Hacker News new | past | comments | ask | show | jobs | submit login

It was only shocking to people used to complicated behemoths of multi-pass compilers or complicated optimizing compilers with expensive internal representations.

Turbo Pascal really mostly "only" does things the way Wirth used to: As simple as possible. Wirth's languages are all designed for single pass compilation with direct code generation, and if you write your compilers that way, they will be fast. It is very, very hard not to make them fast that way.

His compiler textsbooks, all the way back to "Compilerbay" in 1977 (using PL/0 as the language) included full source code for compilers following that style, and they're so small the entire compilers fit in a few handful pages.

(EDIT: just to make clear: I do admire Turbo Pascal - I used it quite a lot, but main the genius of Turbo Pascal was to pick the Wirth way of doing compilers and integrate it with a simple "IDE" - a large part of the amazing impression of Turbo Pascal was that you did not have to write your code to disk, exit the editor, run a compiler etc. but could do it all in one)




I remember that differently: on Z80 CPU machines, UCSD Pascal was slow. It compiled to the p-code (it was both an "operating system and compiler" and they wanted it portable). On the first PC's (8088 CPU), Microsoft's Pascal was slow. It produced obj files. Turbo Pascal was lightning fast on both. It had to be implemented contrary to beliefs common then: it was itself written in asm, it was never just a compiler but the editor and compiler at once, kept everything in memory if it could, produced the pure native code processor specific and never produced obj files.


UCSD Pascal was slow because the compiler was written in Pascal and compiled to p-code itself (the source is available: http://techtransfer.universityofcalifornia.edu/NCD/19327.htm... ).

It was not a good benchmark. It was prevalent because it was trivial to port, not because it was good.

(Note that UCSD Pascal was based on a part of Wirths research groups "porting kit" - their intent was not for p-code to be used for production systems, but as an easy way of getting a Pascal compiler running on a new platform to be able to then use the target platform while retargeting the code generator)

> It had to be implemented contrary to beliefs common then: it was itself written in asm,

That was nothing out of the ordinary at the time, though not something Wirth himself did, as a large part of his mission was to teach the development of compilers.

But compilers for small systems were often written in asm at the time. It'd not be very viable to write compilers in high level languages for a C64 or other home computers, for example, yet there were plenty of compilers for small systems. When I wrote my first compilers on the C64 and a bit later on the Amiga, it never even occurred to me to write them in a high level language until a few years later (incidentally when I got HiSoft Pascal - an integrated Pascal environment for the Amiga very much in the spirit of Turbo Pascal)

> it was never just a compiler but the editor and compiler at once, kept everything in memory if it could, produced the pure native code processor specific and never produced obj files.

That's technically true, though the compiler that became Turbo Pascal was actually originally a separate, stand alone compiler.

Combining the compiler with the editor was fairly uncommon and certainly innovative. When Kahn at Borland decided he wanted an environment like that, though, he went out and bought an existing, standalone, commercial compiler, from Anders Hejlsberg, and brought him to Borland.

Producing pure native code on the other hand was not unusual - UCSD's p-System was an aberration in that respect, and it's greatest lasting legacy was in inspiring VM based systems; e.g. Bill Joy has cited it as one of the inspirations behind the JVM. Not producing object files was also quite common - for many small systems there was no tradition of object files at all, as they were too small for separate compilation to make much sense.


You remember correctly (at least your memories jive with mine). UCSD Pascal was, at best, 'functional'.


I need to stop writing late at night. That textbook is "Compilerbau" ("Compiler Construction").




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: