Live data from Hacker News

Internals of a Turbo Pascal Compiler

turbopascal.org

11–20 of 106 posts

Re: Internals of a Turbo Pascal Compiler

#11
post #8
post #6

Earlier quoted context omitted.

Object Pascal was originally an Apple invention (with help from Wirth), and made some strides towards ISO standardisation. However it used a value-based OO model that made vtables optional until you added the first virtual method, permitted object slicing, had no common ancestor for all classes, had an odd syntax for calling constructors (using extra parameters to New), etc. Delphi introduced a new object model while…

Interestingly I just Googled Borland to see what they do these days: http://www.borland.com/Products Seems like they made quite a major pivot?

I used Borland C++ Builder and their version of it in the XP - Windows 7 days, when they released Codegear 7. As far as I knew many of the developers left after they renamed themselves Inprise ("integrating the enterprise" whatever that means), decided to produce odd products that targeted an entirely different audience and after they ditched all the development work on C++ Studio (I think that was what it was called).

I remember them introducing Kylix and the disappointment of it being based on Qt and Wine so slow on my old Linux box. The VCL stagnated too (horrible flicker on XP as I recall, to begin with so hacks to disable theming via the application manifest were needed) and the compiler let you do illegal things in C++ in Codegear's C++ Builder 7 (must dig out an example). The installer for C++ Builder 7 took FOREVER to run and also required you keep all of your setup files in your temp directory for later updates to work (???? insane eh!)

I remember them releasing a paid PHP editor etc. at the time when you could just grab Netbeans and use that for £0.00 - difficult to compete with that!

Re: Internals of a Turbo Pascal Compiler

#12
Turbo Pascal was my first contact with compiled languages in school, after starting off with Commodore Basic as a kid and graduating to Amos and some other Amiga stuff later. TP was my first contact with real PCs, too. After school I moved to Delphi, which was basically a thin wrapper around the Win32 API with Object Pascal syntax and the nicest IDE I had ever used (and probably will ever use).

Delphi really paid my bills as a newbie commercial programmer. That was around the time when the internet took off, and I wrote my first CGI servers in Pascal to make dynamic websites. The Pascal/Delphi language and environment were incredibly versatile and you could write some really fast code with it.

Fond memories. In many ways, TP leveled me up as a programmer.

Re: Internals of a Turbo Pascal Compiler

#13
post #4

This site doesn't describe the internals of Borland's Turbo Pascal compiler. It describes a compiler written in Turbo Pascal that can compile some subset of Turbo Pascal's language. Borland's Turbo Pascal compiler was written in 16-bit x86 assembly, mostly by Anders Hejlsberg. There is an explanation of this on the front page of the site, but it's not clear from the headline. (I used to work at Borland on the Delphi…

I have very fond memories of just how blazingly fast Turbo Pascal was at compiling on my Mac. It stunned me every time. I remember spending most of one summer writing a text adventure game with it, based in the Australian Gold Rush. It even had NPCs which was quite advanced for text adventures of the day (I think the only NPCs in adventure games that I had encountered up to that point were those in the Hobbit, and of course the bloody thief in Zork (although he wasn't really an NPC, but was implemented as a bunch of semi-random encounters)...

Good times. In particular, I remember having to implement my own strings, because for a text adventure you often want to have access to strings longer than 255 characters...

Sadly, I never managed to make the jump from writing console applications with TP to writing proper Mac GUI apps. But "Inside Macintosh" cost an absolute fortune at the time (for a 10 year-old kid at any rate), so I ended up scraping enough money together to buy another text book whose name escapes me. I must have read the first few chapters about a million times - they talked about handles and graphics ports etc, but I could never get any code from them to run in TP (I think they were assuming that you would be using MPW?).

Which brings me to the point of this long rambling message - did TP really support graphics programming on the Mac? I know my version of TP was an official bought copy, so we had the manual, but I don't remember ever seeing anything that explained GUI programming in there.

Re: Internals of a Turbo Pascal Compiler

#14
post #4

This site doesn't describe the internals of Borland's Turbo Pascal compiler. It describes a compiler written in Turbo Pascal that can compile some subset of Turbo Pascal's language. Borland's Turbo Pascal compiler was written in 16-bit x86 assembly, mostly by Anders Hejlsberg. There is an explanation of this on the front page of the site, but it's not clear from the headline. (I used to work at Borland on the Delphi…

Turbo Pascal was also available on CP/M (so 8080/Z80 8-bit). It was the most powerful language on Amstrad CPC 6128, the only 8-bit low cost computer to offer CP/M compatibility.

Re: Internals of a Turbo Pascal Compiler

#15
post #8
post #6

Earlier quoted context omitted.

Object Pascal was originally an Apple invention (with help from Wirth), and made some strides towards ISO standardisation. However it used a value-based OO model that made vtables optional until you added the first virtual method, permitted object slicing, had no common ancestor for all classes, had an odd syntax for calling constructors (using extra parameters to New), etc. Delphi introduced a new object model while…

Interestingly I just Googled Borland to see what they do these days: http://www.borland.com/Products Seems like they made quite a major pivot?

Yes, quite some time back they split the languages and compilers part out and the rump of Borland became an application lifecycle management company, or something like that.

The bit you're probably looking for is at http://www.embarcadero.com/ now. Some of the old people like David Intersimone are still there.

I worked with Delphi for a long time, through versions 3, 5 and 7 (the odd numbers were always better). When .NET came, the whole situation went crazy and never recovered. I can't remember the twists and turns now, but I think they released a .NET only RAD Studio which was awful, then they added the Win32 bits back but Delphi.NET was still awful. Then they dropped .NET and incorporated Remobjects Chrome/Oxygene as Delphi Prism, which was an Object Pascal inspired .NET language. Now they've split again, and Radstudio is all about Firemonkey, a cross-platform UI library. Remobjects are doing their own thing.

Re: Internals of a Turbo Pascal Compiler

#16
post #7

I loved Turbo Pascal. When I got to learn C, already had Turbo Pascal 3, 4, 5.5 and 6.0 on my toolbox. Compared with Turbo Pascal, the only thing C had going for it was being available in other systems. Everything else was meh. No memory safe handling, no bounds checking, no units (modules), no namespacing, no proper strings, no OOP support, arrays decaying into pointers, no type safe enumerations, no sets, no generi…

Pascal was off time. A lot of these traits are really worthy, but it wasn't attractive at the time .. was it as 'performant' as C too or was it a very nice environment to craft sound code productively whereas C code could allow you to tap into hardware more aggressively no matter how much headaches that would give you ?

Given the caveat that performance is always a question of how well the implementation performs inside the limits given by the language: Yes Turbo Pascal produced fast code. About as fast as Turbo C. Which was really quite fast. Also, the compilation process itself was very fast compared to other Pascal compilers.

About the question you didn't specifically ask: There's no reason (apart from optional stuff, like array bounds checking) that a Pascal compiler couldn't produce code of equivalent speed as a C compiler. (There is one language with a potential speed advantage over Pascal/C/equivalents and that's Fortran.)

Re: Internals of a Turbo Pascal Compiler

#17

> Anders Hejlsberg developed Blue Label Pascal... This compiler was later licensed by a software company Borland which added user interface and editor, changed the name to Turbo Pascal and offered it for a competitive price. Nooo... Another account of TP origins was that it was written by Philippe Kahn (the founder of Borland), back when he was just a one-man operation running from a small office on top of a Jaguar c…

http://blogs.embarcadero.com/davidi/2008/11/02/38933

Re: Internals of a Turbo Pascal Compiler

#18
post #4

This site doesn't describe the internals of Borland's Turbo Pascal compiler. It describes a compiler written in Turbo Pascal that can compile some subset of Turbo Pascal's language. Borland's Turbo Pascal compiler was written in 16-bit x86 assembly, mostly by Anders Hejlsberg. There is an explanation of this on the front page of the site, but it's not clear from the headline. (I used to work at Borland on the Delphi…

Turbo Pascal was also available on CP/M (so 8080/Z80 8-bit). It was the most powerful language on Amstrad CPC 6128, the only 8-bit low cost computer to offer CP/M compatibility.

> the only 8-bit low cost computer to offer CP/M compatibility.

The Commodore 128 also offered CP/M compatibility (through a second CPU...), though rarely used.

Re: Internals of a Turbo Pascal Compiler

#19
post #7

I loved Turbo Pascal. When I got to learn C, already had Turbo Pascal 3, 4, 5.5 and 6.0 on my toolbox. Compared with Turbo Pascal, the only thing C had going for it was being available in other systems. Everything else was meh. No memory safe handling, no bounds checking, no units (modules), no namespacing, no proper strings, no OOP support, arrays decaying into pointers, no type safe enumerations, no sets, no generi…

Pascal was off time. A lot of these traits are really worthy, but it wasn't attractive at the time .. was it as 'performant' as C too or was it a very nice environment to craft sound code productively whereas C code could allow you to tap into hardware more aggressively no matter how much headaches that would give you ?

Pascal and C compilers produced similar code quality back then.

Everyone praises C compiler quality nowadays. On those home computers, C, Pascal and Modula-2 were good enough for general purpose applications, if one wanted real speed, Assembly was the only way to go.

Turbo Pascal, as well as any other Pascal dialects, had the same capabilities to access hardware as C offered.

Also the MS-DOS game development scene and the demo scene tools were heavily based in Turbo Pascal, besides the usual Assembly stuff.

Re: Internals of a Turbo Pascal Compiler

#20
post #8
post #6

Earlier quoted context omitted.

Object Pascal was originally an Apple invention (with help from Wirth), and made some strides towards ISO standardisation. However it used a value-based OO model that made vtables optional until you added the first virtual method, permitted object slicing, had no common ancestor for all classes, had an odd syntax for calling constructors (using extra parameters to New), etc. Delphi introduced a new object model while…

Interestingly I just Googled Borland to see what they do these days: http://www.borland.com/Products Seems like they made quite a major pivot?

They've been rotating at high speed for the better part of the last two decades. Starting around the time of Philippe Khan's departure.
Post reply on HN