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

The goal here is to write a compiler that can compile itself.


sort by: page size:

The *point* of a compiler is to compile itself.

Sometimes you need to write a compiler.

What kind of compiler are you writing? For which language and target?

I would love to see somebody writing a compiler that way.

I'm writing my first compiler now, and it's been quite a learning curve. I've also realized how much nicer my language is for writing compilers than the language in which I'm implementing the compiler. That made me realize I could write the compiler in my language and then write an interpreter for my language which would only need to run once--to generate the compiler--after which point my compiler would be self-hosting. :p

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.


Well, if it reaches a point where it can compile itself, you'll get your compiler written with just one instruction (assuming that's what you were hoping for).

What does it mean for something to be able to compile itself?

Sure, that makes sense, but you can write a compiler in languages that don't require it themselves. That's what I meant.

I'm looking at writing a compiler for my own language, and I can certainly use ideas for anything that's technically feasible.

Write an interpreter/compiler for your own little language. With your own garbage collector.

Working on a compiler? Do tell!

it's called a compiler :)

Yes but you’re not the one doing it, the compiler is.

That is called a compiler.

every program is a compiler

The obvious solution here is to write a compiler :)

You're writing a compiler! It won't be painless in any language.

Nah. What you usually want from a compiler is maintainability and correctness. There's also a grand tradition for dogfooding by writing the compiler for language X in language X. If you don't, then how do you know you're actually making progress?
next

Legal | privacy