Live data from Hacker News

I told my 2nd year CS students to create a programming language

dovyski.com

41–50 of 67 posts

Re: I told my 2nd year CS students to create a programming language

#41
post #26

Earlier quoted context omitted.

That's jaw-dropping really... every student should have to experience the horrors of the dragon book. *edit: I say that firmly tongue in cheek. The Dragon book is one of the most important pieces of CS literature ever written. It's a fine book, the subject matter is just difficult:)

Agreed. I'm taking a class right now with the dragon book (taught by Aho, actually - one of the authors of the book), and it's easily the best and most important CS class I've taken[1]. The main project for the class is to design a language and write a working compiler/interpreter for it - in all the years he's taught the class, apparently no group has failed to do this. The really tricky part is making a language th…

I interviewed Professor Aho a few years back; I'm a little jealous I was never fortunate enough to take that class. It's likely to be one of the most practical classes in all of computer science anywhere.

(I won't give away the punchline for the class. I don't know how far along you are on the project.)

Re: I told my 2nd year CS students to create a programming language

#42
post #10
post #4

Earlier quoted context omitted.

Which school do you go to? Compilers seems like a pretty standard CS course at most schools.

How the PLsy courses are split varies a lot. Where I went (Harvey Mudd), compilers was optional and not taken by most students, but there were two required Programming Languages courses, which involved parsing, ASTs, interpreters, tree transformations, and some other things you might otherwise find in a compilers course, but with less of a low-level flavor (no code-gen) and more of a PLs flavor.

The content of such a course also varies by university. I recently came across some university that did offer a compiler course, but it was all theory. Being a geek, I didn't really like that.

Re: I told my 2nd year CS students to create a programming language

#43
post #23

So, from what I understand, they have the flexibility to choose their own syntax. If they're interested in doing the least amount of work possible, they could either implement a Lisp-like language or Forth. (Smalltalk is pretty teeny as well. A basic Smalltalk-y language would weigh in at 1/6th the size of Python's grammar.)

One pair of students decided to create a stack-based language. I guess they noticed it would save several lines of code and make the interpretation process easier to do.

The second thing I did after finding out about FORTH (after boggling for a bit and trying to figure out how the heck it worked without function arguments) was to go and design a stack-based language and implement an interactive interpreter for it in JavaScript. Largely just because I realized FORTH is so simple, I actually could do it.

Then my language design aspirations languished for about 10 years until I had a Discrete Mathematics class based around writing a parser and interpreter for Datalog (subset of Prolog).

Then there was the programming language design class where we implemented interpreters for various language features in Racket, but by then I forgot most of how to write parsers and (read) takes care of most of the hard part there. It certainly would've been more fun if we'd had to design our languages, rather than just implementing predefined ones.

And several computer architecture & an operating systems class that dealt with "this is what C code gets turned into", but no details on the actual process of doing the translation.

So, I guess this kind of thing has been fairly well represented in my formal education, but not very well integrated. Just disjointed bits and pieces as they're relevant for some other subject. It'd definitely be nice if they were more coherent earlier on, before tackling Compilers head on.

Re: I told my 2nd year CS students to create a programming language

#44
post #26

Earlier quoted context omitted.

That's jaw-dropping really... every student should have to experience the horrors of the dragon book. *edit: I say that firmly tongue in cheek. The Dragon book is one of the most important pieces of CS literature ever written. It's a fine book, the subject matter is just difficult:)

Agreed. I'm taking a class right now with the dragon book (taught by Aho, actually - one of the authors of the book), and it's easily the best and most important CS class I've taken[1]. The main project for the class is to design a language and write a working compiler/interpreter for it - in all the years he's taught the class, apparently no group has failed to do this. The really tricky part is making a language th…

My compilers class was a nightmare (and we used the Dragon book). I had hoped a compilers course would actually teach about the full process by which a text file becomes executable 1s and 0s. Instead it was a months-long torture of parsing text. Regex to NFA, NFA to regex, regex to DFA, NFA to DFA, DFA minimization, LL(1), LR(0), SLR(1), LR(1), LALR(1), along with memorizing all the rules governing which grammars are amenable to which parser, and working through all of the preceding by hand. And then finally about a week of teach-yourself-LLVM.

I don't know if "compilers are a solved problem", but I'm pretty damned sure that the only people who need to know that much about text parsing know who they are, and would be able to reference it when needed. As an undergraduate course, it was utterly worthless.

Re: I told my 2nd year CS students to create a programming language

#45
post #34
post #31

Earlier quoted context omitted.

I see you have other students use the language at the end. If you have a chance, it might be a rare opportunity to point out some of the innovative ideas, after all the projects are done.

Yeah, it's true. I will try to analyze and discuss the implementations at the end.

Could you keep us updated about that? Such a round-up post with interesting ideas could be marvelous!

Re: I told my 2nd year CS students to create a programming language

#46
Cool! I had a (mandatory) course on compiler construction in my second year of CS as well. It was one of the toughest subjects, but it also made me understand and appreciate programming languages so much better. Like everyone, we tried to create a language without the annoyances found in many modern languages. Like everyone, we found that those annoyances are actually really hard to avoid. It was tons of fun :)

Re: I told my 2nd year CS students to create a programming language

#47
We did this for our Compilers module during my second year CS degree at Nottingham university. It's a very interesting subject and I thought it gave a very good grounding in understanding new languages. Unfortunately we had to write our compiler in Java, we had the option of using Haskell but I didn't really learn get to grips with functional programming until the third year.

Re: I told my 2nd year CS students to create a programming language

#48
post #26

I wish I had a professor like you. When I asked why there was no compiler class, the answer I was given was: "compilers are a solved problem; there's no point in teaching them anymore." Maybe it's just my school though.

That's jaw-dropping really... every student should have to experience the horrors of the dragon book. *edit: I say that firmly tongue in cheek. The Dragon book is one of the most important pieces of CS literature ever written. It's a fine book, the subject matter is just difficult:)

The Dragon book may be a fine book but it is mainly a book on parsing, not on compilers. You first learn about control flow graphs in chapter 9! Most courses probably won't even get that far. The parts that are about compilation are very old fashioned, essentially a book about "how to compile Fortran to inefficient code like they did in the '60ies".

It would be great if there was a book on modern compiler techniques, including SSA, abstract interpretation, compiling high level languages, pointer analysis, compiling dynamic dispatch, garbage collection and closures, etc. Probably the closest are Appel's compiler books.

Re: I told my 2nd year CS students to create a programming language

#49
post #48
post #26

Earlier quoted context omitted.

That's jaw-dropping really... every student should have to experience the horrors of the dragon book. *edit: I say that firmly tongue in cheek. The Dragon book is one of the most important pieces of CS literature ever written. It's a fine book, the subject matter is just difficult:)

The Dragon book may be a fine book but it is mainly a book on parsing, not on compilers. You first learn about control flow graphs in chapter 9! Most courses probably won't even get that far. The parts that are about compilation are very old fashioned, essentially a book about "how to compile Fortran to inefficient code like they did in the '60ies". It would be great if there was a book on modern compiler techniques,…

Some bigger schools now teach with their own set of materials that the professors put together. I think it might be precisely because of this reason.
Post reply on HN