Turbo Pascal: A Great Choice for Programming Under CP/M (2013)
techtinkering.com
techtinkering.com
To this day I think it's the most interesting and satisfying thing I've ever done in terms of software. Despite getting a Ph.D. in computer science and working for Amazon, Microsoft, and Cray, nothing even comes close, with the exception of one project at Microsoft Research. These days I've given up completely any hope of working on something even remotely interesting or satisfying.
I think it's the learning experience and result we crave.
1) Find some worthy students and be their mentor
2) Do Program something you really want or enjoy, e.g. a game or a new language
Fortunately, in my professional work, I'm not affected by office politics, and I can handle the overhead of project management. It's just the lack of opportunity to write code that does something interesting (figure out an algorithm that does something non-trivial with this data) that bugs me.
I realized what the difference was: Back then, I was programming for myself, for the enjoyment of it. I was dogfooding everything, at times I was not only the top user, but the only user of my software.
So I went back to doing that, and I can happily report that I feel that way again. It can be done, don't give up hope.
So yeah, it's somewhat "going back", but at least, I can express creativity in some unbounded ways. Plus, I code my dream, not the dream of the company which is paying me :-)
So far, I've reached back to Netscape 2.x and Mosaic :)
A hobby lets you choose your own battles, work on your own schedule and terms, gauge your progress by simple measures such as personal satisfaction or helping someone with their own life. Career means all of the ** that comes with the job, and doing mostly stuff that other people want.
Granted with music it's a bit more extreme, since a middle ground of doing fun work for subsistence money doesn't really exist.
He does not have this problem, but I suspect he's left lots of money on the table as a result.
That said, i'm afraid that modern Pascal isn't awfully popular, which hurts its practicality a bit (e.g. learning about it, finding tutorials and others' experience with it, getting help). However, it's approach to native GUI development is pretty good, the language itself seems pretty okay and the compilation times are generally pretty good, as is performance ( https://benchmarksgame-team.pages.debian.net/benchmarksgame/... ).
Perhaps the only actual dealbreaker i can think of, is the fact that it doesn't have that many stable or even first party web development frameworks/libraries ( the closest i've found to that being https://wiki.freepascal.org/fpWeb_Tutorial and https://wiki.freepascal.org/fcl-web ), however they don't seem to be as popular as the "de facto" frameworks of the other languages. For example, Java has Spring (and Spring Boot), Node has Express, Python has Django (or even Flask), Ruby has Rails, .NET Core has ASP.NET Core, which are all widely supported and well documented, with plenty of tutorials.
Of course, that has only been my limited experience, since i mostly work with the other alternatives at my workplace and only dabble in Pascal occasionally in my free time. Would anyone care to comment on their experience with modern Pascal as well?
I use Delphi all the time, IMHO, it's the best tool for Windows desktop app development - concise language, blazing fast compile time, easy UI design, flexible UI framework, all-in-one IDE, and so on. It's such a joy to me :)
And here is my new desktop software written in Delphi: https://docxmanager.com/
The latest language from Niklaus Wirth is Oberon which was last updated in 2016. It is both smaller and more capable than Pascal.
The original Oberon and Oberon-07 lacked any support for subranges, enumerated indexes for arrays, co-routines, monitors and exceptions.
Oberon-07 goes even further cutting features from Oberon.
For me the best language from the Oberon family is Active Oberon.
Oberon-07 is a nice exercise in minimalism, but not something I would enjoy using in production.
However, as a language, Pascal is a bit of a pain. The parts that frustrate me the most, are the necessity of editing code across separate locations when introducing a new variable/function and the lack of smaller scopes beyond function scope. Brian W. Kernighan's "Why Pascal is Not My Favorite Programming Language" (1981) lists some of these frustrating parts, although there are many improvements since then.
I think more recent pascal compilers now support declarations elsewhere aside the interface section or beginning of a function. But more recent also means less support for older systems, which is part of what I like about Pascal.
And if my program doesn't need a GUI, I feel that C/C++ is far more productive for multi-platform-compilable native programs.
Almost on the topic: in Russia there were popular school computers UKNC https://en.wikipedia.org/wiki/UKNC, pdp-11 clones with deep changes, with an RT-11 compatible OS. They were everywhere, well into late 199x, when they were deeply obsolete, because schools didn't have funding to upgrade classrooms. It was my first computing platform when I was a kid, but the only language accessible was BASIC, with a line editor (pretty strange concept nowadays), line numbers, no named subroutines, etc. In 1997 I was suprised to find in a new school I've transfered to the same old computer but with Pascal compiler on it. With an actual editor, a very fast compilation time, and all still crammed into 64kb of memory. I was really impressed.
MS just released Windows XP, I was in high school. Back in those days, people used Basic, Pascal, and C for programming competitions.
Already had some experiences with Basic, and found C to be too "low level" for my taste, I picked Pascal. Next year, I jumped into Delphi: learning Win32 GUI basics and some database programming with MySQL. Probably pretty advanced for a high school kids, since most of my friends were interested in music or games :)
I never used Pascal/Delphi for work though, because Java has been a major player in mobile development scene (J2ME -> BlackBerry -> Android....).
One of the things I appreciate about Pascal compilers is: blazing fast compile time. And I think it still applies to FPC (Free Pascal Compiler).
You can rebuild the whole compiler + basic libraries from scratch under 5 minutes. Can't say the same thing about GCC. Well the last time I did this was in 2014 (or 2015?), though.
Now, if I want a native compiler with fast compilation speed, I'd pick Go or Nim.....
But I do share a similar Pascal story, just a decade earlier. :)
[0] - People keep forgetting there are AOT toolchains (and JIT caches) for them.
We were taught C and Pascal in college, and I distinctly remember thinking out loud, "Wow. Why do people bother with C when Pascal seems so much easier to understand and just nicer?" (Ofcourse, in hindsight, I now know Pascal was easier to understand because I had already learnt programming concepts with C previously). But I still prefer Pascal's overall 'ideology' and syntax over C (except for the BEGIN ... END - would prefer braces :).
Its history and uses are interesting.
I worked through the entire Advent of Code 2020 exclusively in Pascal.
In case others would like to skip the trip through mike's blog ;)
I'm surprised at how modern a lot of the code feels.
Eventually I got old of Turbo Pascal 3.0, started learning there (yep a version below), then at school Turbo Pascal 5.5 was actually the programming language after Basic, so I got introduced to units, and Object Pascal.
Eventually due to an agreement with the teacher that if had a theme I wanted to learn more, I could study it and present to the class.
I choose OOP, which in the process made the owner of a Turbo Pascal 6.0 copy, with the wonderful Turbo Vision framework to learn from.
On the same year I bought a copy of Turbo Pascal for Windows 1.5 (target Windows 3.x), with the Object Windows Library, a pleasure to work with versus bare bones Win32.
So when I go to learn C a couple of years later, it never impressed me, too little features, too unsafe, the only thing going for it was being available in more platforms than Turbo Pascal was.
Luckily the same class also had a Turbo C++ 1.0 package that was being ignored, and that brought me the Turbo Pascal features I was enjoying, alongside the portability that Turbo Pascal lacked.
From my point of view, only Microsoft and Apple tools seem to keep on the same developer tooling spirit and language capabilities.
It was so fast to compile and so ergonomic compared to the alternatives.
Great stuff.
Looking back I believe Pascal was the perfect language to learn those two fundamental and tricky concepts. It felt aesthetically pleasing and struck just the right balance between the terse (and sometimes quirky) C and verbose COBOL.
When I coded up those graph algorithms in Pascal I felt “happy” in a way that can’t be explained and which I didn’t experience in C.
Sure you can emulate them with double pointer indirection, which is anyway what the compiler does, but it adds more cognitive overhead.
I wrote a set of routines to allow field based text editing, and built up a CRUD (Create Read Update Delete) database of locations, routes, equipment. I took 4 weeks instead of the two I estimated.
The customer loved it, it met all the requirements... and was totally impractical as a system. I spent the next year rewriting it in a fairly agile manner working for the Russ, Assistant Plant Manager. He taught me how to make user friendly software in a simple manner... we would pull a person from the plant and say something like
"This is Mike... he wrote this program. [Worker Name], I don't expect you to be a computer expert, it's not your job... I want you to do X,Y and Z... If something goes wrong, it's Mike's fault"
"Press F1 for Help" was ALWAYS at the top of the screen after the first 5 seconds of the first user trying things and not knowing what to do. I learned an amazing amount about writing software from Russ.
One time... he asked "what would happen if I disconnected it right now?" I didn't know, and said so.... I got that taken care of in the next week. You could disconnect at any time, and never lose a record.
It was a fun job.
Discussed on HN here: https://news.ycombinator.com/item?id=16704733
I remember that Janus Ada for DOS cost thousands for a license. Java and GNU C++ were free.
Now Microsoft has the Community edition of Visual Studio for free C#, Visual BASIC.Net, C++ and other languages.
Long answer,
UNIX spread like fire, because Bell Labs/AT&T initially weren't allowed to sell it.
So the code was given to university, and while they needed to pay for a UNIX license to use it, the price was symbolic versus paying for something like VMS.
Which naturally made UNIX the number one choice for the startups trying to get into the Workstation market during the 90's.
So C started to spread into the 8 and 16 bit computers in some form.
When those 8 and 16 bit home computers, written in Assembly, started to be replaced by more powerful systems, the OS vendors were adopting C as the language.
Most won't be aware of this today, but Microsoft did sell Xenix and MS-DOS at the same time, they sold Xenix as they decided to focus on MS-DOS instead. In fact, MS-DOS 4 failure was an attempt to make it more UNIX like.
At the same time, maybe to reduce costs, the OS vendors started to reduce the amount of compilers they were selling it for their platforms, selling only the same ones as they were using themselves for the OS, which by then naturally meant C.
Any other language started to be available only from third parties, and most of the time without bindings to all OS APIs.
So given the choice of buying the language programming tools from the OS vendor, with everything ready to code, or paying even more (you would need the OS SDK anyway) and having to code bindings, the majority stayed with OS SDK only.
As C++ is a C sibling, coming from UNIX birthplace, it quickly found a place among C compiler vendors tooling.
Java, well it was pushing by Sun, quickly adopted by Microsoft, IBM and Oracle on their platforms.
So enjoyed a bit that extra love from platform owners.
Having lived through this evolution, I have learned only to bet on platform languages, or those that eventually get blessed by platform owners on their official SDKs.
When I got into university, I had my first set of Pascal classes on UNIX.
Coming from a background of multiple Turbo Pascal versions, I was on TPW for Windows 3.x by then, I was dismayed having to do university assignments in P2C, using original ISO Pascal (it wasn't even capable of the ISO Extended version).
So no wonder that Pascal on UNIX hardly got any love.
I think only HP-UX and VMS Pascal variants were actually relatively good.
All the ones I currently use in some form, Java, .NET languages, C++, JS, SQL, fulfill the above via ISO, ECMA, or official reference docs managed by multiple vendors.
And to be honest, even those that don't I really don't care any longer, because most of the code I write isn't mine to own rather the employer, so as long as it fulfil what the customer is after, I am good, when the project is done I move to the next challenge.
If project requires cross platform capabilities, then usually something along the lines of what is available across all platform SDKs gets chosen.
On Unix mass adoption...
My best friend (and still best friend to this day) in the early 90s had an SGI Indy at home (his stepfather happened to be the director of SGI Benelux) and so I got to play with one of the earliest SGI Indy. What a machine to have, for teenagers into computing, at home in the early nineties!
The shock, the world of difference between a beige box running MS-DOS / Windows 3.1 and stuff like (Turbo) Pascal compared to that amazing SGI workstation...
I saw the future, I saw "my" future when I got to play on that SGI Indy. And then when I discovered Linux (back when it was shipping on a CD attacked to a book/magazine) I got to transform my MS/Windows beige PC into a (modest) Un*x station and never looked back (I'm using Linux daily since that day).
I don't have bad memories of programming in Pascal but both Pascal and Delphi felt, to me, like deeply attached to the MS ecosystem and a bit toy'ish (making it easy to do easy things, but very hard to make anything a bit advanced).
As soon as I found a way out of the MS world I was out and so I was done with Pascal/Delphi.
Hardly impressive, with its green phosphor terminal.
SGI was interesting, then again I guess you didn't had much contact with Atari and Amiga scene back then, right?
Object Pascal dialect was originally created by Apple in collaboration with Niklaus Wirth (see clascal), used to write the Lisa and Mac OS operating systems (naturally they also had their share of Assembly, like UNIX also does).
They only switched to C and C++ after market pressure to have some compatibility with them.
Oh how I missed Turbo for Linux...
Interesting paying for cygnus stuff on Windows never occurred to me, I rather spent my money with Borland and Microsoft compilers.
It’s not a meritocracy driven development, it’s marketing 101.
Go is to Google what Java is to Sun/Oracle. History is repeating but we can’t really fight it because it would be a wasted effort.
If you wanted to play in those ecosystems, you had to learn C at the beginning. People wanted to play in those ecosystems. :)
Today when I program in C (thanks to embedded work), it seems like many of the modern improvements to the language consist of making it more Pascal-like.
I also had Microsoft CBASIC, Fortran-80, COBOL-80, BDS-C, and many assemblers. Turbo Pascal put them all to shame. The C compilers for CP/M could not even do floating point math. Turbo Pascal had no such limitations.
At the time Borland intended to develop their own version of Modula-2 for IBM PC, so they bought ours as a complement for the CP/M versions they were still covering. But the in-house version got delayed a lot. It was eventually released as Topspeed Modula-2 several years later, from a spinoff. If Borland had let us also do the IBM-PC version in around 1984, maybe history would have changed and Modula-2 would have become more popular.
I liked it but remember the I/O commands were frustrating as heck. It would be interesting to C-syntax it and see what the reaction is.
I think a great thing about Pascal was its origin as a teaching language. As a result, the textbooks placed a heavy emphasis on learning good programming techniques, and the language supported those techniques. I think maybe it's no mere coincidence that good teaching tools also become good general tools for those of us who are not destined to become full time pro's.
Learning BASIC and Pascal side by side was a great lesson in how to write good code, because you could make your Pascal programs so much more readable and organized. Even today, if any human has a faint hope of reading and using my code (in Python or C), it's thanks to the skills I learned from Pascal.
When I got my first computer, a non-PC-compatible MS-DOS machine, I remember my dad asking me some vague questions about it. He had heard us talk about Pascal (my mom and brother both learned it), and the Wall Street Journal had a glowing article about it. He had no idea what it was, but got me it for my birthday. And it followed the "rules" of MS-DOS, so it ran on my weird computer! No graphics, but who cares, I was up and running with Pascal.
I found a magazine article on how to attach a serial port to my computer, wrote a terminal emulator in Pascal, and found an old 300 baud modem. I was able to complete my computer assignments from my dorm room. In FORTRAN.
It's a shame what Embarcadero has done to Turbo Pascal's successor Delphi. It's really an amazing language if it weren't for the god awful IDE.
If you're happen to still work on Delphi enterprise software I'd highly recommend to have a look at OmniPascal (https://www.omnipascal.com/), a very smart VisualStudio code plugin. It's a gem that provides JetBrains-like quality completions/refactorings for Delphi/Pascal.
I have had a million technical books in my life, and I held on to many of them for a long time past their technical viability just out of sentimentality. Now I limit myself to half a shelf. On that shelf are my well-worn K&R, a similarly dogeared very early O'Reilly Perl book, the Peter Norton Assembly Language Book for the IBM PC, and a Waite Group book on Turbo Pascal 5.5.
One dad Dad brought home Turbo Pascal. To try it out I implemented Conway's Game of Life. Once I got past my syntax errors, I was shocked when it worked correctly the very first time. I never wrote another line of BASICA.
I learned programming in my own time on 1980's 8-bit machines, but in college it was Pascal on Vax VMS then Turbo Pascal on, IIRC, an Act Sirius. Loved the language.
Then along came JPI TopSpeed Modula-2 (Pascal++ [joke]) and even though I now do C#, Go, Node, Python, Ruby, and FreePascal, nothing matches the sheer productivity and performance that TopSpeed provided. And their IDE was incredible at the time (though Turbo Pascal 3 having a compiler and editor in around 40KB was technically more awesome).
Indeed - I still have the software (though the disks are long gone). A few years back I even rewrote that demo in C# (console app) because why not.
Edit: Anders Heljsberg is responsible for C# and TypeScript. Prior to that he wrote what became Turbo Pascal and was chief architect on Delphi. Seems I can't escape his stuff.
I was blown away when Turbo Pascal 7 came with syntax highlighting.
I also spent days trying to fix infamous Runtime Error 200.
Oh, you can do it.
his is the TXR Lisp interactive listener of TXR 249.
Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet.
Use full-strength TXR for tough tasks, or dilute with shell scripts.
1> (defmacro with (struct obj . body)
(with-gensyms (obj-sym)
^(let ((,obj-sym ,obj))
(symacrolet ,(mapcar (op list @1 ^(qref ,obj-sym ,@1)) (slots struct))
,*body))))
with
2> (with time (time-struct-utc (time))
(list year month day))
(2021 1 30)
Expansion: 3> (macroexpand '(with time (time-struct-utc (time))
(list year month day)))
(let ((#:g0016 (time-struct-utc (time))))
(symacrolet ((time-local
#:g0016.time-local)
(time-utc #:g0016.time-utc)
(time-string
#:g0016.time-string)
(time-parse #:g0016.time-parse)
(year #:g0016.year)
(month #:g0016.month)
(day #:g0016.day)
(hour #:g0016.hour)
(min #:g0016.min)
(sec #:g0016.sec)
(dst #:g0016.dst)
(gmtoff #:g0016.gmtoff)
(zone #:g0016.zone))
(list year month
day)))
Total expansion; symacrolet gone, a.b desugared into (slot a 'b): 4> (expand '(with time (time-struct-utc (time))
(list year month day)))
(let ((#:g0017 (time-struct-utc (time))))
(list (slot #:g0017 'year)
(slot #:g0017 'month)
(slot #:g0017 'day)))So when you add, remove or rename members of a record, you are potentially influencing the contents of scopes in other files all over the project. You can cause variable shadowing that way.
VAR
B : INTEGER;
WITH ^P DO
A := B; (* B is just a local, A is a field *)
END
If B is added as a field, the above suddenly means ^P.A = ^P.B.Any time you edit a Modula-2 record, you have to search the program for all the places where its type may be targeted by WITH.
Probably if you stick to some rules, like never using WITH on another module's record type, you will be fine.
Diagnostics related to shadowing could help.
class foo {
// int x;
int y;
int bar();
};
// in another file
int x;
foo::bar() // "with whole friggin class scope ..."
{
return x + y; // global ::x plus class member y
}
Now uncomment the x in the class declaration, and the x + y now adds two class members.The scope operator is an ugly opt-in mechanism you will only use if you discover the problem.
Turbo Pascal: A Great Choice
I did a lot of Turbo Pascaling on that one, but it was frustrating watching the compiler go so slooowly while I already noticed a misprint or a missing ; on the screen.
The last thing I did on Turbo Pascal was a program that drew fractals in 320x200 using direct memory access (byte absolute). I tried to get it working in 640x480, but the differences between individual VGA cards were too big. That was 386 already, though.
Buyed the programming manual for the ET4000 GPU (>100DM for this manual alone, a lot for a student from the eastern part of Germany at this time), opcodes and all. I liked the possibility to easily mix Assembler with Pascal in Turbo Pascal. Machine code for graphics, FPU, interrupt programming, the higher language for anything else.
After that, I learned C from the Open Source Fractint. So, the transition wasn't that painful after TP's decline.
And anything was so snappy in Turbo Pascals text mode windowing system (as with Norton Commander too).
I have this snippet burned in my head and I used it all the time in MS-DOS' on Turbo Pascal 6 or 7 to get to the tasty 320x200 palleted graphics mode:
asm
mov ax,13h
int 10h
end
iirc, after that you could simply directly access video memory using something like "mem[$A000:x+200*y] = color;" and that was it.Fun times.