8 ms·
Great timing. I was just pondering what functional programming language I should attempt to learn in all my new downtime.
by dcl 7y ago
Great timing. I was just pondering what functional programming language I should attempt to learn in all my new downtime.
- Apollidore 7y agoHaskell is fun, but bear in mind that it's followes a purely functional programming paradigm, meaning you either do things the Haskell or you don't do them :). But it's a fun language to learn, and there are lots of free quality ressources on the internet
- marceloabsousa 7y agoWhat do you mean by "either do things the Haskell (way) or you don't do them"? Isn't that the same with every language? I still don't understand why people put all sorts of unfair labels on Haskell. By labelling Haskell with "fun", we almost make it sound like it can't be used in production.
- Drakim 7y agoWhat I think he meant is more like "either do things the functional Haskell way or you don't do them", as in, there is no non-functional fallback or alternative in the language, which some functional languages have.
- kadoban 7y agoThere's escape hatches here and there. If you need imperative code, use IO or ST. If you need to debug output something, Debug.Trace. If you need to temporarily bypass purity there's unsafePerformIO and friends (or they can occasionally be used permanently if you do a lot of analysis I believe). It's a pretty practical language compared to its reputation.
- Koshkin 7y agoActually, someone said, “Haskell is the world’s best imperative programming language.”
- sullyj3 7y agoSomebody said it, but it's glib, and not particularly true. I believe it was a comment on do notation, the bind operation, and programmable semicolons. The customizability is definitely cool, but nobody could possibly argue that imperative programming in Haskell is ergonomic.
- sullyj3 7y agoSure, IO and ST are escape hatches, but they're not escape hatches that beginners struggling with the concept of a higher order function are going to be able to use.
- giantDinosaur 7y agoI imagined it was more in the sense of the 'Have fun implementing Quicksort!' variety, where you're fighting the language constructs, basically, to do what you want.
- tmountain 7y agoHaskell has a huge catalog of libraries you can reach for, so you don’t have to reinvent the wheel. That said, the Haskell way can seem very different than what you see in most languages. As an example, IO—or anything causing a side effect—has to happen in the IO Monad. There are good reasons for this, but it takes some getting used to.
- vkou 7y agoThe parent poster is not lamenting that Haskell lacks a trivial sorting function. They are lamenting that implementing a trivial sorting function in Haskell is difficult.
- tmountain 7y agoI disagree. quicksort [] = [] quicksort (x:xs) = let smallerSorted = quicksort [a | a <- xs, a <= x] biggerSorted = quicksort [a | a <- xs, a > x] in smallerSorted ++ [x] ++ biggerSorted
- magicalhippo 7y agoNot that I know any Haskell, but wouldn't smallerSorted already include x due to <= operator? edit: also, how is the pivot element selected there?
- zests 7y agoBoth of your questions have the same answer. (x:xs) means x is the first element and xs is the rest.
- lonelappde 7y agoFor 99% of programmers, Haskell can't be used in production.
- yakshaving_jgt 7y agoThis is nonsense.
- gtycomb 7y agoI wish I could give you a thumbs up for speaking plain truth here. Anyway programmers will find out for themselves how best to satisfy their customer need.
- masklinn 7y ago> it's followes a purely functional programming paradigm I'd say that it's one take on that paradigm, the Way of Monads is not the only way to do purely functional, Clean uses uniqueness typing instead. Though it otherwise has rather similar properties to Haskell.
- deleted 7y ago[deleted]
- yeshengm 7y agoI'd say start with some eager functional language such as OCaml without the "object" part. Haskell code is hard to debug cuz you can't rely on good old print. Monad itself is never a silver bullet. Type systems and Composability are the true power of FP IMO.
- willtim 7y agoDebugging declarative code is always hard, whatever the language. Haskell does allow you to use trace expressions which will output values to standard out, see Debug.Trace. This is no reason to avoid arguably the most popular (and state-of-the-art) function language and implementation out there.
- marceloabsousa 7y agoI think we can all agree that debugging languages with lazy evaluation is specially hard. To effectively use Debug.Trace you actually need to add strictness and that can be fundamentally incompatible if you do intend to use the full power of lazy evaluation.
- lonelappde 7y agoDebug.Trace won't solve the space leaks lurking around every corner of your program, and won't shave the hundreds of megabytes to gigabytes of RAM the compiler needs for compiling a non trivial program with dependencies.
- fulafel 7y agoThough The Haskell Way includes the io monad, which is imperative code in practice :)
- Random_ernest 7y agoI tried to learn FP multiple times by learning haskell. Never clicked, tried clojure and I was productive after roughly 2 days.
- lonelappde 7y agoFor the 99%, Haskell's purpose is to teach you what to hate about your working language, not to be a working language. https://blog.plover.com/prog/haskell/what-goes-wrong-2.html https://blog.plover.com/prog/haskell/what-goes-wrong-2.html
- rkangel 7y agoHaskell is very much the deep end of learning functional programming - it's at an extreme end of the spectrum in purity and type system. The language I recommend as a first step to most people is Elixir (or Erlang). It's fairly pure, data is immutable, relies on recursion at the lowest level etc. Good code in Elixir is structure in a similar to good code in a lot of other functional languages (and so teaches good habits), but being dynamically typed is avoids that immediate pain of learning about how to keep the compiler happy.
- dan-robertson 7y agoAs a counterpoint, I picked up (some) haskell pretty quickly. I read a lot of code and didn’t get bogged down reading explanations of what a monad is. I also avoided trying to understand too well what the evaluation semantics of the language were. When I read code, I focused on looking at the type signatures and understanding what they meant, then I would stare at the code and try to work out in my head why those definitions would get those types. I did this at a time when there were lots of “I wrote a program in Haskell. Let me explain how it works” blog posts on this site. I defined some data structures and solved a bunch of project euler problems as practice
- akegalj 7y agoI would second this. My experience is that people get scarred of so much new terms which get introduced in Haskell and that could feel overwhelming. When beginning with Haskell, I would advice to just write code and try to intuitively understand bits, but not get down into unwrapping things or theory much. Stay high level and figure out how things interact as you would do in black box model. Don't open the box, but poke it and see what result you will get (in other words; just write code and do trial and error). When you get comfortable with black-box learning then open the box and look for the details.
- BoiledCabbage 7y agoIf you want to learn a functional language absolutely do not learn Haskell. If you're interested in static functional programming, learn Elm and then F#/OCaml. If you're interested in dynamically typed then learn Clojure or possibly Racket. That's it. Spending time learning Haskell as your first (or even second) fp language is a terrible idea and has done more to slow FP adoption than anything. You can learn Elm literally in a weekend it's so small and well organized (go to their site and follow the tutorial). The concepts you pick up will double the speed you learn any other static FP. F# on .net core is cross platform and can run via a vs code plugin. Plus you have a batteries included full class library of practical needs via dot net. Clojure is very productive, great concepts as well. A bit worse tooling / debuggingqgen you have to drop down to deal with java, but also had batteries included java libs. Racket is probably the most isolated of the above. A scheme dialect and a bit closer to historical scheme and Lisp. Don't learn Haskell it's a horrible use of time as a first language. You get 80% of the value in the above languages in somewhere between 1/10 to 1/4th the effort (depending on which lang you choose), and have learned a more practical language, and will actually learn that lang plus Haskell faster than if you had started in Haskell.
- hvs 7y agoAgreed. Haskell is masters class in functional programming that is generally more interested in pushing theory forward (not necessarily a bad thing). If you are a .NET developer, F# is a wonderful language (based on OCaml) that allows you to ease in to FP since it supports functional, oop, and procedural programming. Plus, you have the whole .NET ecosystem as well. You can become very productive, very quickly.
- agentultra 7y agoA counter point: Haskell is pushing for practical applications of pure, statically typed lazy functional programming. There is plenty of real-world Haskell code in production systems by industrial users. The research is on practical applications.
- outlace 7y agoI’ve tried learning Haskell once or twice and it didn’t really click. However, I’m know knee deep in learning Lean, which is a dependently typed functional language that is also a theorem prover and it’s been a much easier ride. It’s not any less complex than Haskell but learning FP by essentially doing mathematics has made it a lot easier for some reason.
- StreamBright 7y agoI like to think that ML languages, in general, are good to start to learn FP with. SML by Dan Grossman is a great resource because it explains the concepts very well. Anything that you learn after will be easier, does not matter if you go for Haskell or F# later. https://www.youtube.com/watch?v=a1fkhDjCHB8&list=PL-eVNDa9MNJczU4ZjhJDT8rIcCa12DyAx https://www.youtube.com/watch?v=a1fkhDjCHB8&list=PL-eVNDa9MN...
- jlevers 7y agoI see a lot of people below saying to chose a functional language other than Haskell. As someone who's currently learning Haskell, I'm finding it _incredibly_ interesting...but I've heard that many of the free online resources don't lay the necessary foundation for learning the more advanced concepts. I'm 6 chapters into Haskell Programming from First Principles [0], and I highly recommend it. [0] https://haskellbook.com/ https://haskellbook.com/
- Iceland_jack 7y agoHaskell is definitely interesting, there is so much to explore and the community is eager
- Iceland_jack 7y agoJust learn Haskell