Why is Haskell a mathematicians language?

Why is Haskell a superior language? Why are boot camp and web devs scared of it?

Other urls found in this thread:

haskell.cs.yale.edu/wp-content/uploads/2011/02/history.pdf
en.wikipedia.org/wiki/ML_(programming_language)
en.wikipedia.org/wiki/Hindley–Milner_type_system
axiomsofchoice.org/haskell_type_system
manning.com/books/type-driven-development-with-idris
manning-content.s3.amazonaws.com/download/7/b2efb6c-0182-47e4-a78b-797c49e66d0d/SampleCh13.pdf
en.wikipedia.org/wiki/Intuitionistic_type_theory
en.wikipedia.org/wiki/Curry–Howard_correspondence
cs.cmu.edu/~15150/previous-semesters/2012-spring/lect.html
en.wikipedia.org/wiki/F*_(programming_language)
leanprover.github.io/introduction_to_lean/
unpetitaccident.com/pub/compeng/FP/Type Theory And Functioanl Programming-ttfp.pdf
en.wikipedia.org/wiki/Parametric_polymorphism
en.wikipedia.org/wiki/Turing_tarpit
cs.uoregon.edu/research/summerschool/archives.html
functionalcs.github.io/curriculum/
youtu.be/RqFgtYrw4J8?t=704
codersnotes.com/notes/a-constructive-look-at-templeos/
youtu.be/i9CU4CuHADQ
twitter.com/NSFWRedditGif

/g/

I tried but g is full of brainlets.

Because the goal of boot caps is to turn you into a "vocational" programmer that can churn out apps and office tools like a factory conveyor belt. Not to teach computer science.
I did one of these myself after leaving HS.

However right now I'm working through SICP and it made me realize the difference between a programmer and and computer scientist.
I'm finally starting to get an intuitive understanding of things like tree recursion.
I like the elegance of scheme and I'll definitely will try Haskell soon.

Because it's a shit language with limited extra functionality as opposed to C++ for instance.

Everything I pull from Wolfram is translatable to (C)++. Haskell is like Erlang (forced to work with), there's no fucking need for it. Stable OOB languages provide sufficient functionality, or, a way around certain things (like hard coding (rarely) or the long way home) but are stable, have decent documentation and blatantly fucking work.

OOB = OOP obviously. Drank dome wine

>mutability
>state
Go back to /g/.

because nothing of worth was ever written fully in haskell, and mathematicians think being useful is selling out

Short, condenced answer: you don't have side effects => can reason mathematically about programs

Are you sure?

What's with the hate of Haskell and the love of Java?

There is no love of Java.

...what?

OOP is a horrible way of achieving the things it intends to deliver.

Composition is a much better system for reusing functionality.
As for polymorphism, Rust traits or Go style interfaces are superior to C++/Java style hidden vtable pointer interfaces/inheritance.
And OOP isn't needed for encapsulation at all

I also don't understand the point of associating functions with types. The Idea of static functions is even more laughable.

Enjoy your shitty inheritance trees and type taxonomies.

>I'm finally starting to get an intuitive understanding of things like tree recursion.

woah....................................................................... truly................ a master................. computer scientist...................

haskell is an example of a computer scientists idea of mathematical thinking

Except mathematicians made Haskell.

Why do you think that? It's wrong.
Here's the history form the source

haskell.cs.yale.edu/wp-content/uploads/2011/02/history.pdf

>Why is Haskell a mathematicians language?
Arguably this: It's purely functional, i.e. has no side effects.
>What does this mean?
It means your code is a concatenation of functions in the mathematical sense: Functions are objects that for a given input x always return the same output y=f(x).
That's not enforced for something like C++ or Python. There you CAN write a function that does stuff like pic related. In Haskell that's not possible. Moreover, Haskell has a type system (that translates to "System F", you can look it up on Wikipedia) and by some mathematical results, type systems share syntax with formal logics itself.
That being said, there are languages that are "more mathematical" than Haskell. E.g. the ML family
en.wikipedia.org/wiki/ML_(programming_language)
As you can read in the essay above, mostly, Haskell was cooked up because CS academics interested in ML like languages wanted a common language to research the concept of laziness. That's when terms are only ever computed when you need them. This way Haskell can e.g. work with infinite lists. In Python, when you write
>sq = [k^**2 for k in range(5)]
you get the reference sq pointing to some place in your computer storing the list [0, 1, 4, 9, 16]. In Haskell, the expression for sq lingers around unless you work with it, e.g. until you project out the 2'nd element of the list. This way, you can e.g. in Haskell write
>ps = 2 : [i | i 0 | p p^2 ps is a list starting with 2 that has all i (from the list of ALL natural numbers starting with 3) which have the property that the remainder of i/p is nonzero, where p are the primes (recursively accessed via ps)

I'm doing learn you a haskell right now, so I'm no expert, but can't you do similar shit in python with generators/iterators and shit?

I supposed that works, yes, there also seems to be a StackOverflow thread on that iterator.
I use Python at work (physicist), but note that Haskell is lazy (=non-strict) by default, i.e. everything is non-strict in that way.
Btw. laziness was the motivation for Haskells creation, but it's not really the most selling feature (for when it left academia). In fact, laziness is "bad" because it makes it extremely difficult to reason about memory storage. It's funny because being purely functional helps with reasoning, but Haskell has aspects that make it difficult.
A reason why Haskell is nice to work with (apart from the relatively high entrance barrier as it's relatively hard to learn) is that the compiler helps you complete code. A reason people did ML was when the following was discovered in the 70's
en.wikipedia.org/wiki/Hindley–Milner_type_system
I get into Idris now, which has a richer type system (but no full Hindley Milner), and strict evaluation.

That's some cool shit. I'm also in physics, so I've self-taught python. I'm interested in programming languages too, hence trying to haskell it up. I'll look into ML too, that sounds interesting.
Thanks for the explanation though, you sound like a cool guy.

What are good theory books to read on this? Even if Haskell was made by CS academics it feels like this can all be formalized in the language of mathematics

I started taking notes on Haskell from a mathematical (category theoretical) perspective here
axiomsofchoice.org/haskell_type_system
and will do youtube videos on Idris once I got the book by the main developer that was just released
manning.com/books/type-driven-development-with-idris

To compare with Haskell, pic related is an example from the idris book (all the code can be downloaded in the book link above)
Basically, you have a boolean data type
>B={True, False}
(called DoorState={DoorOpen,DoorClosed} here)
and a door command type, essentially
>DoorCmd : B -> B -> Type
which let's you construct 4 types
namely
>DoorCmd(DoorOpen,DoorOpen)
>DoorCmd(DoorOpen,DoorClosed)
>DoorCmd(DoorClosed,DoorOpen)
>DoorCmd(DoorClosed,DoorClosed)
and then some monad stuff to set up "do" notation.
The gain is that you can e.g. write
my_program : DoorCmd(DoorClosed,DoorClosed)
and the code you write below won't compile unless it satisfies the specifications that all actions start out with a closed door and in the end you end up with a closed door again.
It's descibed in this chapter
manning-content.s3.amazonaws.com/download/7/b2efb6c-0182-47e4-a78b-797c49e66d0d/SampleCh13.pdf

Since Intuitionistic type theory bascially IS constructive formal logic via Curry Howard, all mathematically thinkable specifications can be put into a type expression this way. Meaning e.g. your boss can write a few lines expressing a type that says
>map an integer to a (the) list of it's prime factors
(i.e. the full specification of a task)
and the employee is now tasked to implement an algorithm, and his shit won't even compile unless it does exactly what it's supposed to. The whole spec has made it into the type system, because it's expressive as math itself.
And maybe we can automate programming in this way, to some extend, i.e. have programs generated, just having to write the type. Haskell can do this to some extend, where it's easy.
E.g. if you write the type
SwichType = forall a b. (a,b) -> (b,a)
then the Haskell compiler can compute an algorthm that fits the type (because there is only one function that has that type, extensionally speaking)

en.wikipedia.org/wiki/Intuitionistic_type_theory
en.wikipedia.org/wiki/Curry–Howard_correspondence

>mathematicians language
It's very type theoretical and that makes it easier to think about from a mathematical perspective. That said it doesn't mean it is popular amongst mathematicians, in fact it is not. However, theorem provers are really just pure languages with more sophisticated type theory baked into them. Agda for instance is basically Haskell with dependent types. Such theorem prover languages are popular in certain circles in mathematics and may become more popular in the future as said line of research develops.

>Superior
It's not superior in the sense that no language is truly superior. Some languages are more appropriate than others in certain contexts and no language is most appropriate in general. The future is moving towards domain specific languages and this will become more obvious over time. That isn't to say that Haskell doesn't have some very good qualities. Perhaps the most striking is that it's far easier to write correct code in Haskell and for certain tasks the solutions are much simpler and cleaner. Compiling Haskell with optimization turned on (it's off by default and most people don't realize it) can often make it run comparably fast to C code.

>boot camp and web devs
Because they're memers who latch onto the next big meme. Pure functional programming is just a different way of thinking about programming and it can be difficult to grok at first. Moreover handling stuff like state can only be done by utilizing monads in Haskell and they can be difficult to grasp without a (very) basic background in category theory. There are some web dev communities out there that have embraced functional programming within javascript, even big famous javascript memers will often give talks on introductory functional programming with monads in javascript. You can find many such talks on youtube.

Ignore this retard who can't into monads and never learned how a functional compiler is different from a traditional compiler.

I cooked up a more silly Python example for how side effects even prevent you from assigning a straight forward type to f (it has sum type of Int and String, if you're generous), let alone make it functional

Yeah I sometimes hate that about python how the output type isn't well defined.
Sometimes it's really useful, but it's just really dangerous.
I know that the argument is supposed to be "python is much more readable so you just won't make type mistakes like you would in other languages." But it's still just scary for me sometimes.

The red pill is that learning a functional language (Standard ML for example) is much, much easier than learning any kind of imperative language.

By much easier I mean in massive magnitudes. People are just 'scared' of it because of the weird syntax but the GESTALT of functional programming is Types are theorems (specifications) and programs are the proofs. Once you understand that you can build incredibly complex shit and reason about the whole thing because it's trivial to verify via induction your massive pile of complexity.

If you want to learn functional programming get the book 'Discrete Math' by VanDrunen which uses SML and look at the 2012 lecture notes for 15-150 at CMU.

>2012 lecture notes for 15-150 at CMU
>for 15-150
Excuse me, what?

cs.cmu.edu/~15150/previous-semesters/2012-spring/lect.html

Thanks!

What's the difference between Go and Rust?

Functional programming is a stepping stone towards Logic programming

Prolog is the future

what kind of research can I do if I want to do research around functional programming/haskell? Asking as a math major that finds this more interesting than traditional areas of pure math.

category theroy and type theory.

Logic programming the future? In my view it is the past, just nice to play around. Please explain.

Automated theorem proving. Although that field is arguably quite dry. I've been shilling for automated code generation above, although admittedly there's at the moment not enough manpower in it for this research to take off.

I know of Microsoft projects such as F* or Lean

en.wikipedia.org/wiki/F*_(programming_language)

leanprover.github.io/introduction_to_lean/

The best would be to just start learning a language and produce some tools for Git. Your interests will manifest from there

Thanks what are some good books on getting into this?

what's OOB? object oriented brogramming?

>Why is Haskell a mathematicians language?
Because you can spend your entire life studying it without ever doing anything useful

>This way Haskell can e.g. work with infinite lists. In Python, when you write
>>sq = [k^**2 for k in range(5)]
A generator expression lets you work with unbounded sequence.

Because it's outdated and useless for industry use?

>this
We name dropped a million topics by now, what do you mean.

What you may searching for could be
>Type Theory & Functional Programming - Simon Thompson
unpetitaccident.com/pub/compeng/FP/Type Theory And Functioanl Programming-ttfp.pdf

How does Haskell compare with lisp?

Most notably, Haskell has a polymorphic type system and Lisp has very few primitive notions.

en.wikipedia.org/wiki/Parametric_polymorphism

Haskell is mostly just for looking at instead of using. See

>a language that doesn't prevent brain-dead retard shit like this is bad
>needing polypedantic type systems to hold your hand so you don't put a square peg in a round hole

Get the fuck back to /g/ with this pseudo-math bullshit. Haskellfags are the epitome of armchair intellectuals.

>Talk for hours about how great their language and type system is
>"So what have you actually made with it?"
>"UH UH MY 100TH PARSER FOR A TOY LANG SHUT UP!!!"

Excellent, thanks!

only armchair intellectual here is you.

>sauce: pure mathfag, go to /g/ yourself brainlet

Is it possible to do numerical algorithms in haskell or functional language?
From what I've learned numerical stuff is very procedural a lot of the time.

Haskell is a meme.

haskell is turing complete: what you can do in a procedural way, you can do in a functional way (category theory is even capable of beeing a formal foundation of math instead of set theory).

>side effects must be typed with monads
no thanks, some things are just more natural to program with state and imperative programs and there are languages which allow me to pick the best of functional and imperative style

I suggest you acquaint yourself with this concept

en.wikipedia.org/wiki/Turing_tarpit

Thought about writing "...can theoretically do...", I see I should have. Thx for the link.

The creator of Idris (which as opposed to e.g. Idris has the aim of interacting with the real life system, and does bindings to other langusges), like to call a language
>pacman-complete
if you can actually write programs (as opposed to do stuff like "memory tape manipulation", i.e. just be Turing complete in a formal sense)

Haskell is the pinnacle of language circlejerking. It requires so much time and effort to fully learn that it puts the scope of C++'s language features to shame. Yet using Haskell isn't 1/10th as productive as using C++ is (if not, where are all the programs?).

studying algorithms/AI/ML > studying PL masturbatory shit

Theory A > Theory B desu.

What's the difference between Go and Rust?

>I'm finally starting to get an intuitive understanding of things like tree recursion.
a true gombuter scientist

>I am not personally familiar with it so it must inherently be difficult to learn

>>sq = [k^**2 for k in range(5)]

I'll guess ' ^** ' was a typo.

You could just turn it into a generator and yield the result until Next shows up.

In Python you can even use lambda and map it, which is kind of the same process, but Guido doesn't like lambda. Almost any function can be turned into a generator for the sake of memory.

If you're using comprehensive lists like that and need to turn it into a generator just change the brackets for round brackets.

Pic related

I forgot, depends on the version of python, but since 3x (iirc), range is already a generator.

Wrong. Prolog is very different from purely functional languages like Haskell.

>Go here
>Pick a year with good lecturers
>Watch those lectures
cs.uoregon.edu/research/summerschool/archives.html

It's basically a crash course to category theory, type theory, logic, and some areas of programming language theory. You could also try to attend over the summer (even as an undergrad it isn't too hard to get in).

Yes and no. It really depends on the sort of algorithm. In all honesty if you're asking this sort of question (i.e. you've found yourself in a position where you're searching for a 'better' language to write numerical algorithms in) then you are probably going to want to go with something like Matlab/Octave, some language + Cuda, or perhaps python + a domain specific framework for the sort of problem you're working on (eg. deep learning frameworks).

Haskell can do numerical stuff and it can often do it quickly (in some implementations optimizing away entire parts of the algorithm yielding faster results) but there are likely to be better languages out there.

If you want to research in type theory here you go: functionalcs.github.io/curriculum/

OPLSS is great too, I put it in that above curriculum. The best is the 2012 Proof Theory by Pfenning and Harper type theory talks.

Type Theory is mainly a branch of Applied and Pure Logic. I spent 6 months doing linear, modal and substructural logic it's a rabbit hole you fall down into and consistently discover there is yet more logic to find

Forget "boot camp and web devs" they aren't even software engineers. They're irrelevant, stop talking about them - they will die out soon once the bubble pops

And Haskell is not a superior language. If you can't write a program in C, you can't write it at all and you're not a real programmer.

Why is the list [2, 3, 0, 1, 6]??

I'm not that guy, but let's be honest - it's known to have a steep learning curve

If you know basic algebra then you know functional programming.

Types are theorems (specification) and the program is the proof of said theorem via induction. It's a completely awesome, and efficient way to program once you get it and all current research in CS is entirely functional these days

>If you know basic algebra then you know functional programming.

If you just want to program, maybe ok. But if you would like to truly understand, then If you call some category theory concepts (for example monads) "basic algebra" I'm honestly impressed.

>awesome, efficient way to program
true

>If you know basic algebra then you know functional programming.
You'll not be an able programmer who can in reasonable time solve relevant tasks.

I meant just Standard ML/OCaml functional programming is basic algebra, but monad's are just yet another algebraic abstraction and you can use them without having to understand how to prove them in Category Theory.

If you want to get to that level of abstractions with Algebra follow this guide to build up your exposure in algebraic abstractions. They key is starting small and building up or else none of it makes sense. Seeing lectures and seminars are crucial too until you are comfortable at that level then you can tear through Awodey's CT book.

It's actually the opposite. Programming in a functional language (not necessarily Haskell which has a lot of strict types) requires much less code and time to finish whatever it is you're doing. I TA'd a compiler construction class and the starter code for the labs in ML/OCaml was only 1/3 what it took to write the same starter code in Java and C++. You can also write up some insanely abstract/symbolic type generics and macros (like Common LIsp) inside a DSL and compile gigantic programs with minimal amounts of code. The best part is you can prove your pile of abstractions is correct too that it satisfies the specifications you wrote for it.

In simple terms both Go and Rust are written with a view to replace C. For now Go's main focus is to be a language in which you can write efficient networked systems in hence its prevalence cloud computing and distributed systems. Rust's goal for now is to become a better replacement language for systems programming language compared to C.

If you want to tinker with distributed systems pick Go else play with Rust.

>Haskell

youtu.be/RqFgtYrw4J8?t=704

Programming in practice is about training monkeys working in your company, though, and monkeys won't learn this fast.
Sure, it might be able to write short and smooth programs in a good language, but the procedural block of commands structure is easier to get into. Thus, Haksell is hard to learn, in comparison

Do you think both will survive in the long run?

Go has done well so far, and is being used in major projects and in the industry. All well known cloud service companies are asking for Go experience.

Rust except Redox and some other open source projects has yet to have the same level of adoption as Go. Only time will tell.

In the long run, C will still be there for a lot longer than we might think.

In 3 range is a generator but the list comprehension still gets put in memory unless you do generator expression.
bitwise xor

You sound so up your own ass it's incredible.

>and all current research in CS is entirely functional these days

>implying TempleOS isn't hot shit that's only being held back by the author's schizophrenia and religious zeal.

codersnotes.com/notes/a-constructive-look-at-templeos/

Bump

I think the steep learning curve comes from the fact that most people are approaching it from an imperative programming background. I think if you took a class of mathematically competent undergrad freshman with zero programming background, they'd do fine

>author's schizophrenia
t. MIT CIA Nigger

>but monad's are just yet another algebraic abstraction and you can use them without having to understand how to prove them in Category Theory.
>prove them in Category Theory

I'm not the guy you responded to but I'm honestly doubting whether or not you actually know category theory. Also, the algebraic abstraction approach to Monads is kind of terrible for learners (learning adjunctions and then deriving monads from that). In my opinion the easiest approach is through Kleisli Categories and those can be taught without going too deep into category theory.

Also, Standard ML/OCaml aren't really the best example for claiming to know functional programming given that those are not pure functional languages and it is common practice for users of those languages to fallback on gross side effect laden code that certainly doesn't qualify as functional programming.

This. Writing compilers is better in every way in Haskell.

All of those things are possible in Haskell. Terry is just being silly to keep the CIA off his trail.

I arguably come from the mathy background (but not really) and never grasped why Kleisli categories are nice or interesting to look at.

In any case, as few days ago I googled again and saw that this guy who's doing a category theory for programming blog started putting his blogs to videos, here

youtu.be/i9CU4CuHADQ

A good Chardonnay?

they literally have haskell and functional programming generals up perpetually
they're not brainlets, they're just autistic

They're neither brainlets, nor autistic. They're straight up retarded.

It's a language that forced its way into the fields by Sun/Oracle throwing money at it. Nobody actually loves Java except people who don't know better and universities. Universities love it because Oracle pays them to teach it.

What languages should universities be teaching intro and intermediate programming in instead? My university uses Java for both to teach OOP.

Universities don't like Java either, but they accept that the vast majority of their CS students are going to work in the software industry. Putting out a resume that reads
>experience 2 undergrad projects. Can only code in Common Lisp
is not a good idea.

OP confirmed for not knowing what the hell he's talking about. After 20 years, Haskell is still an experimental language that is barely suitable for fizzbuzz.

>Haskell is like Erlang (forced to work with), there's no fucking need for it

Same way there is no fucking need for javascript but choose to do you webdev using it anyway instead of hippie shit like elixir. There are reasons why people choose to code in erlang and it's because it provides a type of thread safety similar to the hipster language called Pony.

Haskell is a meme because even though you don't have states in functional programming, trying to avoid states is really hard.

You could suggest Wolfram Mathematica aswell which wolfram alpha is using.

>instead of hippie shit like elixir

How is it hippie?

>Why is Haskell a superior language?

It is not.

>Why are boot camp and web devs scared of it?

They aren't scared. 20 years of Haskell has produced virtually no real useful programs, libraries, or APIs.

It is a joke, little more than a theory language for CS graduates to circlejerk over.

The ^ operand is not powered to operand.
seq= [x**2 for x in range(5)]
will give you what you expected.

Well for now it is hipster.
But I demonstrated that Elixir has some similarity with erlang. Looking att programs written in erlang you will see that their uptime is very impressive.

Yes, evidently, but what is that operation then?