14 ms·
Is Haskell the right language for teaching functional programming principles?
- pacala 9y agoUse a good _library_ of persistent immutable data structures. In any language your audience is already familiar with.
- adrianN 9y agoFunctional programming is not just about using immutable data structures.
- CJefferson 9y agoMy feeling is Haskell is a bad teaching language for the same reason C++ is -- there is too much "this is some crazy stuff you have to learn about the language" early on. One reason I have learned to love teaching Java over C++ is that the language-based bugs tend to be "shallow", at least in the first few weeks. The error messages tend to be easy to interpret, and when programs crash it is easy to understand why (how to fix it might be hard of course!) For later year students, it's fine to expect them to learn the weirdnesses of Haskell and C++, but not for a student on day one.
- crimsonalucard 9y agoC++ isn't as crazy as the concepts in haskell.
- swift 9y agoI’d argue that you have to get pretty deep into experimental GHC language extensions to get into anything as weird as some of the SFINAE-based template metaprogramming tricks I’ve seen (and used, sadly) in C++.
- jorvi 9y agoIt's all in the approach. I've noticed most universities these days either get students started on Python or C. I believe the idea behind starting with Python is that most beginning students will hit the ground running, whereas the idea for C is that you get thrown in the deep end but will have a deeper understanding (and perhaps foundation) going forward. Which approach is better I dare not say..
- msla 9y agoC is good for teaching a simplified machine model, one with a distinction between stack and heap, pointers, and a purely sequential execution model. This is enhanced if you use it to program an Arduino or similar trivial hardware, collapsing the division between hardware and software to one piece of hardware (the single-board computer) and one piece of software (the code the student wrote) and nothing else. C, in short, gives a good way to control actual hardware without having to introduce students to the complexities of actual hardware. Python is good for teaching algorithms and OO design, precisely because it allows students to focus on the algorithm while not having to slow down the course with memory management. In both cases, the idea is clear: Only teach one hard thing at a time, and then build.
- CJefferson 9y agoI teach C as a second language. It is useful to learn from a historical perspective and because so much software is written in it, but I find it doesn't give that good understanding of machines compared to say java, and many of the problems are C specific. By "C specific" I mean reading from freed variables, or going out of bounds in arrays. These bugs are horrible to find, but also don't map cleanly to the underlying machine, because often the compiler will optimise away invalid accesses, or move them somewhere weird, meaning you can't use your understanding of the real machine to understand the C bug.
- tytytytytytytyt 9y agoI always thought it'd be a lot nicer to learn FP, without the static type system stuff, say in Erlang or Scheme, so students would be able to recognize the difference between the two.
- macintux 9y agoI always thought FP was a cool idea but I couldn’t get started. Erlang was a revelation.
- pyrale 9y ago> there is too much "this is some crazy stuff you have to learn about the language" early on. There is actually not that much crazy stuff you must learn early on. The problem with Haskell is that it's hard for beginners to know what stuff they should avoid.
- platz 9y agoyes, especially when bloggers and conference talks show off that edgy stuff. People begin to get attracted to Haskell because of those things. Things have changed a bit too over the years. I've heard of folks that burned out on haskell after wrestling with Arrows, and obscure arrow operators. Also, remember iteratees?
- te_chris 9y agoIn my personal experience: No. I tried Haskell and Scala multiple times but never worked. Once I got to elixir everything just sunk in and felt easy. YMMV
- mjhoy 9y agoI love Purescript, but I think in some ways it is even more arcane than Haskell for a beginner. e.g., > :t (+) forall a. Semiring a => a -> a -> a > :t (&&) forall a. HeytingAlgebra a => a -> a -> a
- dualogy 9y agoAgreed on both points, love it and a bit too wicked for new-comers. Elm is perfect there and should find its place into all kinds of educational contexts hopefully. Such a friendly ML language, I secretly call it "the Basic of FP/ML land" (an honour in my book; more modern equivalent might be Python there but you get the idea). Also good that it's missing "advanced" stuff like type-classes, built-in monad/functor/applicative & friends. Good for teaching because students will be compelled to learn to write that themselves from the ground up. It's all lambda calculus under the hood anyway, and thusly representable "hand-made from scratch".
- kccqzy 9y agoBut it requires a different kind of skill altogether. A semiring is a concept in abstract algebra that’s quite independent from general functional programming.
- mjhoy 9y agoThat's kind of my point. Usually when you're just learning "general functional programming", you're thinking about, say, (+) as a function that takes two numbers, and returns a number, because you're at the stage of figuring out how something like fold (+) 0 [1,2,3] works. Introducing "Semiring" as a concept at the same time can be a bit much for a beginner! I do think it's a useful concept, and that Purescript is an excellent, intermediate-level FP language.
- galvs 9y agoGo SJT! He taught me haskell back in 2003 - rotating ascii horses
- megaman22 9y agoNo. It's a great way to turn people off from the whole idea. I suffered through a course in Haskell and functional programming in college, and the course material was so up its own butt about monads and type classes and algebraic data types and such, that I essentially wrote the whole thing off as academic flubbery. It didn't help that whatever version of GHC we had then gave off error messages more cryptic than C++ template metaprogramming, and it was such a cluster to have to bounce into the IO monad to just to do some intermediate printf debugging. It wasn't until years later and exposure to .NET LINQ that it started to click and the motivations for why you would want to use functional programming became apparent.
- TuringTest 9y agoI studied Haskell in college (with the Gofer variant), and it was GREAT for learning practical functional programming. We didn't use monads though (they weren't in widespread use back then), so we had to learn the accumulator-parameter pattern and tail recursion the hard way. Learning my foldr's and foldl's and zipwith's gave me confidence that almost any imperative programming can be equally represented as a recursive function, which is an important lesson for someone who had only learned about traditional imperative programming and OOP up to that point. Of course, a proper course should center around algorithms and recursive data structures where functional programming shines; it should not begin with building business application logic, for which a classic language may have a gentler ramp-up.
- HelloNurse 9y agoIf your course didn't cover monads, it was a very introductory one which would have probably benefited from choosing a nicer and simpler language, like antiquated LISP or maybe Scheme.
- deleted 9y ago[deleted]
- TuringTest 9y agoIt was introductory, yes, although it also covered relational programming in PROLOG. I benefited from the type inference/type declarations, and learning about generics explained in a non-duck-typing way, though, which I wouldn't have had in LISP.
- crimsonalucard 9y agoI do believe that Haskell is the wrong language to learn functional programming principles. Right off of the bat Haskell forces learners to use monads for IO. Monads are an advanced concept; too advanced for beginners. If learners end up do kind of getting the IO monad, a big number of them actually end up not being able to understand why it's good or even understanding what a monad is completely... and see it as a pointless overcomplicated abstraction. I knew a person who learned Haskell then moved on to javascript due to the wall he hit while trying to understand monads. I've looked at his javascript code and his idea of functional programming is just littering his imperative javascript code with maps, reduces and filters. Thanks to redux, a lot of people are getting a broken view of what functional programming really is via javascript. If you think you've learned functional programming via react/redux and javascript... chances are you haven't really understood it yet. Ask yourself, why is functional programming called functional programming and not called immutable programming? If you don't know the answer... you haven't really grokked functional programming yet. The right language? Racket maybe?
- arca_vorago 9y agoI'm very interested in FP but I'm a sysadmin, not a dev, so I had to do a lot of reading. My conclusion is racket would be good for teaching indeed, but I think its ecosystem is a bit too academic though it is getting better. Instead, I think I would offer guile scheme as a language with some good, active projects to help on, such as the new cron replacement mcron. I would probably also offer elixir and some lisp variant. It was actually lisp that got me so interested in FP because I saw how much it was being used in AI research. That said, I think its worth noting Haskell is the only one I've seen listed here that is pure FP. So if one wanted to really use FP, it might be worth wading through the maze like Haskell ecosystem, but I don't think for teaching.
- yawaramin 9y agoI disagree that you have to learn monads for IO. I know some tutorials mention monads right off the bat while teaching IO but that is not a recommended teaching approach. For IO what you would need to learn is that all IO actions are values of the `IO` type and they can be sequenced together for guaranteed ordering using the `do` notation. That's it. No monads. We can introduce monads after we show using the same `do` notation for lists, `Maybe`s, and `IO`.
- sddfd 9y agoWhat do you think about Standard ML as a language for teaching? I like it because the syntax is clean, it is functional and higher-order, but also has an explicit concept of references (i.e. mutable memory) and using functions with side effects (i.e. printing) is no trouble at all.
- hood_syntax 9y agoSML was my first exposure to FP, and while I didn't _really_ get it then, it was responsible for my initial interest in Haskell after graduation. I think SML is a great tool for teaching FP.
- ulrikrasmussen 9y agoI second that. I followed an 8 week university course teaching introductory programming using SML and picked up Haskell on my own afterwards. I think SML helped me get enthusiastic enough about FP to motivate me to study the more advanced concepts
- mahmud 9y agoI have been programming for over 20 years, most of it in FP land. ML is tractable, a beautiful prism through which one can peek at Computer Science as a subject, but it has a frustrating lack of _practical_ tooling and beginner-friendly community. For anything outside basic I/O, you will need to dust off compiler-specific extensions, most of them last used on "Un*x Workstations". Just look at the Basis library. Safe to say it's nowhere near Racket, Scala, Clojure, Kotlin, ... http://sml-family.org/Basis/manpages.html http://sml-family.org/Basis/manpages.html
- adjkant 9y agoRacket / HtDP is the best way to teach functional programming to beginners. http://www.ccs.neu.edu/home/matthias/Thoughts/Growing_a_Programmer.html http://www.ccs.neu.edu/home/matthias/Thoughts/Growing_a_Prog... Haskell obviously has its place, but it is much better used when looking at something like PL Theory at a 3000-400 level.
- baldfat 9y agoTHIS! Racket is an educational programming language as well as now a great general purpose language. I tried to learn Haskell three times and I always left with a bad taste in my mouth. So many paper cuts in the ecco-system aka I HATED Cabal and I know they changed it but man that this was horrible.
- cglouch 9y agoDefinitely agreed. I was introduced to functional programming via Pyret, which is similar to Racket and draws from HtDP in terms of pedagogy. It's a much gentler introduction than being thrown to the wolves with Haskell or OCaml. I'm sure one could learn FP effectively with those languages too, but if you're still trying to wrap your head around the functional paradigm you don't really want to have to stumble across words like "endofunctor" while reading the documentation. I even have a good math background but I would have found that confusing at the time. https://www.pyret.org/ https://www.pyret.org/
- adjkant 9y agoGlad to see people are enjoying Pyret! If you don't like the parenthesis in Racket, this is the path for you.
- emmelaich 9y agoYes, I did the Coursera Racket course and it was great.
- ajuc 9y agoI've mostly learned functional programming with SML at university, and then I learned Clojure with no problems, and after that I still had problems with learning Haskell. So I'd say - no. I especially had problems with searching for varios operators and what exactly they do. Also (despite having some experience with SML) - currying makes function definitions hard to read.
- yorwba 9y agoI have never seen an operator that I couldn't find with Hoogle. E.g. for (&&&): https://www.haskell.org/hoogle/?hoogle=%26%26%26 https://www.haskell.org/hoogle/?hoogle=%26%26%26 You can also search by type: https://www.haskell.org/hoogle/?hoogle=%3A%3A+String+-%3E+IO+%28%29 https://www.haskell.org/hoogle/?hoogle=%3A%3A+String+-%3E+IO...
- norswap 9y agoAs much as I hate to say this, I think untyped functional programming is the way to go to teach about the virtues of functional programming. We do this at my university using the obscure but awesome Oz programming language (1). But then students (and some professors, truth be told) complain that it's obscure... If I had to pick one, I'd say Elixir. It's like Erland with less wonky syntax. Another option is a pure scheme. But people hate on the parens (yes, it's not very smart, but people are going to do it anyway). Pyret (2) is also made for this purpose, but that's sort of the caveat: it's a teaching language and people don't like that. (1) https://www.info.ucl.ac.be/~pvr/book.html https://www.info.ucl.ac.be/~pvr/book.html (2) https://www.pyret.org/ https://www.pyret.org/
- pivo 9y agoToo bad about scheme, that's the language I used to learn functional programming and it seemed to make so much sense in that context.
- submeta 9y agoI got in touch with Scheme twenty years ago. Read the specification (R5RS) and that was the first time programming in Lisp made sense to me. Because the specification was so short, I could remember every detail after a short time. Also the syntax was so predictable unlike Common Lisp with its myriad of operations. Without reading too many books about Scheme I started programming in it. Learned about tail recursion. About destructive vs non destructive operations. About functions that always returned values. Then I got in touch with SICP ("Structure and Interpretation of Computer Programs"). Man, that book was a revelation. Scheme was a breathe of fresh air coming from C/Pascal/Java. It was a totally different way to tell the computer what I wanted to do (although I had similar thoughts several years earlier programming my HP28s calculator in a Forth like language, then later when I started using Mathematica).
- flavio81 9y agoScheme is pretty alive and kicking, see "Racket".
- Fiahil 9y ago
- kevinSuttle 9y agoI'm in the boat of learning FP right now. What would really help me, and folks in the same process, is for people to suggest languages that _would_ be better, and why, instead of doing the stereotypically HN commenter thing that I'm already seeing.
- yawaramin 9y agoI always recommend https://www.coursera.org/learn/programming-languages https://www.coursera.org/learn/programming-languages for learning FP, the professor has fantastic explanatory videos that are really clear and concise. You'll get the most out of it from doing the exercises, but you can still take away a lot from just watching the videos.
- kevinSuttle 9y agoThank you. I'll check that out.
- MBCook 9y agoI wouldn’t think so. Maybe Clojure? I kind of like Haskell but I’ve been turned off by the way some of the development is done. There is, for all intents and purposes, only GHC. Yet everyone uses it by tuning on all sorts of special options to make it more usable. Why are they options? To remain ‘compatible’ with the ‘other Haskell compilers’ that basically no one seems to use. It’s like if JS all defaulted to 1.0 and you had to pile on options to use any features after 1998. It just makes things much more confusing and odd than necessary. To support something it seems like no one uses. It will also be easier once the whole applicable/monad thing is done.
- slowmovintarget 9y agoClojure's focus, after simplicity, is functional programming. Haskell's focus is as an experimental vehicle for type system theory. If you want to teach type system and category theory, use Haskell. Functional programming does not require Hindley-Milner type inference, and that happens to be one of the larger cognitive hurdles in Haskell. Algorithm W is a layer on top of the Lambda Calculus, not something essential for understanding it. +1 for using Clojure to teach Lambda Calculus^h^h^h functional programming.
- platz 9y agoJust because there are some folks that use Haskell for for experimental studies, doesn't mean that Haskell is not a great language for line-of-business programming. I can't say it better than Gabriel Gonzalez: "Haskell is unbelievably awesome for maintaining large projects. There's nothing that I can say that will fully convey how nice it is to modify existing Haskell code. You can only appreciate this through experience. When I say that Haskell is easy to maintain, I mean that you can easily approach a large Haskell code base written by somebody else and make sweeping architectural changes to the project without breaking the code."
- burkaman 9y agoI think many of those special options will eventually become defaults once the Haskell 2020 standard comes out, which was started last year: https://mail.haskell.org/pipermail/haskell-prime/2016-April/004050.html https://mail.haskell.org/pipermail/haskell-prime/2016-April/... You can follow along here: https://github.com/haskell/rfcs/pulls?q=is%3Aopen+is%3Apr https://github.com/haskell/rfcs/pulls?q=is%3Aopen+is%3Apr GHC is definitely the only widely used compiler, but there is at least one other significant one I know of: https://github.com/IntelLabs/flrc https://github.com/IntelLabs/flrc
- gurelkaynak 9y agoWe were thought functional programming with Dr. Scheme and Miranda. I think they were ok. Never had any problems with them. Have no idea about haskell.
- dualogy 9y ago> Have no idea about haskell Born as a non-proprietary Miranda alternative, but instructors would have to be careful to side-step various modern quirks across the libs ("SQL as a free-monadic-profunctor-optics" and such broohaha) for a similar teaching experience.
- opaqe 9y agoWhy not ML? Our programming languages course had a unit in ML and the transfer to Haskell after that was not trivial but still a smooth learning curve -- I could read not just getting-start or for-beginner guides.
- lisardo 9y agoI learned FP using Racket. It was a good experience, but the parenthesis were really annoying. It makes you feel stupid. I believe Elm would be better choice. It would allow to get a visual result easily (html), there is a clear convention about code formatting and the compiler errors are really friendly.
- justinhj 9y agoMy path to functional programming started with Paul Graham’s lisp essays and books and then SICP and Scheme. I visited the world of Haskell but only half heartedly as I was much happier in a dynamically typed world for my hobby projects. As a daytime C++ coder I found types an annoyance; so much time wasted getting something to compile. Later I came to discover types again with Scala and now I’m fully sold. I will revisit Haskell again some day but most likely will learn Elm first. Elm is a much friendlier ML style language and much more explicit about things like monads. Moving from Elm to Haskell is much easier since the programmer will have “aha” moments mapping what they did explicitly in Elm to what you can do more generically with type classes in Haskell
- cryptonector 9y agoI'm lucky enough to own copies of On Lisp and ANSI Common Lisp. These books are a pure pleasure to read -- a lot like reading a novel.
- flavio81 9y agoMay the warm light of Lisp enlightenment shine on you -- CL blew my mind!!
- cryptonector 9y agoI strongly recommend these two books. They are amazing!
- hackermailman 9y agoRobert Harper has written a few posts on his personal blog why they use SML to teach functional programming, why they teach it to freshmen, why they don't use Haskell ect https://existentialtype.wordpress.com/2011/03/21/the-dog-that-didnt-bark/ https://existentialtype.wordpress.com/2011/03/21/the-dog-tha... "Finally, this article explains why Haskell is not suitable for my purposes: the principle of induction is never valid for a Haskell program! The problem is that Haskell is a lazy language, rather than a language with laziness. It forces on you the existence of “undefined” values of every type, invalidating the bedrock principle of proof by induction. Put in other terms suggested to me by John Launchbury, Haskell has a paucity of types, lacking even the bog standard type of natural numbers."
- joelhaasnoot 9y agoI actually enjoy the benefits of my course in Clean at university ( http://clean.cs.ru.nl/Clean http://clean.cs.ru.nl/Clean => "Clean is a general purpose, state-of-the-art, pure and lazy functional programming language"). While challenging, it taught me all the functional principles. Many of the language features and principles can be applied and useful for understanding Python, Scala, Kotlin, etc. Applying it to something that wasn't just plain 'ol boring was slightly hard, but creating soccer team logic as the final project with a pre-written GUI module was lots of fun. Before that I never thought exams that required writing actual code were a good idea, but this one pulled it off well.
- shados 9y agoAbsolutely not. You need a gateway drug before Haskell becomes interesting. It's one of those things where you should not use a solution to a problem until you understand what the problem IS. Otherwise you'll feel like things are complicated for no reason. ML, Elm, Elixir, Closure or even (yes, really) JavaScript are much better places to start.
- jgtrosh 9y ago> Full disclosure: at Kent, after teaching Haskell for many years, we currently a compulsory second year course on “functional and concurrent programming” s/currently/currently dispense/
- hbbio 9y agoI have taught FP to more than one thousand students over 5 years. For all of them, the language was OCaml (at several universities, in Paris). At the time and still today, I think that OCaml is a very good language to learn FP. Students that learn FP before any other programming language get it quickly, and others can compare and write both the imperative and the functional form of a given program. But as a whole, the installation is easy and uniform (which matters a lot when teaching) and the standard library sufficient for everything, as you never want to have a lot of dependencies for the same reason. Of course, OCaml has its drawbacks: A weird syntax, terrible tooling... but you don't really see that when learning programming concepts. The only students which complained were the ones which already spent a lot of time programming before class and trollers at the same time.
- yawaramin 9y agoFor dismissing syntax complaints, have you looked at ReasonML?
- oggyhead 9y agoHaving learnt Haskell as my first programming language, sure it has a high learning curve but it pays off in so many ways. It is without doubt the most beautiful language ever conceived. Without doubt it is the right language to unlearn imperative bs and the right language to learn functional programming principles. Even against the likes the of lispy langs and other ml flava, Haskell reigns supreme with it's purity
- BoiledCabbage 9y agoIt's the most "beautiful", and It's the most "pure" are probably reasons 99 and 100 on a list of priorities when choosing why a beginner should learn a language. Those reSons are reasons for people instilling why others want then to learn that language, not why it's the best for them to learn.
- marcosdumay 9y ago"It's the most pure" is a perfectly good reason to learn a language if you are trying to learn the concept about what the language is pure. Of course, that completely flies in the face of an education system oriented towards training hordes of non-thinking peons into start positions at the job market. So, yes, it's not for everybody.
- gnaritas 9y agoThe question is about learning functional programming, Haskell forces you to learn much more than that to use it. Functional programming should be taught in something like Scheme, which lets you focus on the functional without being forced to also deal with a crazy Hindley-Milner type system that has nothing to do with functional programming. Haskell is not the right language to learn functional programming in, it's not the right language to learn anything in, beginners should start in easier languages. > It is without doubt the most beautiful language ever conceived. Only if you're a masochist.
- yorwba 9y agoI'd say Haskell is the right language for mathematicians to learn programming. Purity and laziness make Haskell definitions almost indistinguishable from mathematical ones; that means that the functional part of "functional programming" will come easy and you can focus on the "programming" part instead.
- hellofunk 9y agoHaskell is really the intersection of functional programming and static typing at the highest level, and these are 2 very different things, and it will be very easy to get lost in the typing aspect for fear of not grasping the functional aspect. If your goal is to teach just functional programming, then Haskell may be too much since the language is about a lot more than just functional programming. Scheme or a light lisp (including Clojure) is often the way FP is initially taught, since you can focus directly on the functional aspects and leave the complexities of static typing out of it. This was the tradition at MIT for a long time (maybe still is).
- christophilus 9y agoYeah. I have to agree. The same was true for me with OOP, when learning it ages ago.
- jdeisenberg 9y agoHackett (https://github.com/lexi-lambda/hackett https://github.com/lexi-lambda/hackett) seems like an interesting project in this regard.
- greencore 9y agoHaskell itself is difficult to understand unless you give someone to read "Learn you a Haskell for great good". I was giving this book to my junior developers to read for understanding such principles like recursion, list manipulation functions like map, filter, reduce etc. and it worked pretty well.
- polyfish42 9y agoBeginner programmer here – I just want to say that I credit Elm with getting me hooked on programming. I tried other languages (Ruby, Javascript, even Elixir) but I never made it past the first project. With Elm, I've made a few projects and show no sign of stopping. Here's the best I can determine why: 1. Elm is simple, so I have fewer options to choose from when solving a problem. This means I learn a few ideas really well. 2. Even thought Elm is very much about the web (as the article mentioned), it's awesome to be able to see things in your browser immediately. It's also helpful to be able to build an application without a backend. You can see your model in the same file that you see your view, which helps you more easily think about each part together. 3. Complier/Type System: Once I finally figured out Union Types, the compiler is super helpful and friendly. 4. Elm forces you to handle errors, functions that can fail, and "Nothing", all things that you have to (a) know about and (b) remember to do in other languages. 5. Lack of tutorials, documentation and libraries to rely on means less "productivity" but it forced me to really learn the language and how things worked. I had to implement OAuth without a library, read source code to figure out what a function did, and couldn't google every problem. I'm too new to know if Elm taught me the most important things a I should know about programming, or if there are better options out there. I do know that it's really fun. As a beginner, that might be the most important thing.
- BoiledCabbage 9y agoThis is so true. Anyone who wants to see the ideas behind Haskell and It's style of languages succeed should be doing everything they can to support elm. You can't find and easier, more straightforward introduction to the concepts and style of programming than it. Yes purists will complain about the bells and whistles it does have, and that's exactly the point. You can learn elm and be productive in it in after a single weekend. And it's error messages should be the industry standard for language messages in any language. It's incredible how simple and accurate they are. It will change your view of what a compiler is capable of. Not to mention it's not a far leap for people already doing web coding.
- wtetzner 9y agoThe only thing I wish it had was something like ML's module system, with functors. Mainly, I think it would be a good thing for Elm to have because it fits so well with the Elm architecture.
- lonk 9y agoNo. You need to understand monads before learning FP and you need to learn FP for understanding monads. This is chicken/egg problem. Functional programming is overrated.
- dragonwriter 9y ago> You need to understand monads before learning FP No, you don't. You don't even need to understand them before learning Haskell, much less before learning FP using a language which doesn't use monads as pervasively as Haskell does. You obviously need to learn at least something about monads as you learn Haskell, but understanding them is not a prerequisite.
- userpass 9y agoI would lie if I said this isn't fun which is probably the reason why people do it in the first place even though their explanations might make it worse than just reading this: https://hackage.haskell.org/package/base-4.10.0.0/docs/Control-Monad.html#t:Monad https://hackage.haskell.org/package/base-4.10.0.0/docs/Contr... Asking what a monad is is like asking what an iterator is. It doesn't tell you very much what it actually does because it depends on the implementation. The iterator is just an interface. A bunch of functions that have to be correctly implemented according to certain rules. It all first started with lazyness. FP developers wanted a new modern language developed from the ground up. It should be a pure language. The haskell developers soon realised the evaluation order of a pure language must not necessarily be fixed. Eventually lazyness was born. Lazyness was a unique and very appealing feature for a purely functional programmming language. However as soon as a haskell program had to leave it's protective shell and interact with the real world lazyness turned into a double edged sword! FizzBuzzes were printing their buzzes and fizzes out of order! Chaos ensued and haskell developers returned back into the shell. After long years of work they have finally discovered it! A mechanism to force the evaluation order of a program to be partially sequential again! It is a new type of container that allows you to put another type inside it. However sometimes the only way to access the contained value is by giving the container a function that takes a the boxed value as input and returns another container with a boxed value inside! The value never escapes the box. And so was the (IO)monad born! You can now take two IO actions a and b and turn them into c which is a combination of a and b where the output of a is piped into b. Not only can we send messages to the outside world, we can also finally receive them! Everyone was happy in haskell kingdom until the imperative migrants started writing monad tutorials... (including this one) This story is fiction by the way. As a bonus for all the wasted time. another crappy analogy: A cage inside a bird is given a machine that puts birds in cages. The regular tool called functor that only replaces what's inside the cage would give us a bird in a cage in a cage! The special tool gives us what we actually want! The tool named monad gives us a bird in a cage! No nested cages!
- crusso 9y agoGiven your constraints, I'd say that Elm is an excellent choice. It's simplistic enough to be approachable, the easy web integration is a feature (not a drawback as you mentioned), and people are doing "real work" in Elm so they will be able to use it for years moving forward.
- k__ 9y agoProbably not, because it's lazily evaluated and almost no other language is.
- erik14th 9y agoI think Haskell is a beautiful language, but it's community seems too elitist and pedantic, which from my perspective makes people value sophistication and "elegance" over readability and ease of comprehension. I'd recommend Elixir, it's code is beautifully readable, it's pragmatically functional since it's based on Erlang, I'm not refuting Haskell usefulness in the real world, I'm just pointing out it's functional nature is academic, while Erlang's functional essence is pretty much a colateral effect of the problems it was aimed to solve. edit: Thinking again, even from the academic perspective, I'd still go for something like Racket, in my sense of aesthetic there's no competition to the beautiful simplicity of lisp.
- neilparikh 9y agoCould you clarify what you mean by elitist/pedantic? I've found the Haskell community to be fairly friendly, and very open to beginners (including when they ask basic questions). I've mostly been on /r/haskell and Quora, and watched talks by Haskellers though, so maybe the community is different on other platforms.
- Sophistifunk 9y agoI'd say this thread is a perfect microcosm of it. In JavaScript, the general attitude is "you're right, this thing you're complaining about is kinda stupid, here's this tool to make it go away" versus "no, you're wrong, Haskell is great, STFU"
- neilparikh 9y agoI don't think that's really true in the Haskell community. I've seen lots of self-criticism of Haskell on /r/haskell. Even SPJ himself is willing to admit that Haskell has design mistakes. Some things Haskellers readily admit as issues with Haskell: - the String type - records - laziness (more contentious, but many people agree that this might not have been the right choice) - error messages - the prelude Essentially, my experience has been that Haskellers are willing to accept that Haskell is not perfect.
- bpyne 9y agoThis question leaves me with more questions. The post looks at a few alternatives without giving context. 1. How does the course fit the overall curriculum? 2. What is the experience and maturity of the people taking the course? 3. How strong are the teaching skills of the instructor? The density of functional features taught in a certain time period matters. A drastic change in mindset simply takes time that, I would say, is greater than a standard semester. A single semester is fine if FP is going to be reinforced, thereafter, in other courses. Also, starting students with FP instead of imperative or OO means less to break down and relearn. I've read numerous debates that try to define functional programming. I don't want to start another one because they're tedious. My experience is that functional programming is a change in mindset in how to solve a problem and organize code. The instructor's ability to teach matters. The time given to learn matters. Reinforcing the concepts throughout a curriculum matters. For each point I make above, you could make a valid case for a different FP language/ecosystem. As much as I like Haskell, it's not a "one size fits all".
- sitkack 9y agoI think Python is a wonderful language to teach functional programming since it is so accessible for many definitions. One has to go a little off the rails to get all the functional features, but it is possible.
- Myrmornis 9y agoI also suspect this makes sense for an introductory FP class (FP, not static typing). The students have already already met the language, and they can compare functional and imperative styles of solutions to the same problem. I think I’d go with python, and then have one or two lectures near the end showing a language dedicated to FP / static typing.
- sitkack 9y agoYeah, and by using a widely available language, they can actually use these techniques in the field.
- davesque 9y agoOne might consider using a functional language which isn't lazy. Haskell's laziness makes its behavior harder to understand and is not necessary to illustrate the core concepts of FP.
- abritinthebay 9y agoNo. The best language is likely the one you know best. Be that Ruby, JS, Rust, or C++. That way you can concentrate learning the principles and you’ll immediately know how to apply them. The basic principles aren’t hard anyhow - you can learn them completely in a day. The hard part is applying them and understanding the trade offs.
- gnaritas 9y agoNo, teach in Scheme; functional programming has shit to do with advanced static type systems.
- meebob 9y agoI think there is also an emotional/social dimension to choosing a beginner's language that is important to take into account. Imagine (putting Haskell's static typing aside), the difference in feeling between learning the basics of FP (say higher order functions, streams, all the different ways of dispatching function calls, etc.) in Haskell, vs OCaml, vs Clojure, vs scheme, vs javascript. Poking around on the internet, the beginner is going to get really different aesthetic vibes from each of these languages. To shamelessly generalize: - Haskell/OCaml feels cerebral, academic, Mathematical, maybe even elitist - Clojure/scheme has that dark-terminal screen, classic 80s vibe- to me it feels nostalgic and quirky. - Javascript is, of course, javascript- it's bright, active, and, most of all, popular All of these will bore/intimidate/comfort/excite different student demographics in different ways, completely independently of the programming concepts that you're teaching. So I think it's important to keep in mind the aesthetic preferences of the students you're trying to catch.
- js8 9y agoIt worked for me, but I guess (also based on comments here) it depends on personality. I like to learn (work things out) from theory and I generally prefer to learn elegant languages that introduced some concept rather than a watered down version of that concept as it was adopted in more pragmatic languages. Some other people might prefer to be more practical and understand the theory later, and so prefer languages that are more pragmatic before they accept a new paradigm. Haskell, due to its annoying insistence on pure functions, made functional programming click for me. I have seen functional style in impure languages before (Common Lisp) but I didn't have the discipline to really code that way - I only saw the downsides. Haskell forced that discipline on me, so I could also see the upsides. One significant upside is that one is forced to make functions really small, which leads to more readable and composable code.
- pklausler 9y agoIs there any other language with purity, laziness, and static types that could possibly be put forward as an alternative to Haskell?
- bitwize 9y agoFunctional programmers practice a form of no-true-Scotsmanism wherein type and category theory are an intrinsic part of "true" functional programming. So unless you are working in something with a type system at least as expressive as Haskell's, you are -- arguably -- not doing true functional programming. (Sorry, Schemers.)
- amatecha 9y agoI'm currently learning Haskell from "Haskell Programming From First Principles"[1] and enjoying it so far (even attending a local weekly study group). I'm absolutely learning functional programming principles and then some. Pretty effective thus far, and I find it extremely accessible. [1] http://haskellbook.com/ http://haskellbook.com/
- chasedehan 9y agoBuy this: http://haskellbook.com/ http://haskellbook.com/ I tried LYAH and some other sources a few times, but was really turned off by those approaches. It wasn't until i found HaskellBook that I really started liking it. I think a lot of it depends on the background of the person learning. I came from a strong math/stats background before I learned to code and so much of it clicked a lot better than other imperative languages.
- nicolashahn 9y agoI learned Haskell in a course called "Comparative Programming Languages" by Cormac Flannigan (https://users.soe.ucsc.edu/~cormac/ https://users.soe.ucsc.edu/~cormac/) my last year in college, so I had done a lot of procedural, object oriented programming by then, but no real emphasis on functional and especially not purely functional. It was probably my favorite course I took in college, owing a lot to his outstanding teaching style. It awoke an interest in programming languages and a strange fetish for the beauty of them. I was probably the odd one out, few other students enjoyed it as much as I did. I became a slightly rabid Haskell promoter for a little while. I realize it's not great to build most things in but I think everyone should have the same experience I did with it (after learning some basic programming and gaining a working knowledge of at least one "easy" language like Java or Python, but before you've spent too much time with them and have solidified your opinions).
- ShareDVI 9y agoI had an FP course on F#, really liked it.
- Chiba-City 9y agoHaskell Type Classes are brilliant. But I would recommend a strict evaluation language like ML (and modules with signatures) for Semester #1 and lazy Haskell for Semester #2. Anyone could cover a ton of useful contextual material taking just a little more time.
- galaxyLogic 9y agoHaskell syntax is terse but not simple. Not good for teaching Functional Programming PRINCIPLES. See: https://www.haskell.org/onlinereport/haskell2010/haskellch10.html https://www.haskell.org/onlinereport/haskell2010/haskellch10... . How about using Lisp to teach functional programming? Lisp syntax is small, simple. You don't need to teach so much Lisp as teach with Lisp.
- throw-away-8 9y agoLisp syntax is particularly ill-suited for humans.
- GarvielLoken 9y agoSICP in Scheme is the only true answer. You are all heretics.
- latj 9y agoI knew the answer after just reading "Is Haskell the right language..."
- alaties 9y agoI think Haskell is very akin to C++ in terms of learning curve. There are a ton of concepts you have to learn up front to even get started. The compiler is generally unhelpful if you've never dealt with it before. There are a lot of approaches to solving a problem and the language does not make it clear which approach is preferred when. Unless you're a masochist, these qualities can be quite off putting. I think a language like OCaml is a good entry point into functional programming. The compiler errors are really useful. The language pushes you towards a sane functional approach. The learning curve is pretty smooth, too. My alma mater seems to agree and FP with OCaml in the upper level CS intro course (https://www.seas.upenn.edu/~cis120/current/index.shtml https://www.seas.upenn.edu/~cis120/current/index.shtml).
- yahoojprty 9y agoColts vs Titans Live Stream Free https://indianapolis.craigslist.org/eve/d/watchcolts-vs-titans-live/6349068008.html https://indianapolis.craigslist.org/eve/d/watchcolts-vs-tita...
- walterstucco 9y agoNo
- sriku 9y agoNot entirely on topic, but related, I have an evolving attempt at introducing programming language concepts by building a forth-like language in JavaScript - https://github.com/srikumarks/nospoon https://github.com/srikumarks/nospoon It is written in a stream-of-thought literate style. Feedback welcome as issues.