Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

Writing a compiler is another one of those things that is a lot easier than people assume it is. Far easier.


sort by: page size:

It's not that hard if you have experience in writing compilers.

Some things are irreducibly difficult. Writing a compiler isn't one of them.

Writing compilers is actually rather easy. The hard part is dealing with other programs. For example, last week I finally tracked a bug down to the documentation on how the function ABI worked was simply wrong.

Compiler writing isn't the easiest thing in the world by any stretch, but it's something that we manage to achieve all the time, unlike the mythical "program to do my programming" we are so quick to imagine.

A compiler for what? Some languages are easier than others.

Compilers are not that hard and this isn't that much of a niche role. Even C++ compilers.

Writing compilers definitely is.

It's easy to write a compiler.

I understand that writing a good compiler is somewhat more difficult.


I just finished writing a compiler for a CS class. I was surprised at how logical it ended up being. For me, it really took away a lot of the mystic nature surrounding compilers.

Writing a compiler for a small language with minimal optimization features and an easy to understand assembly/bytecode format is actually relatively straightforward.


It's simpler for a compiler at least

Or it might be as easy as writing a compiler. These things are hard to prejudge.

But a lot of programmers think compilers are magic. Maybe because they read about stuff like parser generators, register allocators, optimizations, etc., that are not strictly necessary. It's empowering to remind people that a seemingly hard task is within their reach.

Writing a compiler is easy. Optimizing one, not so much, but setting "writing a compiler" as some kind of difficult thing that requires arcane magic irritates me.

Slightly paraphrased quote that I read somewhere: writing a compiler is easy. Writing a compiler with good error messages is the hard part.

I agree with you. In fact I would say understanding compilers is really pretty easy. They are some of the most well researched and documented subjects (in CS) out there. Almost all compilers are going to follow a similar structure of lex -> parse -> pass0 -> passN -> generation.

The challenge these days seems to be in the passes which can become numerous and complex.


Very true. Writing a compiler that works on correct code is often trivial. It’s not much harder than a minimal lisp or forth.

However, figuring out errors, adding type checking, etc now that’s hard.


Compilers are hard.

The implication here being that writing an interpreter is easier? I've found it easier to write a compiler.

Compiler writing is easy? No. (I've built compilers for large subsets of C and Java, as well as my own languages)

Lord help you if you try to write a perfectly conforming compiler for C++ (has it ever been done?), and the U.S. legal system is at least an order of magnitude more complex than that.

next

Legal | privacy