News for hackers. Stuff that matters.
Re:Compiling to Java as a target language by sedachv on Thursday April 14, 2011 @11:10AM (#2447108)
People think real compilers are complicated, but often writing a native code compiler is simpler than writing an interpreter or translator. Abdulaziz Ghuloum has a great paper called An Incremental Approach to Compiler Construction (http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf), which shows how to build a Scheme native code x86 compiler in 10 pages. JVM bytecode isn't that far away from machine code.

Another great example of how straightforward compilers can be is the Tiny C Compiler (http://bellard.org/tcc/).

Re:Compiling to Java as a target language by bad_user on Thursday April 14, 2011 @05:35PM (#2448561)

    JVM bytecode isn't that far away from machine code.
It is far away in the case the type system is a complete mismatch, like Haskell. Or in the case of Scheme, if you want to have continuations without a huge performance penalty, you've got to put some effort into it.

For these instances I've see advices on Lambda-the-Ultimate to just go for native-code, as it is easier to experiment since you have a lot more freedom.

That said, building on top of the JVM can have advantages other than being easy to write the compiler.

Re:Compiling to Java as a target language by spacemanaki on Thursday April 14, 2011 @09:51PM (#2449193)
I tried to read through An Incremental Approach but found that it was really too brief. I had questions that I wanted answered but he was briskly moving on to compiling the next Scheme form. I found the first chapter of a longer version from his site, but this seems incomplete. Does anyone know what happened to that? Did it not turn into a book?