I’ve been using Elixir on personal projects for a while (I even managed to create a dashboard tool at work using Elixir which is now on some screens in the office), but I still feel I haven’t made the switch of mindset from imperative to functional, I’m working with Java at work, and I think that thinking more functional will help me to be a better programmer. I studied functional programming at uni a long time ago, but now I really wanna go in depth to change my mindset, and I think that in order to understand I should go and read books about pure functional languages. After researching I think I’m gonna read a Haskell book, Real World Haskell - do you guys think this is a good idea, that reading a book like that will help me to understand the concepts about functional programming and help me to change my imperative mindset?
It can teach you functional programming but it also has a lot of other concepts which are really orthogonal to functional programming.
- Lazy by default
- Functors, Monoids, Monads
I’ve tried to dive into Haskell a few times. I have no problems with the functional part but I never manage to grok the entire “system” so I spent more time struggling with that than learning functional programming. They say it is a good language though so perhaps I’ll give it another go sometime.
You might also want to have a look at more general functional programming books such as:
Haskell is root of functional programming. If you know haskell you know it all
But haskell can be no so much practical in some cases, but I think it worth to know it.
I don’t know Real World Haskell book but I can recommend you http://haskellbook.com/.
You can check book resources at my repo https://github.com/mkunikow/haskellbook.
There is nice slack channel for this book. So if you stuck with something you can ask.
But you will be need patient with this … you will need some time to get used to
I also recommend you to check
Well, not quite as lisp predates it by 35 years Even erlang is older. It has been the academic playground for computer science for a while though.
I mean not the oldest … but it have most concepts of functional programming. So if you want to learn all concepts Haksell is place to start. And if you learn all concepts , it will be easy to pick any functional language.
thanks @cmkarlsson, I also read about Structure and Interpretation of Computer Programs - I might give it a try as well. @mkunikow I also read a few recomendations about Haskell Book - gonna research a bit more between both books and make a decision. And thanks for the podcast, gonna listen to it tomorrow.
There is an
lfe version of it as well in progress but you might want to have a look as it will give you an idea what i looks like:
A little old now, but this thread might help:
Everybody is different.
After repeated goes at Haskell, it was Clojure that finally helped me getting “functional”. Functional Programming in Erlang actually conveyed the mindset quite effectively, mainly because you’re not getting bogged down with type classes (as much as I like static typing - I wish they would run Introduction to Functional Programming in OCaml again). From that perspective Learn Functional Programming with Elixir (Pragprog) may be worth a look - the first chapter is available from here.
That being said of all the Haskell resources that I’ve used I liked haskellbook the most - but the chasm between (C, C++, Java, C#, Python)-ville and Haskell is quite wide so it may be a good idea to look for a more intermediate destination before moving on to Haskell.
I’ve got it and was waiting for it to get a final release, by the look of it that should be right about now:
We’re going to publish the final version between end of February or the beginning of March.
I think I am going to read it next
Was announced as “in print” in the February 28, Newsletter.
I got convinced to try haskellbook, but seems that there is not a printed version, at least can’t find one. So might try real world haskell, and then hopefully Functional Programming in Erlang
Will there be a print version?
The short answer is: we hope so; we’re working on it.
The slightly longer answer is that it didn’t make sense to worry about that too much while the majority of the book wasn’t written yet. We’ve been churning and adding new material quickly, and to maintain that speed, we had to delay giving serious thought to printing. That said, we hope to make it happen. We do have our early access buyers in mind and will offer them discount codes for the print book when it is available if the publisher/printer allows it.
At 1200+ pages it’s best considered as a long term project.
Note that because of it’s age Real World Haskell may be more frustration than it’s worth especially from a beginner perspective.
In the short term, according to the TOC, Learning Functional Programming with Elixir does seem to hit all the right spots:
- Pattern matching
- Higher Order Functions
(…but that’s all I can say because I don’t actually have access to it)
You can always have a look at the source code to see if it’s not advanced enough for you.
The book is not final release, so this is only electronic version.
But who needs printed version …
I read all books on Samsung S2 9.7 tablet. Specially good if you have safari online account.
Waiting for this book
yeah read a few reviews saying that probably it’s not the best book for a starter.
I could read some of the elixir books, but there are some concepts that I won’t learn as currying for example as there is not something elixir has natively, plus I consider I understand the basic concepts like pattern matching, recursion, etc, so wouldn’t like to read a book that explains concepts I already know in a language I kind of already know and use, that’s why I wanted to read about functional programming applied to a pure functional language to help me think functional.
IMO currying is overhyped - the core idea is partial application, i.e. a function accepting a parameter and returning another function ready to accept the remaining parameters which kind of falls into the “Higher Order Functions” topic (function returning a function - often for the purpose of feeding it to a higher order function) and is realized in Elixir with a closure.
That seems to be discussed in Creating Anonymous Functions - passed that currying is a “nice to have”/“cool feature” as it streamlines lots of partial application cases (but not all of them).
I would say that Higher Order Function is function as take another function as parameter like map.
With currying you can create anonymous functions much cleaner
map (add 1) [1..10]
Correct. The controversy is whether functions returning other functions is part of that thinking. Some people exclude it, others include it. My stance is that its part of the whole “functions as values” toolset and that the function being fed into a function is often produced by a third function. So it seems natural to have that entire discussion all at once.
actually currying was just an example. But somehow I still have the idea that learning or reading about functional programming applied to Haskell will help and be useful even for my Elixir programs, whereas by reading about functional programming applied to Elixir I will miss some concepts more specific to functional programming that don’t apply to Elixir (some theoretical concepts and some practical concepts). This is why I’m looking for Haskell books.
Algebraic data types
data List a = Nil | Cons a (List a)