Hi, author of Jacqueline here. I read HN almost daily so it caught me off guard to see my stuff here.
It's been a long time since I did this (2019). It was a prototype just to see if a standard PC boot loader could hand-off into something that's not C (or Rust). And yes you can, as long as the programming language has a way to control how symbol names are exported, and then to link the object code with the rest of the boot loader.
You won't have a runtime unless you implement one, so for most languages there is no stdlib, no exception handling, no garbage collector... But it is fun anyway. As I said, this was a prototype and once it could say Hello World I considered it complete.
Happy to see it here though, and I'll be happy to answer any questions about what I remember, or what is like to write code in Pascal, or OS development or i386 in general.
I remember writing my own bootloader for my DOS-successor OS project with its own FS when I was 17. Never got around other than running a primitive kernel that just displayed text on the screen though. Fun times! https://gist.github.com/ssg/546634
> Even while Pascal wasn't written with low-level programming in mind
If that’s true, then neither was C, Algol, etc. When those languages were conceived, “low-level” programming was just “programming” and “high-level programming” was the exception. Mostly because the hardware ecosystem was far more fragmented and an OS wasn’t guaranteed.
To that effect, all of those languages give you the “features” necessary to “low-level” program, namely: raw pointers and ability to compile for freestanding environments.
I remember embedding assembly inside my Turbo Pascal procedures and functions, using asm/end blocks. It worked quite well. External assembly module object linking was an option too.
It did in Object Pascal as well - way back in a different life when I hung around a programming channel there was a big argument about C always been faster than Pascal from one of the C devs in there - so we set the challenge as "count instances of several words in a 100MB file" fastest using only language features and the standard library for each (what came out the box).
I beat the C programmer because I "cheated" - I dropped into assembly for parts of it since that was part of the core language to be able to do that, he used whatever string library was shipped with his compiler at the time, he rigged it because Object Pascals standard string functions where notoriously slow (fast enough but much slower than C implementations of the time) - one of my prouder moments and 100% not something I could do now, I've completely forgotten assembly.
i386 is a great target for toy OSs. There's no risk of getting a bit megalomaniacal and thinking your OS could ever be anything more than a toy. Also, it's more challenging than RISC-V, ARM, and even x86-64, so it feels like more of an accomplishment if you actually make it to userland and back without catastrophic failures.
Mac OS 9 was written in Pascal, and so was the Berkeley P-System, a portable Pascal development environment from the 1970s, featuring a virtual machine that influenced the later JVM. Apple's Lisa OS was also implemented in Pascal.
Indeed, e.g. Apple Lisa OS and the first Mac OS. But the present one so far is only around 100 lines; the author calls it a "bootloader". Here is a list of more complete systems: https://wiki.freepascal.org/Operating_Systems_written_in_FPC.
My employer (France Telecom) had a Unix written in Pascal running on a 68000 machine. But there were all the usual Unix tools on it, including a C compiler.
How come? Pascal is a perfectly good language, it wouldn't be my first choice for anything but compared to quite a few other languages from that era it got lots of things right.
There have always been fanboy "camps" feuding each other, from "What's the best programming language?" to the never-ending "What's the best text editor?".
Brian Kernighan tried to port his famous software tools (the code to go with the likewise famous book) to Pascal and failed, which led to a write-up, in which he identified 9 shortcomings of Pascal that C doesn't have.
https://www.cs.virginia.edu/~evans/cs655/readings/bwk-on-pas...
But needless to say, there exist also many strenghs of Pascal over C, which he does not address. I find his claim that Pascal is only a toy language in which serious software can be written unprofessional and empirically untrue: for over a decade, PC software development in Pascal was thriving thanks to TurboPascal. Now admittedly that is not standard ISO Pascal, but at the same time, it is a well-known fact that it existed, and that it fixed some of the criticisms of Kernighan's paper, so it is regrettable he still elected to use such strongly negative language regardless. (And for the record, his paper was written 1981, when Pascal's successor Modula-2 was already available.)
I like C and Pascal, each in their own way, but Pascal is
arguably much more readable, and perhaps it is fair to say many Pascal programmers were comfortable in the language and would not have bothered to learn/struggle with C.
Had we bothered with Modula-2, released in 1978, where Niklaus Wirth took care to fix all ISO Pascal issues from 1976, we would not have such problems.
Also he has a pretty much dual approach to his criticism, while having Pascal dialects is a flaw, apparently having C dialects is a plus.
I find the claim that bwk 'failed' suspect, since I have a copy of "Software Tools in Pascal" on my shelf right now.
Almost the entirety of his criticisms were accurate in 1981 and addressed even five years later, and many of them say more about his assumptions than they do about Pascal. For instance, the implicit assumption that arrays must be the natural way to deal with strings rings hollow; some years later, "I wish it were as easy to deal with strings in C as it is in Pascal" would be a common refrain.
I think bwk is one of the best people in the industry, both technically and personally, but I feel this essay is an artifact of its time more than a lasting commentary on Pascal as a whole.
It's been a long time since I did this (2019). It was a prototype just to see if a standard PC boot loader could hand-off into something that's not C (or Rust). And yes you can, as long as the programming language has a way to control how symbol names are exported, and then to link the object code with the rest of the boot loader.
You won't have a runtime unless you implement one, so for most languages there is no stdlib, no exception handling, no garbage collector... But it is fun anyway. As I said, this was a prototype and once it could say Hello World I considered it complete.
Happy to see it here though, and I'll be happy to answer any questions about what I remember, or what is like to write code in Pascal, or OS development or i386 in general.
reply