3 ms·
Not much time... Pascal (and most of Niklaus Wirth's languages) was designed to be easy to compile. The grammars are very small (typically less than a page of
by vidarh 13y ago
Not much time...
Pascal (and most of Niklaus Wirth's languages) was designed to be easy to compile. The grammars are very small (typically less than a page of text; Turbo Pascal used to include the full BNF grammer in the manual), and his languages are designed to be possible to compile in one pass.
Also "traditional" Wirth-style compilers usually output code directly rather than build an abstract syntax tree and a lot of compilers of the era were heavily influenced by his compiler textbook, which included the full source of a compiler.. They also tend to output object files or final executables directly rather than go via an assembler.
All of that combine to make it very easy to make the compilers very small, and very fast even on very slow machines. For an example of simplicty, take a look at the source code to an educational Oberon-0 (subset of his Oberon language) compiler, from one of his books: http://www.inf.ethz.ch/personal/wirth/books/CompilerConstruction/ http://www.inf.ethz.ch/personal/wirth/books/CompilerConstruc... (it generates code for a virtual RISC machine, and one of the files includes an interpreter for the generated code)
The whole book is available as a PDF here: http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf ; Wirth's material on compiler contruction evolved over the years from an early book about writing a PL/0 compiler, through Pascal and Modula (2) and finally Oberon, but always focusing on simplicity.
For a time I wanted to go to ETH Zurich to study computer science there because of Wirth. I'm a bit of a Wirth fanboy (which is ironic, since my favourite language these days is Ruby - a language that is pretty much the anti-thesis of Wirth's focus on simplicity of implementation).
As as a final digression, lets play six (well, 3) degrees of Pascal to Javascript: One of Wirth's PhD students was Michael Franz who got his PhD with a one of my favourite dissertations, on dynamic architecture independent code generation for Oberon. Dr Michael Franz co-invented the trace-trees technique that went into Mozilla's TraceMonkey version of their javascript JIT with Andreas Gal. Andreas Gal now works at Mozilla with Brendan Eich, the creator of Javascript.
- lkesteloot 13y agoExactly right. Turbo Pascal compiled straight to machine language, which made it hard for them to do nice optimizations. But people like me didn't care. IBM's compiler couldn't blow off optimizations, though. Typical worse-is-better. This compiler started out as a five-pass compiler, then I reduced it to two. I could have reduced it to one and simplified the code quite a bit, but having the intermediate parse tree made debugging easier. The parse and compile passes together take less than 20ms on the largest Pascal program I have (rose.pas).
- pjmlp 13y agoOne of the Go guys, Robert Griesemer, studied at ETHZ, http://www.ethoberon.ethz.ch/hall.html http://www.ethoberon.ethz.ch/hall.html He is most likely the reason why Go methods share Oberon-2's method declarations.
- vidarh 13y agoIt's a small world. Griesemer finished his PhD the year before Franz - I remember seeing his thesis and some of his papers, but I don't think I read his thesis in full. I spent a lot of time going through stuff on ETHZ website and FTP servers back then; there were a ton of interesting papers coming out of there at the time. The current stuff on active object etc. doesn't resonate with me as much as the stuff they did in the early 90's though. I keep meaning to go back and read more of their research output - it's amazing just how small and simple a lot of their systems were.
- pjmlp 13y agoAfter being a Native Oberon user, I become convinced that doing OS in GC enabled systems programming languages is quite possible. I keep looking forward to the day it becomes mainstream. Sadly only people like us, that experimented with ETHZ's work seem to share such enlightenment.