Hacker News new | ask | show | jobs
by siraben 2150 days ago
Writing interpreters in Haskell (which is what some of the lessons seem to be about) is a great way to learn the language. It naturally motivates recursion, algebraic data types, strong types, higher-order functions and later, when effects such as state and errors are needed, monads arise naturally.

The best part? It takes a ridiculously small amount of code to do all that, maybe around a hundred or less. Languages without ADTs and higher-order functions bend over backwards to recover them[0] via design patterns.

[0] http://www.cs.ox.ac.uk/jeremy.gibbons/publications/hodgp.pdf

4 comments

It also introduces you to the expression problem pretty quickly and organically :)

I agree with the comment though. I learned Haskell and how to write an interpreter at the same time by working through the book Crafting Interpreters. It was a great match.

Back when I did my degree, Haskell still wasn't a thing, like it was giving its first steps.

So the choice would be Lisp, Prolog, Caml Light, or the recently released Objective Caml.

The year before I took compilers design project, the TA responsible for it used to disallow them from the implementation language option list, as it would make the assignment too easy.

Agreed! I've been trying to learn haskell for a long time, and this guy writes a json parser live, giving his intuition along the way. It's helped me immensely. https://www.youtube.com/watch?v=N9RUqGYuGfw
compiler, evaluator constructs should be the bottom of the next set of mainstream languages (possibly being born today by former haskell programmers?) imagine free monad lisp