logoalt Hacker News

cowlevel • today at 1:13 PM • 5 replies • view on HN

Probably no optimization though, right?


Replies

joakleaf • today at 2:50 PM

You could enable optimizations. Turbo Pascal generated pretty fast production code in general, and you could also disable run-time checks like range checking etc.

The generated code wasn't perfect, but you could always use assembler for short routines that needed faster code (e.g. loop-unrolling, tighter register usage, or 80386 32-bit register code, which I think TP never supported). There were also tricks that would improve performance (I seem to remember that 'repeat'/'until' was faster than standard 'for' loops).

To be honest, it was a very fast tool to work with (even on a 80286) -- The integrated debugger was a dream to work with for the time too.

I remember switching to C (both Turbo C and later gcc via DJGPP on both a 80386 and 80486). Compiling even standard C was agonizingly slow in comparison to TP, and you couldn't iterate as fast as TP. It was like moving from having fun programming to plain torture.

I moved on to fully embrace C later (and C++). As the computers got more RAM and got faster, it became a lot better experience, but I never fully understood why C was popular as a general purpose language in the 80s and 90s. I doubt C was optimal for development time.

TP was a really balanced compromise in a lot of ways.

pjmlp • today at 1:30 PM

There were optimizations already available.

Even if the basic ones that tend to be part of university compiler assignments, .e.g. peephole optimisations, constant propagation, inlining, bounds checking removal, redundant loads removal,....

See chapter 21 from Turbo Pascal 7 Language Guide, to use the last one for MS-DOS as example.

Similar build performance available in other languages, alongside a small set of optimisations.

It is a urban myth that we cannot have both, only because folks experience is tainted with C and C++ compilers.

If you want a good example of fast compilation times with optimisations enabled, check D reference compiler dmd, or to keep on the subject, FreePascal or Delphi 13.

hnlmorg • today at 2:14 PM

Optimisations existed back then. But what Pascal did differently to a lot of modern languages was it only required a single-pass compiler and no macros.

On slow systems of the era, that vastly reduced the amount of work a compiler had to do to turn ASCII into machine code.

These days, compilers run macros, multiple passes of the source code. Often then building their own byte code or an interim machine representation, before turning that into machine code.

Those layers of abstraction aren’t without benefit. You get greater composability of code, greater portability, and so on and so forth. So they exist for a reason.

OskarS • today at 1:59 PM

Optimizations is one reason for modern languages to compile slowly, but it's certainly not the only reason. Even at -O0, C++ and Rust are much slower to compile. The culprits are more likely much more advanced type-systems and monomorphization passes for generics. Slow compile times are much more inherent to the languages (compared to Turbo Pascal, certainly).

➕ show 1 reply
muyuu • today at 1:30 PM

they are pretty minimal

the game back then was to use inline assembly for the critical bits, this really worked a treat for the meta of the 90s, with computers that were being asked for multimedia processing with slow CPUs, little RAM and typically no hardware acceleration

➕ show 1 reply