News for hackers. Stuff that matters.

Ask HN: Recommend an introductory course on compilers

I am doing Bachelors in Information Technology and to my bad luck, my curriculum does not have a course on compilers. I looked online and found one on Coursera only to realize that it has now been removed. Could you guys recommend a good compilers course or book which gives a good introduction to the topic along with a guided practical implementation? I would be much obliged.
( 22 comments | 66 points | on HN )
Re:Ask HN: Recommend an introductory course on compilers by n00b101 on Sunday December 25, 2016 @06:30PM (#13256017)
This is not a course, but a practical tutorial that will teach you the "nuts and bolts" and get something pretty cool (a JIT compiled REPL) working easily:

http://llvm.org/docs/tutorial/

These are examples in C++ and OCaml.

There's a similar tutorial in Python as well, which should be easier to get running:

http://www.llvmpy.org/llvmpy-doc/0.9/doc/kaleidoscope/Python...

Re:Ask HN: Recommend an introductory course on compilers by zachgersh on Sunday December 25, 2016 @06:23PM (#13255975)
Not a full course (apologies in advance) but I have heard a lot of people get a good introduction from:

http://compilers.iecc.com/crenshaw/

It was written with Turbo Pascal in mind but many have read the text and transcribed the instructions to a language of their choosing. Should be at least a good introduction to compilers.

Re:Ask HN: Recommend an introductory course on compilers by rochak on Monday December 26, 2016 @02:38AM (#13257376)
No need for any apologies. I am looking for anything that can introduce me to the topic along with practical knowledge
Re:Ask HN: Recommend an introductory course on compilers by userbinator on Sunday December 25, 2016 @07:26PM (#13256213)
Re:Ask HN: Recommend an introductory course on compilers by dstein64 on Sunday December 25, 2016 @06:27PM (#13255999)
Here's an HN comment from last week that included links to a compilers course (a course from HN user jpolitz, who posted the comment).

https://news.ycombinator.com/item?id=13207695

Here are the links:

https://www.cs.swarthmore.edu/~jpolitz/cs75/s16/index.html

https://github.com/compilers-course-materials/

https://github.com/compilers-course-materials/cs75-s16-lectu...

Re:Ask HN: Recommend an introductory course on compilers by Joe8Bit on Sunday December 25, 2016 @06:31PM (#13256019)
James Kyle (who created Babel) wrote a 'Super Tiny Compiler' that's a really great (low barrier to entry) place to start.

The inline docs are super well written, clear and extensive. It's also implemented in JabaScript.

It's an amazing learning tool and I really loved reading it!

https://github.com/thejameskyle/the-super-tiny-compiler

Re:Ask HN: Recommend an introductory course on compilers by farax91 on Sunday December 25, 2016 @09:42PM (#13256630)
I thought it was that young aussie guy, Sabastian that created babel? It was initially named 6to5 to my best memory, and later renamed Babel.
Re:Ask HN: Recommend an introductory course on compilers by ENTP on Monday December 26, 2016 @03:24AM (#13257488)
You are correct.
Re:Ask HN: Recommend an introductory course on compilers by wkandek on Sunday December 25, 2016 @07:15PM (#13256174)
I enjoyed this book by Niklaus Wirth - father of Pascal, Modula-2 and Oberon. https://www.amazon.com/Compiler-Construction-International-C...
Re:Ask HN: Recommend an introductory course on compilers by nils-m-holm on Monday December 26, 2016 @04:00AM (#13257559)
http://t3x.org/reload/

A tour through a clean subset of a C compiler, full C source code included. It's not exactly a course, but will introduce all basic parts of compiler construction on the theoretical and practical level: lexing, parsing, code generation, optimization, and runtime support. The complete code from the book is in the public domain: http://t3x.org/subc

For the record: I'm the author.

Re:Ask HN: Recommend an introductory course on compilers by tzs on Sunday December 25, 2016 @08:11PM (#13256345)
Allen Holub's book "Compiler Design in C" is excellent. The book is out of print, but you can get it as a free PDF from Holub's site: http://www.holub.com/software/compiler.design.in.c.html

Over the course of the book you implement compiler construction tools (a LEX clone and two YACC clones) and then use those to build a C compiler.

Re:Ask HN: Recommend an introductory course on compilers by e12e on Sunday December 25, 2016 @07:52PM (#13256299)
Great question. In addition to all the "serious" answers here, I'd recommend the nice "How I start" article for nim:

https://howistart.org/posts/nim/1

As well as playing a bit with ometa:

http://www.tinlizzie.org/ometa-js/#Sample_Project

Re:Ask HN: Recommend an introductory course on compilers by demosthenes111 on Sunday December 25, 2016 @06:36PM (#13256030)
MIT has a course called 6.035 which might be of use. Unfortunately the ocw page doesn't have lecture videos, but there seem to be some on YouTube if you search for it and the notes on ocw could help. Good luck!

https://ocw.mit.edu/courses/electrical-engineering-and-compu...

Edit: here's some videos https://ocw.mit.edu/courses/electrical-engineering-and-compu...

Also maybe check out the recommended text: Modern Compiler Implementation in Java (Tiger Book)

And a few more resources here: http://cons.mit.edu/sp14/references.html

Re:Ask HN: Recommend an introductory course on compilers by checker659 on Sunday December 25, 2016 @08:52PM (#13256461)
You should split your study into three parts.

1) Theory of computation (can't recommend a book for this one)

2) Programming language theory (Book: Programming Language Pragmatics)

3) Compiler construction (Book: Engineering a compiler or the Dragon Book)

Re:Ask HN: Recommend an introductory course on compilers by brudgers on Sunday December 25, 2016 @09:48PM (#13256655)
1) The classic is Introduction to Automata Theory, Languages, and Computation by Hopcroft and Ullman.

Ullman used to have a course on Automata via Coursera but the platform changes have sent it down the memory hole.

Re:Ask HN: Recommend an introductory course on compilers by tymm on Sunday December 25, 2016 @06:52PM (#13256081)
I recently began with https://lagunita.stanford.edu/courses/Engineering/Compilers/...

Until now I think it is good (I'm in the second week of the course).

Re:Ask HN: Recommend an introductory course on compilers by sn9 on Monday December 26, 2016 @12:05AM (#13257019)
The Coursera course can be found on Stanford's site: https://lagunita.stanford.edu/courses/Engineering/Compilers/...

It's self-paced now.

Re:Ask HN: Recommend an introductory course on compilers by krat0sprakhar on Sunday December 25, 2016 @08:30PM (#13256408)
Here's a list of courses that should help - https://github.com/prakhar1989/awesome-courses#programming-l...
Re:Ask HN: Recommend an introductory course on compilers by yogeshp on Tuesday December 27, 2016 @12:33AM (#13261474)
There are few courses on compilers listed in this list: https://github.com/Developer-Y/cs-video-courses
Re:Ask HN: Recommend an introductory course on compilers by jedmeyers on Sunday December 25, 2016 @06:25PM (#13255989)
Very good question. I am interested in reading the suggestions as well. Also, a specific book question: is Engineering a Compiler by Cooper & Torczon any good?
Re:Ask HN: Recommend an introductory course on compilers by cvoss on Sunday December 25, 2016 @06:54PM (#13256091)
The compiler course I took was taught by Keith and Linda. Keith is certainly one of the best educators in the department, and, in my opinion, their book is also of high pedagogical value.

For me, its shining moments are the explanations of abstruse algorithms. The text takes the time to work through interesting example runs of the algorithms that illustrate all the facets of the computation. This was critical to my understanding of how the algorithms work, why they need to work that way, and how competing algorithms differ.

It's also not the kind of book that needs to be read cover to cover. We went through the chapters out of order. If you can find matching lecture slides, that can be a great guide or survey of the material.

Re:Ask HN: Recommend an introductory course on compilers by fusiongyro on Monday December 26, 2016 @12:54AM (#13257169)
This was the official text when I took the class in 2004 with one of their disciples (Dr. Liebrock) at New Mexico Tech. But the exercises were actually taken from the book Modern Compiler Design by Andrew Appel. Officially, the C version of the book.

I got almost nothing out of the book Engineering a Compiler.

Aside from that the class was amazing. Maybe the next edition has become excellent? I knew people who took the class using the Dragon book and found that book unhelpful too.

I'm currently reading Wirth's book and really enjoying it though.