News for hackers. Stuff that matters.
Re:Compiler Construction: The Art of Niklaus Wirth (2000) [pdf] by vidarh on Sunday March 18, 2018 @09:39AM (#16611872)
>> Generate good code from the beginning; don't generate bad code and optimize later

> Unfortunately this is something that no compiler I know of does,

You're probably right compared to modern compilers. What you need to compare to are the compilers of the era, which were truly abysmal.

It's not that the Wirth compilers generated fantastic code (e.g. at least one of Wirths students explored adding much more aggressive optimization to his Oberon compiler), but they generated code that was a great deal better than a lot of non-Wirth style compilers at the time.

Some compilers of the time even depended on peephole optimizer passes because the code they generated was so bad that even simple 2-3 instruction peephole passes were enough to drastically improve the code. There was little reason for this. E.g. most of the time it was a matter of as basic stuff as passing on information about the registers to use rather than the dumb/naive approach of generating everything using scratch registers that you move things to/from.

I remember back in my asm days that I once had the C source for a GUI component I wanted to use, but the code the C compiler I had available generated was so awful that in exasperation I compiled it, disassembled it, and proceeded to manually clean it up. I deleted about half the instructions of about several thousand lines of compiler output, with very minimal fixups.

Re:Compiler Construction: The Art of Niklaus Wirth (2000) [pdf] by lboasso on Sunday March 18, 2018 @10:36PM (#16615858)
Wirth's compilers generated reasonably good code: 80% of the performance of optimizing compilers with 20% of the effort.

The first Java client jit compiler, was developed by Robert Griesemer (former PhD student of Wirth). The design of the compiler is described in the paper "A compiler for the java hotspot virtual machine", published in the same book: "The School of Niklaus Wirth: The Art of Simplicity".

Re:Compiler Construction: The Art of Niklaus Wirth (2000) [pdf] by sitkack on Sunday March 18, 2018 @09:02PM (#16615478)
I did something similar, I was a novice C programmer, and had a problem that could have used some `rot` instructions that weren't available, so I used the emit asm flag to generate stubs and wrote the function in asm, it would have taken me ages to do it from scratch, but fixing up the output of the C compiler took about an hour of experimentation.