Live data from Hacker News

Turbo Pascal Turns 40

blog.marcocantu.com

191–200 of 271 posts

Re: Turbo Pascal Turns 40

#191

Turbo Pascal is what got me into programming. I remember spending hundreds of German marks on a license for Borland Pascal 7.0 and later Delphi 1.0 and 2.0. I ended up developing my first “commercial” software that I sold for money. In the DOS era, Turbo Pascal was probably the easiest way to get into programming, outside of Basic. And on Windows 3.1/95, Delphi was eye-opening how easy GUI programming could be. In ma…

Ah, the mark. It's been a while. Maybe this was just in Britain but the name of the mark was never translated into English when spoken or written, it was always just the Deustchmark.

Re: Turbo Pascal Turns 40

#192
post #10

When I was a kid, a kindly computer store owner (who also made me a great deal on an PC-semi-compatible running MS-DOS 1.25, for approx. a hundred lawns mowed and babies sat) sold me a copy of Turbo Pascal for generic MS-DOS (no PC BIOS assumed) on 8" floppy. He transferred it to the 160KB 5.25" format that my semi-compatible used. I hope I was appreciative enough at the time, as I am now. That helped bootstrap my ca…

Okay, I'll bite :) What's this "PC-semi-compatible" of which you speak?

Wang had some funny ones. They ran both MS Word and MS Multiplan.

Re: Turbo Pascal Turns 40

#193

Turbo Pascal is what got me into programming. I remember spending hundreds of German marks on a license for Borland Pascal 7.0 and later Delphi 1.0 and 2.0. I ended up developing my first “commercial” software that I sold for money. In the DOS era, Turbo Pascal was probably the easiest way to get into programming, outside of Basic. And on Windows 3.1/95, Delphi was eye-opening how easy GUI programming could be. In ma…

[deleted]

Re: Turbo Pascal Turns 40

#194
For all who wonder why Turbo Pascal was so fast here some insights:

50% is certainly due to the language Pascal itself. Niklaus Wirth designed the language in a way so it can be compiled in a single pass. In general the design of Pascal is in my opinion truly elegant and compared to other programming languages completely underrated. Wirth published a tiny version of his compiler written in Pascal itself in a 1976 book called "Algorithms + Data Structures = Programs".

In the late 70s Anders Hejlsberg took that version and translated it into assembly. He certainly must have changed the codegenerator since Wirth's version emitted bytecode for a tiny VM whereas Anders version produced machinecode, however if you take a closer look especially at the scanner and parser of Turbo Pascal and Wirth's version you can see that they are very similar. Back then Anders was not so much a language guy in my opinion but much more an assembly genius. And that resulted in the other 50% of why Turbo Pascal was so fast:

-) The entire compiler (scanner/parser/typechecker/codegenerator/ and later the linker) was written in assembly.

-) The state of the compiler was held as much as possible in cpu registers. If e.g. the parser needed a new token from the tokenstream, all registers were pushed to the stack and the scanner took over. After the scanner fetched the next token, registers where restored.

-) The choice of which register hold what was also very well thought through. Of course the cpu dictates that to a certain extent but still lots of elegant usage of the "si"/"di" register in combination of non repetitive lodsb/stosb instructions were done.

-) The entire "expression logic" (expression parsing / expression state / code generation for expressions) was kinda object oriented (yes, in assembly) with the "di" register hardwired as the "this" pointer. If the compiler needed to handle two expressions (left expression and right expression), then one was held in the "di" register and the other one in the "si" register. Since the "di" register was hardcoded, you will find lots of "xchg di,si" in the codebase before a "method" (a procedure with the "di" register as a "this" pointer) will be called.

-) Clearly the cpu registers were not enough in order to hold the entire state of the compiler so heavy use of global variables were made. Global variables have the advantage of not needing a register in order to access them (e.g. "inc word ptr [$1234]").

-) Parameter passing was done through registers and were possible stack frames were avoided (too expensive), meaning no local variables (still heavy usage of push/pop within a procedure, does this count as a local?)

-) Parameter passing done through registers allowed procedure chaining: instead of "call someOtherProc; retn" at the end of a procedure just "jmp someOtherProc" was used to a great extent.

-) Jump tables everywhere. In general the compiler was quite table driven.

-) Avoiding of strings as much as possible and if needed (parsing identifiers / using filenames) then avoiding to copy the strings around as much as possible, meaning all strings were held in global variables. The big exception here was of course the copying of the identifiers from the global variable into the symbol table.

-) Starting with Turbo Pascal 4.0, hash tables were used as symbol tables. Arena allocator for memory management.

I am sure I forgot a lot, I reverse engineered Turbo Pascal back in the late 90s. Most of the above applies to Turbo Pascal 7.0, but lots have not changed in earlier versions over time.

It is a shame that such a wonderful codebase is buried under the "closed source, proprietary software" label. It is clear that today nobody would write a compiler the way Turbo Pascal was written, not even in a high level language but the codebase has some many tricks, so many elegant solutions, that it is a real pity that this is not open source. Of course the codebase is on the web, just not the official one.

Thank you Anders Hejlsberg for such a wonderful piece of software.

Re: Turbo Pascal Turns 40

#195

Turbo Pascal is what got me into programming. I remember spending hundreds of German marks on a license for Borland Pascal 7.0 and later Delphi 1.0 and 2.0. I ended up developing my first “commercial” software that I sold for money. In the DOS era, Turbo Pascal was probably the easiest way to get into programming, outside of Basic. And on Windows 3.1/95, Delphi was eye-opening how easy GUI programming could be. In ma…

> fully-featured GUI program when today similarly powerful software is orders of magnitude larger in size? That's because the "fully featured" of the 90s would be barely usable today. Or to rephrase: the frameworks and programs of today are not "similarly powerful" to the ones from the mid 90s, even if you just recompiled the app from 25 years ago with the current version of your framework (theoretically ;), it would…

Joel Armstrong once said "You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.". That's a very catchy metaphor, although he was talking about C++ style OOP with bloated classes. Still, it feels like it could be generalized to software bloat, rigth?

What you're arguing seems to be "you think you just wanted a banana, but it turns out the customers needed various banana sizes, levels of ripeness, even special alternative hypoallergenic banana breeds, so instead you get a gorilla to fetch you the right banana from the jungle for each situation."

I do think that there is truth to that, but to be honest I think that in an ideal world that would account for some these orders of magnitude, but leave out the majority of them. It is really, really easy to underestimate just how much faster and bigger computers have gotten in the last thirty years.

What I find a more compelling argument for the majority of this increase in software size and CPU usages is that letting the software bloat and slow down the level that the customers tolerate is a form of externalizing costs for developers. A lot of developer convenience comes at the cost of the end-user, imo. And even if the developers care, then the companies that employ them don't mind saving money that way.

Re: Turbo Pascal Turns 40

#196
Dear God, how I LOATHED Turbo anything as a beginning student. Yes, the debugger was helpful, but I spent HOURS upon HOURS chasing down non-sensical error messages. This was in the pre-Mozilla days mind you, so good luck finding help. Even the TA was useless. Years later, I learned C++ with gcc. Only debug tool we used was "got here" statements. MUCH less frustration. I have vowed to smash every copy of Turbo Pascal and Turbo C/C++ that I find.

Re: Turbo Pascal Turns 40

#197

Never wrote a line of code in Turbo Pascal afterward, but taking it in HS (somewhat on accident) in 1995 was what set the trajectory for the rest of my life.

Similar story here. I started with like 12 casually with C and later C++ in multiple attempts and failed, but TP brought me the joy of programming. And later I could master all other languages (including C/C++).

I will never forget how great it is to have some simple IDE with a "run" button/key, and build simple UI toys with points/lines/rectangles/... (what was it? tortoise? turtle? idk) for a school kid in that age. it was pure magic to bend pixels to my will.

Re: Turbo Pascal Turns 40

#199

Earlier quoted context omitted.

Most programs written in Pascal were UI programs (even in client-server model client was typically a specialized program, not browser), so rendering a string would indeed require a font file. You could pre-render and cache in RAM some frequently used glyphs (locale-specific alphabet, digits etc), but hitting HDD every time to render an emoji won’t be fast enough. Modern Unicode was simply not feasible.

HDD and memory sizes were growing very fast back then. So it would've been feasible even on fairly low-end hardware, starting from the mid-1990s or so. If you could have "multimedia" or "DTP" software on such PC's, modern fonts ought to have been possible. The flip side is that old computers became obsolete very quickly back then, a few years were enough for very real generational changes.

Low-end hardware in 1995 was something like i386 with 1 Mb RAM, meaning that just a modern Unicode font would consume most of the memory available to a program, probably leaving no enough space for the rendering code (which is not small by standards of that time). In 2nd half of 1990s I still maintained a classroom with 15 IBM PC XTs, which were still doing their jobs (our most modern hardware were Pentiums with 16 Mb RAM IIRC).

Re: Turbo Pascal Turns 40

#200

Earlier quoted context omitted.

> was shocked when it ran correctly the first time This overall "if it compiles it works" philosophy is quite common among Pascal-family languages, and derived languages like Ada. Though there is also PL/I if you want a language with a loosely Pascalish syntax that relies on the complete opposite design style - the one that was carried over to C and its derivatives.

I doubt that by modern standards, Pascal seems to work if it compiles, compared to languages like Java or Go. They were comparing it to writing spaghetti code with GOTOs everywhere in BASICA, so no wonder their code seemed more reliable. Nowadays, the jump in reliability comes from strong and helpful type systems, not structured programming. Ada still seems good there, but Pascal is just an ordinary programming langu…

Yeah, the benefits of strong typing have nothing to do with Pascal...

Sigh. Kids nowadays, etc. Look up which was the original language ridiculed for its "belt-and-braces" approach to type safety, in contrast to C, the freewheeling language of Kewl H4xx0rs (although they weren't yet spelled that way).

Now excuse me, there's a cloud I have to go shake my fist at.

Post reply on HN