by joakleaf · 1w ago · 0 comments
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.
Sure things were very spartan, but you could do a heck of a lot on what is basically a trumped up microcontroller. I have mostly felt that modern tech has been a step backwards - because the inner loop has so much latency. Turbo Pascal and Delphi were really leaders in this regard. Python and friends were good too (aside from the runtime errors!), but getting a real compiled and lean binary so quickly was a very special thing. I didn't enjoy moving to Java after that, especially in those early days.
If only I had known about TDD back then, I think ultra low latency compiles and fast running tests would be hard to beat.
Depends on what you mean by general purpose I guess, but I remember I liked it because of C strings. It's difficult to understand these days, C's strings were better than those in other languages: no 255 byte length limit, 0-based instead of 1-based, escape sequences so that you could have any byte in a string (Turbo Pascal supported control characters, but PASCAL in general did not). Other languages at the time really only supported fixed length space filled strings.
Another big thing was existence of malloc().
Null-terminated requires that you have sentinel (null) at the end, instead of a length at the beginning.
Having a length (encoded as a byte at the beginning), means they are very easy and efficient to copy and concatenate, because unlike the null-terminated variant, you don't have to search for the terminator which requires a conditional branch on each character until the length.
Conditional branches were really expensive on old CPUs, compared to the 8086's rep movsb instruction, that could just copy a specific length of bytes. On the other hand, I suppose, other string-operations are more tricky, because you need to keep track of your position in the string as you iterate over it.
I've never thought null-terminated strings were a particularly neat design or easy to work with (there are pros and cons) -- But the 255 string limit was annoying, and I wished they would have had pascal strings up-to 64K in length (they could have used a word as length instead of a byte).
Malloc is by no means a 'C' specific thing -- Turbo Pascal had getmem() to allocate memory on the heap.
Turbo Pascal 1.5 for Windows 3.1 introduced C strings (PChar), and afterwards, Turbo Pascal 7 took open arrays from ISO Extended Pascal.
Malloc() is a primitive library call where one always has to do sizeof math for memory allocation, if you wanted that fun in Turbo Pascal instead of plain New, you could use GetMem and FreeMem functions.
And the concept of areas was already supported with Mark/Release.