Ask HN: What should I give priority, Lisp, Haskell, or the Dragon Book?
So, to the issue at hand. I've been struggling to start The Dragon Book, as I find it incredibly dense and difficult to understand (though, to confess, I haven't given it the dedication it deserves). Also, after reading some of PG's essays and threads on StackOverflow/Reddit/Hacker News, I've been convinced that Lisp is an important language to learn, esp. because of functional programming (which I don't know much about). Then I recently ran into Haskell, which seems to offer some of the same.
My question is this, because I'm in school, I have plenty of free time, but it's still a limited resource. Between the 3 things I've listed (Lisp, Haskell, Compilers), which do you consider to be most enriching? (To the experienced) if you were back in your hacker-youth, knowing only a few languages and how to use a shell, what would you do? Am I making a mistake by starting with the Dragon, and if so, what do you recommend? Should I learn Lisp then Haskell or vice-versa? And what should I prioritize, compilers or more languages?
12 comments
[ 542 ms ] story [ 386 ms ] threadDeciding whether to learn a language or learn how to write a compiler is more difficult. If you are struggling with the Dragon book, have you condidered "Modern Compiler Implementation in ML"? Although ML is even more niche than Haskell, it is a functional language and the book takes you step-by-step through the process of writing a compiler for (a subset of) it.
As for the choice of a functional language for a beginner, I think you just should pick whatever has better introductory materials available. You're likely to experience a big mental shift by using a functional language for the first time. It was a struggle for me, at least. That being said, I'd recommend a Lisp derivative - Racket. It has a very nice tutorial and a good IDE. Also, John Carmack's son game in Racket: https://news.ycombinator.com/item?id=10111479
It us Scheme (a kind of Lisp), it is very functional focused, so many concept will translate fairly good with Haskell and along the way it teach you the fundamental of an interpreter, which is not quite a compiler, but still matching what you are interested in.
And you will be a better coder after that book, I guarantee :)
Lisp & Algol-like has the difference where Lisp's code is also data and its code can rearrange code using macros written in Lisp itself. Both can have functional programming inspired constructs like `map` and `fold` as functions.
Haskell is different because all its code is lazy. So if you write `take 1 (map ((*) 2) [1..1000000000000])`, it runs instantly even though writing idiomatic lisp or python or C will have the computer spinning for ages going through all those numbers you don't even use. It also has partial application of functions, as well as pure functional programming by preventing you to write a line that doesn't contribute to the returned value. The sophisticated type system I have not ever seen outside of the ML family of languages, either.
I haven't read the Dragon Book, but I've written some compilers in my free time, and my compiler code was much better after I had a go at Haskell.
There seems to be a certain personality associated with lisp programmers, which emanates when they speak about the language. So logically I was pretty confident in my choice from day 0. However it wasn't until I actually made a program with it that I was emotionally confident and content with the choice.
In conclusion, I recommend you build a program with Haskell, Lisp, and/or an idea from the dragon book. That experience may give you the best idea of what path will be the most rewarding.
Lisp and specifically Racket because:
1. It's a community that is strongly oriented toward meeting the needs of students.
2. It's documentation is top notch.
3. It's a single download with no external dependencies. There's even a pretty good IDE (that even has a fairly compatible Emacs mode).
4. Racket in the large is an ecosystem that has tools for many many aspects of computer science that a student even at the graduate level might want to play with [meta-programming, objects, type systems, logic programming, ffi, Algol 60, web systems, etc.]. And it all comes down in one package and there's no futzing around with package managers unless you want something that you probably don't want for a long while...did I mention it's a single download.
5. It's beginner friendly. It has its own textbook. It has a gradient of languages with increasing complexity.
I've got nothing against Haskell or Go or anything else. And for a person in a different situation I might be high on one of them...or Erlang. But the orientation of their communities is different and so the problems that they're good at is different, i.e. Go solves Google's problem of hiring a lot of people with a C++ background for systems programming and the problem of packaging programs that run on more servers than one can deploy reasonably to in a week [it uses native executable binaries].
Or learn JavaScript.
Good luck.
I wouldn't suggest the dragon book until you can put forth all the effort it takes. And as far as that goes, theres a lot of other, some would say better, resources available: http://prog21.dadgum.com/30.html