
The Implementation of Functional Programming Languages (1987) - tbirdz
http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/
======
djfm
I've read (part of) this book and used it to implement a toy compiler. It
helped me a lot in getting a better understanding of Haskell and other
functional languages. This is really an amazing book, well worth investing
some time into. It starts from simple definitions and concepts and builds up
on them - very easy to follow even with little to no previous knowledge of the
field.

~~~
krat0sprakhar
I'm on a mobile device so can't view the book. Is familiarity with Haskell is
one of the prerequisites to follow this? Thanks!

~~~
mitchty
It wouldn't hurt, but given this paper predates Haskell by 3 years I think
you're safe.

Would be more a history lesson of what eventually led to Haskell. IIRC Miranda
might be a more apt comparison.

------
e19293001
Although this is quite an old book, the topic is still very relevant even
today. The ideas are timeless and worth reading. I'm impressed by the authors
that made their books survive in a very long time.

~~~
brudgers
The Prentice-Hall Series in Computer Science has a lot of timeless content.
C.A.R. Hoare was an outstanding editor.

------
hcarvalhoalves
Once you get to the final chapters, where an intermediate representation of
lambda calculus is presented (G-code), read this accompanying paper [1] and
wonder where we could be now if the market and hardware manufacturers took a π
degree turn to fully support functional paradigms.

[1]
[https://www.doc.ic.ac.uk/~wl/icprojects/papers/reduceron08.p...](https://www.doc.ic.ac.uk/~wl/icprojects/papers/reduceron08.pdf)

~~~
widdma
> π degree turn

So a bit over 3 degrees?

~~~
panglott
I think that's half of a τ turn. [http://tauday.com/tau-
manifesto](http://tauday.com/tau-manifesto)

------
webreac
I am very suprised to see the association of the word microsoft, 1987 and
functional programming. As far as I remember, Simon Peyton Jones research (and
this book) has made him famous. I was very sad that such a talent was hired by
the "devil" microsoft.

That is old story. He has managed to do great things inside Microsoft and
since the departure of Balmer, my opinion about Microsoft is a lot more
balanced. The association seems an anachronism.

~~~
thinkpad20
Microsoft has been very involved in the development of Haskell for quite a
while now, and functional languages in general, with projects like F# and F*.
Several of the big names in the Haskell community work or have worked for MSR.

------
5outh
This looks pretty promising from the table of contents! It was also written by
one of the main authors of GHC, the most widely-used Haskell compiler.

------
amelius
This is an amazing book. We need more people with writing capabilities like
SPJ. Reading this book is almost like inventing compilers for lazy functional
languages yourself. There really is no substitute other than actually doing it
yourself.

------
dasil003
1987 was the year I first got access to Usenet (via FidoNet). It's interesting
to think how long it would take to download a 30MB book at the time. Of course
it would have been considerably smaller since it would have probably been a
text file or perhaps LaTeX.

When a CS book is relevant this long, I feel like these kind of ruminations
put me in the right headspace to receive it.

~~~
vanderZwan
Well, there's a perfectly fine 6MB djvu file - only one fifth the infinite
download time!

~~~
Maken
Also, as the page states it can be text-searched. A version not consisting on
scanned pages would be neat, but I guess the author lost the sources long time
ago.

------
diggan
Anyone got this in EPUB format?

~~~
jamiek88
Calibre is free and converts easily between all the major formats, I use it on
OS X.

Just FYI, I know I was glad to have it linked to me when I asked a similar
question a few months ago.

------
jaseemabid
Bryan O'Sullivan (Haskell, Facebook) mentioned in a talk that he got into the
whole Haskell ecosystem while interning for Simon P.J. (the author of this
book) and this book helped him get started back then.

------
insejniasty
Here's an implementation of a toy compiler targeting LLVM (with very basic
Erlang interop), which was created with the help of that book:
[https://github.com/pkaleta/kivi](https://github.com/pkaleta/kivi)

------
ape4
I would think that, while tempting, you'd want to avoid recursion in your
implementation.

~~~
eudox
Why?

~~~
ape4
I'm not an expert... but you don't want your C/C++ code stack overflowing or
running out of memory in an uncontrolled way. Your C/C++ can do graph
reduction by working on a structure in a loop. Then you'll be able to better
monitor resources.

~~~
jonsen
There is normally no deep recursion in compiling a program. The compiler would
recurse over recursive program constructs, like nested if statements.
Programmers normally do not nest constructs very deep.

~~~
tbirdz
This may be true for human programmers, but compilers also must compile
machine generated code, which often looks very different. As an example, I
can't remember the source on this, but I have read somewhere that the original
C++ compiler (cfront) compiled C++ into C code, and this generated code
exposed many bugs in the C compilers of the time, as it was very different
than how a human would have written that code.

~~~
jonsen
Running out of stack space compiling a machine generated program would be a
bug in the automatic source code generator then.

~~~
jonsen
In the same sense that running out of stack space compiling a human generated
program is a bug in the programmer.

~~~
kazinator
If human-generated programs compete head-to-head with robot-generated programs
for blowing up the implementation, that human has a _worse_ bug than the
robot.

------
damianknz
If you've done some Scheme (or Lisp (or Haskell (or Curry))) then you will
find this very readable. Section 2.4 has a good explanation of the Y
combinator. I'm going to try and get through the whole book.

