Hacker News
Jacqueline – A minimal i386 kernel written in Pascal (2019)
danirod
|next
[-]
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.
sedatk
|next
|previous
[-]
abotsis
|root
|parent
[-]
nn3
|next
|previous
[-]
KernelMain(); [public name 'kernelMain']; begin consoleClearDisplay(); consoleSetAttributes(White, Black); consolePutString('Hello world'); end;
deaddodo
|next
|previous
[-]
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.
mycall
|root
|parent
[-]
noir_lord
|root
|parent
[-]
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.
james_marks
|next
|previous
[-]
> Jacqueline is an experimental bootloader written in Pascal (Free Pascal dialect) written for the i386 architecture, just because
phendrenad2
|next
|previous
[-]
pjmlp
|next
|previous
[-]
Nice to see yet another experiment that isn't always C or C++.
jll29
|root
|parent
|next
[-]
dboreham
|root
|parent
[-]
pjmlp
|root
|parent
[-]
http://pascal.hansotten.com/ucsd-p-system/apple-pascal/apple...
Rochus
|root
|parent
|next
|previous
[-]
HeavyStorm
|previous
[-]
jacquesm
|root
|parent
[-]
jll29
|root
|parent
[-]
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.
pjmlp
|root
|parent
|next
[-]
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.
stonogo
|root
|parent
|previous
[-]
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.