8 ms·
Learning Haskell as a non-programmer (2014)
- corysama 12y agoHere's an audio interview with (I believe) the same person on the same topic: http://www.functionalgeekery.com/episode-19-julie-moronuki-and-chris-allen/ http://www.functionalgeekery.com/episode-19-julie-moronuki-a...
- coolsunglasses 12y agoYep, that's Julie and I. Had a lot of fun talking to Proctor. I don't think it was the case at the time of the interview, but Julie is my coauthor for http://haskellbook.com/ http://haskellbook.com/ now.
- asattarmd 12y agoI thought people say learning Haskell as a first language is easy because 1) you don't have do a lot of unlearning. See, you still don't understand why you want things to mutate. Experienced programmers (in other languages) mutate things in every single line of code they write. They have to unlearn mutating things to learn this. 2) It's closer to mathematics which many people know. I think the problems you faced are actually problems because you read a book that was meant for programmers. Hell, you'll face these problems even if you read a C book that is meant for programmers. I still think, Haskell (as a language) is a good first language.
- coolsunglasses 12y agoThere's less fighting the student's ego involved, but it's overall more work because there's just so much they don't know if it's their first programming language. Experienced programmers repeating the trope that it's easier to teach/learn Haskell for a new programmer are: 1. Not speaking from experience 2. Taking a lot of knowledge for granted Example - explain what a "side effect" is. Why is it a "side" effect? What's ()? Why is that "nothing"? Why does putStrLn return IO ()? That said, it's been a pleasure learning how to teach Haskell and writing the book so far.
- tel 12y agoI suppose there are two ways to interpret that trope. First, that it's easier to teach someone carte blanche to program at some goalpost level of skill via Haskell than other languages. Second, that it's easier to teach someone who has no knowledge of programming otherwise to understand Haskell than it is to teach someone with "imperative experience" to understand it. I wonder what your thoughts are these days on each of these. My understanding is that you have the requisite experience to talk about it, like few others! It's finally interesting to me to state that I think the best version of that trope, though one that is impractical and untestable, is that it's easier to teach a newbie to program Haskell than an experienced Java programmer ignoring some set of standard, non-linguistic training points. This is the most interesting since it gets directly at there being some kind of "imperative mindset impedance" which is presumed to exist, but it's the least testable since I'm certain nobody will ever agree on what those "non-linguistic training points" are. It's probably folly to assume they exist, even. Anyway, I'd love to hear your thoughts.
- kazinator 12y agoEven newbie computer users understand mutation, because they have moved files (or other objects, like mail box items) from one place to another, deleted or renamed them or edited their contents. Mutation is also something exhibited by everyday objects. This is modeled much better by object-oriented programming with mutable state. More importantly, the rigid typing of Haskell isn't found in the real world in which backpacks can hold dissimilar items, and donkeys can mate with horses to produce sterile offspring. Haskell is close to mathematics, sure. Many people know mathematics. However, many people do not know that mathematics which Haskell is close to! So your (2) is a slight equivocation on the term "mathematics".
- coolsunglasses 12y agoMost people using Haskell are using it to write imperative programs, giving up mutation specifically is less of a big deal than you'd think.
- joe_the_user 12y agoI'm pretty sure I can implement any imaginable algorithm without mutation. Implementing it with any efficiency seems like a different question. A common activity in many programs is scanning a list and changing a few items based on some criteria. So far I've heard in Haskel you either duplicate the list or create a complicated data-structure that somehow essentially makes this mutation OK. Either ways seems silly - especially do what you did before but with complex dance around it.
- coolsunglasses 12y ago>Implementing it with any efficiency seems like a different question. Nah, same asymptotic limitations, just different constants and patterns in what's sensible. Example: https://www.youtube.com/watch?v=6nh6LpcXGsI https://www.youtube.com/watch?v=6nh6LpcXGsI Data.Map, Data.Sequence, Data.Vector all serve for most anything you'd want.
- gizmo686 12y ago
- nnq 12y ago> 2) It's closer to mathematics which many people know. No. They don't. Most people have the "how to" knowledge of basic math in their heads. The imperative parts like the algorithm for dividing and multiplying numbers that they run on their wetware computer. The part concerned with reasoning about "what is", the proofs part, the part mathematicians call "math" is not what most people's knowledge of math consists of. Imperative languages really are closer to how our minds work everyday. Yeah, on occasion we do some "deep thinking" about "what is" but most of the time our brain goes about things like "ok, what are the steps to do X? [...] and now I'll always label the result of the last step y [...] and when condition z happens I'll goto step s etc.". ...this is how laws, regulations, institutional processes etc. are formulated. And this how you see nature work: that place on the tree branch where you saw a bird now holds nothing (... 'null bird pointer' ?) or maybe you look around a few hours later after the storm and you see that branch is actually broken (... 'segfault' ?).
- Peaker 12y ago> Imperative languages really are closer to how our minds work everyday Why do you believe this? I think it is a cognitive bias at play, where you've been trained to think this way until it comes natural, and now it's hard to see it any other way. With these lens, you see imperative instructions everywhere. I randomly opened a wiki page: http://en.wikipedia.org/wiki/Sine http://en.wikipedia.org/wiki/Sine In it, you'll find a sine is not described as a series of imperative steps to compute it, but is defined as what it is. Most descriptions and models you'll find of most things are this way.
- nnq 12y agoIndeed, this is how things are described in a textbook. And how they should be. But, for example, after you've learned how to draw an ellipse using a string, a pen and two pins (like https://www.youtube.com/watch?v=7UD8hOs-vaI https://www.youtube.com/watch?v=7UD8hOs-vaI) your intuition and unconscious perception of what an ellipse is will be tied to the process of producing it and a visual representation of this process, not to the arid definition of it like "a curve on a plane surrounding two focal points such that the sum of the distances to the two focal points is constant for every point on the curve". This is why people find really learning mathematics so incredibly hard, because our intuitions are process oriented. And why you can take anyone who is not what I call a "mud-mind" (people that just can't do rigorous logical thought) and and teach him/her how to write code in an imperative language until they can get something working, while making the same person understand (not memorize!) a mathematical proof or envision such a proof is just 10x times harder. I love functional programming and being able to do "what is" reasoning about programs. But I think this is just inherently hard for the human mind to do, we're not optimized for it, we're optimized for generating sequences of instructions that we send to our muscles to execute (and our muscles and bodies and mind too are obviously stateful, btw) and we're much better at generalizing this "dirty" way of thinking even for abstract pursuits like software development...
- ademarre 12y agoLearn to program and do it with Haskell — In the back of my mind I thought this was covered, but apparently I was wrong. Could an intro to computation textbook using Haskell be a good alternative introduction to CS?
- nandemo 12y agoHutton's Programming in Haskell covers that. I'm not sure if it works as a good intro to modern Haskell, though.
- theseoafs 12y ago> Honestly, I still don’t really understand imperative languages. Why would you want things to mutate? Because in the computer, things need to mutate, and so a language that doesn't mutate is therefore far from the computer. EDIT: Put another way: Haskell does support mutation, but inside of particular monads. So obviously mutation is useful. Learn why it's useful in Haskell and you'll see why it's useful elsewhere.
- DonPellegrino 12y agoIn my opinion you're seeing it wrong. The beauty of FP is that from your code's point of view there is no mutation. Everything is immutable, everything is clean and beautiful. But then the compiler is able to tell that your variable that's used as an argument to a tail-recursive function is actually being redefined on every recursive call and treats it as a mutable variable in the output assembly. Similar ideas are applied throughout those languages. For example, in OCaml you have the notion of "functional record updates". Basically you update structs by getting a whole copy back with the modified fields changed accordingly. Under the hood though, what you get is just the changes and the other fields point to the original struct. Basically there is a difference between what your code says and what the compiler outputs, but in the end the result is the same, the compiler is just smart enough to rewrite it for you. You're right that it's further from the computer, but only for what you type in your editor. I highly recommend the book Functional Data Structures (it's on Amazon) if these sort of brilliant compiler optimizations interest you.
- theseoafs 12y ago> The beauty of FP is that from your code's point of view there is no mutation. The beauty of pure FP is that from your code's point of view there is no mutation. The only functional language you mentioned in your post is OCaml, which is impure and supports ad-hoc mutation, like every other language in the ML family, and like every other functional language except for a select few like Haskell and Miranda and their derivatives. Moreover Haskell supports other kinds of mutation besides fusion and tail-call elimination; it just does it behind a pure interface. See, for example, http://hackage.haskell.org/package/array-0.1.0.0/docs/Data-Array-IO.html http://hackage.haskell.org/package/array-0.1.0.0/docs/Data-A... . So we're back at the same place: obviously mutation is useful since even Haskell goes out of its way to make sure you have access to it.
- quadrangle 12y agoAs a comment on the post itself already says The Haskell Wikibook https://en.wikibooks.org/wiki/Haskell https://en.wikibooks.org/wiki/Haskell is the very best option for those with no programming background.
- coolsunglasses 12y agoI'm going to disagree, particularly for people with no programming background, as it's often incomplete and lacks exercises. Some (not all) of the material that is there is good though.
- quadrangle 12y agoUm, the Wikibook has exercises, and you can add more, you know. The incompleteness is not relevant here. The last quality someone needs when they have no experience is completeness. Sure, the Wikibook isn't complete (but you can add to it where it's missing!), and more exercises would be good. But for anyone coming from zero, the priority is being the best overall introduction to the concepts. Once you're well in the door, then you aren't a total beginner anymore. The elementary track of the Wikibook is a superb overall introduction. I wasn't saying it stands alone and is all anyone ever needs.
- coolsunglasses 12y agoI don't really agree with the approach enough to make the wikibook into what I think is needed without rewriting most of it, which is why I started writing a book instead. I go over some of the problems with other resources here: http://bitemyapp.com/posts/2014-12-31-functional-education.html http://bitemyapp.com/posts/2014-12-31-functional-education.h... I didn't touch on the wikibook in part because people have this weird partisanship about it that I haven't yet fully understood.
- alexashka 12y ago"So, as I was starting with Haskell, I had Linux, Git, an invitation to join an IRC channel (a wut?) and, er, “a text editor” thrown at me. " If this doesn't strike you as very WRONG, I don't know. How about codecademy in a browser instead. Some folks shouldn't teach.
- spv 12y agoDijkstra's comments on using Haskell as first language for CS Undergrads http://www.cs.utexas.edu/users/EWD/OtherDocs/To%20the%20Budget%20Council%20concerning%20Haskell.pdf http://www.cs.utexas.edu/users/EWD/OtherDocs/To%20the%20Budg...
- revskill 12y agoThe inspiration that brings Haskell to me is the similarity when you do : ls . | wc -l on console. Each monad is to be composed to each other, without knowing others. Each monad is self-controlled and has its own world. Pureness!
- plongeur 12y ago> To me, it’s a bit like saying that if you already know English, then learning a second language will be more difficult for you than if you didn’t know any language. To master a first native language takes at least about 16 years for most people ... I think you can reasonably master a second language way faster by leveraging language analogies. I also have a very hard time believing that learning Haskell is easier if you lack programming experience in imperative languages. > along with learning Emacs, but they are mere constituents in a continually growing pile of stuff I still need to learn. At no point she gives a reason for why to learn Haskell in the first place. I mean you only have so much time - why spend time learning Emacs just out of nowhere? > True Confession: I didn’t know Github existed until I started learning Haskell; I didn’t even know what version control was. So, as I was starting with Haskell, I had Linux, Git, an invitation to join an IRC channel (a wut?) So where is her GitHub repo? Can't find the link. There is probably a lot of very smart Haskell code to be found, I guess. > Honestly, I still don’t really understand why people like imperative and OO languages. She writes that she has no experience in other language paradims but she does know why it's worse than functional approach? Sure ... The only thing missing in this post is a humblebrag comment about how she just got a dev position at Google ...
- 6d0debc071 12y ago> To master a first native language takes at least about 16 years for most people What's your definition of master? That doesn't sound like the kids I'm thinking of when I think 'learnt English' and mastering a second language to the same level of mastery as the first I am unsure can be done in a shorter timespan (though conversational fluency to the point where one can understand and be understood is on a significantly shorter time-scale.)
- tel 12y agoThis feels needlessly judgmental. She has a friend who likes Haskell and taught her. The things he taught make sense to her. Perhaps she doesn't have the experience to make a fuller judgement, but that doesn't stop her from talking about what she's personally discovered. The amount of derision you've managed to read into that is remarkable.