Live data from Hacker News

Resources for Amateur Compiler Writers

c9x.me

11–20 of 75 posts

Re: Resources for Amateur Compiler Writers

#11
post #5

Earlier quoted context omitted.

The target language shouldn't make much of a difference, should it?

It makes a huge difference. If you are compiling for x86 you have to think about register allocation. If you are compiling for JVM or an HLL, you don't. A good chunk of what is discussed in that article just is not relevant anymore.

Furthermore, the semantics of a language should be tailored for its target. Some execution pattern works well on the JVM, some don't. Same for javascript and other targets.

Inventing whatever semantics you have in mind without considering how it's going to be compiled is a recipe for slow languages.

Re: Resources for Amateur Compiler Writers

#12

I recommend http://createyourproglang.com/ too if you want something very simple and you don't know where to start.

Unfortunately that page seems to make a lot of big claims (and unnecessarily insult a lot of established work in the field) but seems to include literally no useful information about the book at all: no table of contents, no indication of who the target audience is or what prior experience is assumed, not even a summary of the topics it covers.

Re: Resources for Amateur Compiler Writers

#13
nice collection - i keep some notes myself here, and was able to generate my own parser with Jison https://github.com/mulderp/mulderp.github.com/issues/13

Once the parser returns the AST, it is getting more complicated, how to decorate an AST, add actions, etc. still looking to learn more about compiler backends

Re: Resources for Amateur Compiler Writers

#14
post #9
post #6

Earlier quoted context omitted.

"frankly in 2016 I am afraid the average undergrad compiler course is part of the problem as much as the solution." What do you mean by that?

I'm not the OP, but I sympathize. The specific details covered in a "classical" compilers course are heavy weight and not super-relevant right now. These days you don't have to understand LR parsing or touch a parser-generator, you don't have to worry about register coloring... etc. Courses still use the Dragon Book which is older than I am and covers a bunch of stuff only relevant to writing compilers for C on resou…

In 2006 a second edition of the dragon book was released: https://www.amazon.com/Compilers-Principles-Techniques-Tools...

Re: Resources for Amateur Compiler Writers

#15
post #10
post #9

Earlier quoted context omitted.

I'm not the OP, but I sympathize. The specific details covered in a "classical" compilers course are heavy weight and not super-relevant right now. These days you don't have to understand LR parsing or touch a parser-generator, you don't have to worry about register coloring... etc. Courses still use the Dragon Book which is older than I am and covers a bunch of stuff only relevant to writing compilers for C on resou…

So, the TAPL ? :) https://www.cis.upenn.edu/~bcpierce/tapl/

That's better than average if you are getting that as an undergrad!

Re: Resources for Amateur Compiler Writers

#16
post #5

Is amateur the right word? I am in it for the money which I guess makes me a pro but I don't have a computer science background and frankly in 2016 I am afraid the average undergrad compiler course is part of the problem as much as the solution. Another big issue is nontraditional compilers of many kinds such as js accelerators and things that compile to JavaScript, domain specific languages, data flow systems, etc.…

The target language shouldn't make much of a difference, should it?

There are 3 languages you have to understand to write a compiler:

* The language you are using to write the compiler. You have to know it well enough to write a complex application.

* The language you are compiling. You have to completely understand it.

* The language you are compiling to: x86, JVM, etc. You have to understand it well enough to write every complex application.

Re: Resources for Amateur Compiler Writers

#17
Compiler construction is a big field, so it's easy to get lost in the details.

If you are mostly interested in principles rather than the most recent tooling, there's a course by Wirth that makes it tractable.

More here: http://short-sharp.blogspot.ca/2014/08/building-compiler-bri...

Re: Resources for Amateur Compiler Writers

#18
post #5

Earlier quoted context omitted.

The target language shouldn't make much of a difference, should it?

It makes a huge difference. If you are compiling for x86 you have to think about register allocation. If you are compiling for JVM or an HLL, you don't. A good chunk of what is discussed in that article just is not relevant anymore.

Isolated anecdote, but I work on a JVM based language and my colleague is having to write a register allocator because our input language is written in SSA form and so has a huge number of locals in methods. We need to map these onto a smaller number of JVM locals (like register) otherwise the JVM frames are huge.

Also, if you aren't writing a register allocator because you're using the JVM or LLVM, then someone else needs to on your behalf. We can't forget these skills.

Re: Resources for Amateur Compiler Writers

#20
post #19

I wrote a VM, I still can't get recursion to work. It's hard.

I never understood why recursion causes anyone any problems, because recursion is the absence of a special case limitation.

If I tell you that a function may call any function, then you already know everything you need to know for recursion. If we didn't have recursion, only then would I need to qualify what I just told you with the restriction that a function can only be active once.

When I show students recursion I can't understand their confusion. I think to myself 'but I already showed you functions can call any other function, why do you see this case differently?'

(Obviously I try to be more patient, understanding and anticipatory in person.)

Post reply on HN