
CS143: Compilers (2011) - rspivak
http://www.keithschwarz.com/cs143/WWW/sum2011/
======
RcouF1uZ4gsC
Also, take a look at
[http://www.keithschwarz.com/interesting/](http://www.keithschwarz.com/interesting/)

It is an amazing archive of all kinds of neat algorithms and data structures.

~~~
gravypod
I'm pleasantly surprised. For academic work, this code is amazingly clean.

------
ratsbane
I took that class on the Stanford campus in the Summer of 2011. Keith was one
of the most engaging instructors I've ever had. His enthusiasm and knowledge
were boundless.

The course was video-recorded and I downloaded and saved most of the lectures
(and I gave Keith a DVD with a copy of them.) I still have them, but I don't
know if it's okay to put them on YouTube or not.

~~~
cplease
Of course it is not okay unless you have permission.

------
ttandon
Currently taking CS 103 (Mathematical Foundations of Computing) under Keith at
Stanford. Truly one of the best taught classes I've ever taken - the man has a
love for teaching Computer Science that really makes all the difference.

------
khushia
Out of curiosity - the Mid-term exam paper says:

 _This midterm exam is open-book, open-note, open-computer, but closed-
network. This means that if you want to have your laptop with you when you
take the exam, that 's perfectly fine, but you must not use a network
connection. You should only use your computer to look at notes you've
downloaded from online in advance. If you are an SCPD student, you should take
this exam in any two-hour period between 11:00 AM Pacific time, July 20 and
11:00 AM Pacific time, July 21 . If you have any questions, please feel free
to call me at _ any time in this window except between midnight and 8AM on
July 21, Pacific time. You may submit the exam either by faxing it to _ or by
scanning and emailing it_

I'm not familiar with how these things work in the US - are the students
trusted to take the exam away and not use the internet to get help?

~~~
simscitizen
At Stanford, faculty are prohibited from proctoring. So there is no professor
or grad student that sits in the exam hall with the students while they are
taking the test:

"The faculty on its part manifests its confidence in the honor of its students
by refraining from proctoring examinations and from taking unusual and
unreasonable precautions to prevent the forms of dishonesty mentioned above."

[https://communitystandards.stanford.edu/student-conduct-
proc...](https://communitystandards.stanford.edu/student-conduct-
process/honor-code-and-fundamental-standard#honor-code)

A professor or grad student walks into the room every 30 minutes or so just to
make sure everything looks okay. They otherwise sit outside the exam hall so
you can ask them questions, ask to go the bathroom, etc. But it's up to the
students to police each other and ultimately themselves.

There are definitely other universities in the US that have this policy, but I
would say it's more the exception than the norm.

~~~
khushia
That's really interesting. I did a CS degree in the UK and all exams were
strictly supervised and we were never allowed computers.

The exception to this was programming exams for which the department would
boot all the lab workstations into a locked-down mode with no internet & new
homedir containing only the exam files. At the end of the exam everything got
collected and marked by an automated test suite.

They went to quite some effort to ensure that no cheating could take place -
[http://pubs.doc.ic.ac.uk/Lexis/Lexis.pdf](http://pubs.doc.ic.ac.uk/Lexis/Lexis.pdf)

------
melling
I've got a small collection of compiler resources on Github:

[https://github.com/melling/ComputerLanguages/blob/master/com...](https://github.com/melling/ComputerLanguages/blob/master/compilers.org)

I'll add more as they are posted.

------
sewercake
I'm taking my university's offering of this course in my final semester. It's
fantastic. I'm using all of the seperate skills I've developed over the last
four years: Mathematical thinking (via parsing), algorithms and data
structures (ASTS),Programming Languages, software design. It's also the first
course where big design decisions are non-trivial, and really effect things
later down the pipeline, an experience that is rare in school, but, from what
I can tell, ubiquitous in the field. I really recommend it to any students out
there.

------
mataug
I'm going to be taking a Compilers course next quarter and I was speaking to
the prof who told me that she doesn't plan on using the Dragon book, instead
she plans to use the Louden book which seems a lot more approachable in a
single quarter.

I was lucky enough to buy a used copy on amazon for $8.

[http://www.amazon.com/Compiler-Construction-Principles-
Kenne...](http://www.amazon.com/Compiler-Construction-Principles-Kenneth-
Louden/dp/0534939724)

~~~
pjmlp
Also take Niklaus Wirth PDF and follow how to write an Oberon-0 compiler end-
to-end.

[http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf](http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf)

It is a very instructive process.

~~~
alex_muscar
This is a really neat book. The fact that it builds a complete compiler and
virtual machine in ~100 pages is really amazing.

------
jor-el
I remember while learning data structures and implementing them, I landed on
[http://www.keithschwarz.com/interesting/](http://www.keithschwarz.com/interesting/).
It was enlightenment for me. By browsing through these examples I learned
about good programming practices. Most importantly how commenting your code
can help you even when you return after few years to fix something in it.

------
doomrobo
Took an algorithms course with Keith a few years ago. Really patient engaging
lecturer!

------
yyin
.

~~~
matthewarkin
There's self-reported data that some Stanford students have scrapped from
CourseRank before it got shutdown.
[http://www.stanfordrank.com/cs143](http://www.stanfordrank.com/cs143)

------
sklogic
And again, 90% about the parsing, and a couple of words about "code
optimisation". That pitiful so called "Dragon Book" really keeps taking its
toll of souls.

I'm terribly sorry to break the news for you, but no, compilers are not about
parsing. Nowhere near that.

~~~
theGimp
You have to start somewhere. Code optimization is utterly useless if you can't
parse code.

~~~
nickpsecurity
So write up a grammar, feed it to a parser generator like GOLD, run result
through a premade parser engine, and BOOM your done. Then, you can start on
the stuff in the middle that really needs more people working on it.

~~~
jstimpfle
The problem is that writing a good grammar requires understanding of parsers.

(Also, real parsers tend to be hand-written, judging from open source language
implementations (some have actually migrated from generated parsers to
recursive descent in the past). There must be a reason).

~~~
sklogic
The historical reason was error recovery and error messages. It is a solved
problem now, you can have it all with generated PEG parsers.

~~~
jstimpfle
Alarm bells ring in my head whenever someone claims "it's a solved problem" in
the context of an engineering (as opposed to mathsy) problem. Unless the
context is really narrow (and the problem becomes basically a math problem)
that claim is usually wrong.

Thanks for pointing to PEGs. I will definitely try them out. But judging from
a quick web search, it's obvious that there are perfectly valid reasons not to
use a PEG grammar today -- unless someone already designed the grammar for you
(and it's PEG!). [http://lambda-the-
ultimate.org/node/3039#comment-44356](http://lambda-the-
ultimate.org/node/3039#comment-44356)
[http://stackoverflow.com/questions/1857022/limitations-of-
pe...](http://stackoverflow.com/questions/1857022/limitations-of-peg-grammar-
parser-generators)

Those of us who care about syntax (that is optimized for the user, not the
programmer), will have to keep thinking about parsers for the foreseeable
future.

~~~
sklogic
PEG is basically a thin abstraction over recursive descent parsing. Everything
you can do in a handwritten parser can be expressed mostly declaratively in
PEG.

And, no, there is no single reason not to use PEG. Especially when the choice
is between a handwritten parser and a PEG. There is a lot of stupid FUD about
PEGs, you should ignore it. Your links are pointing to the ignorant,
incompetent mumbling of those who never tried implementing a proper PEG.

And I never met a language for which writing a PEG parser was not totally
trivial. A pro tip: use PEG alongside with a Pratt for the binary expressions.

