10 ms·
Pascal is a great alternative to C. It is practical for writing operating systems. Though its use for this has declined if not vanished. Most think of it as a
by ThinkBeat 4y ago
Pascal is a great alternative to C.
It is practical for writing operating systems.
Though its use for this has declined if not vanished.
Most think of it as a "basic tinkering and learning" language,
and indeed, that is probably the most common application.
It does not have to be. [1]
UNIX came with C, and C became "IT".
[1] https://wiki.freepascal.org/Operating_Systems_written_in_FPC#:~:text=Other%20operating%20systems%20written%20in,based%20operating%20system%20from%20scratch https://wiki.freepascal.org/Operating_Systems_written_in_FPC....
- Rochus 4y agoThe operating systems written in Pascal I'm aware of (e.g. the Lisa the source code of which was published last week) used extended versions of Pascal, which e.g. had the '@' operator; actually I don't know any system of significant size which used original Pascal as specified in Jensen/Wirth's User Manual and Report; do you have references?
- yjftsjthsd-h 4y agoEh, that's fine, nobody writes OSs in standard C without compiler extensions either.
- Rochus 4y agoThere are a couple of operating systems which indeed use standard C; Linux is rather an exception in this respect.
- yjftsjthsd-h 4y agoWhat OSs would those be? AFAIK none of the major ones - NT, Linux, illumos, or the BSDs are in standard C.
- kevin_thibedeau 4y agoAll of the embedded OSs. They need to support a mixture of commercial C compilers that don't support GNU extensions.
- pjmlp 4y agoSince when is inline assembly and a couple of language extensions they have part of ISO C?
- Rochus 4y agoThere is no need for inline assembly. Modules written in assembler can be separate from C code. And if you consider "//" a language extension, then yes, everybody and their dogs seem to use them, and nearly every compiler seems to support them.
- pjmlp 4y agoWhen I look at those embedded OSes, I see more than just what ISO C89 allows for, beyond //.
- Rochus 4y agoMy argument is extended ad absurdum in this thread anyway. My point was that Lisa Pascal has made several significant language extensions compared to original Pascal, such as a module system, pointer handling like in C, compiler directives, etc. - all things Wirth himself later added to Modula-2; these were intended, significant and documented extensions under the name "Lisa Pascal", not just the usual errors, inaccuracies and "common deviations" that you find in every C compiler, and that force you to secure libraries with #ifdefs.
- pjmlp 4y agoMany of those things were already present in ISO Extended Pascal and UCSD Pascal. > not just the usual errors, inaccuracies and "common deviations" that you find in every C compiler, and that force you to secure libraries with #ifdefs. And extension keywords for microcontrollers specific features, intrisics for CPU instructions, DSP specific capabilities,.... Yeah I am already used that what goes for Pascal gets another weigth when placed against C.
- Kranar 4y agoCan you name them? Even the academic/research ones or the barebones embedded kernels I'm familiar with use extensions to get things like context switching/multitasking/threading to work.
- foobarian 4y agoEven without compiler extensions the integration with the linker system is a huge strength of C
- pjmlp 4y agoJust any compiled language.
- musicale 4y agoThe Lisa had two operating environments written in Pascal - the standard Lisa OS/Lisa Office System, which resembled early Mac environments but supported protected memory, and the mostly text-based Lisa Workshop development environment, which resembled the UCSD p-system, but supported native compilation, assembly language, and a Lisa GUI-based text editor. Two big extensions to standard/Wirth Pascal that enabled Pascal to work well for the Lisa and subsequent systems were units (separate compilation modules that could be imported/referenced using the USES statement) and an early version of Object Pascal known as Clascal. I'm not sure that Pascal's evolution from Wirth Pascal to UCSD/Lisa/Turbo/etc. Pascal to Object Pascal and Delphi is something to complain about, any more than we'd complain about C evolving from K&R to C89/.../C23 and to C++ (and its various versions.) Pascal is still a capable and relatively compact language. I think Pascal versions that lacked the @ operator and type casts could often use case variant records (relying on technically undefined behavior) to accomplish similar things.
- Rochus 4y agoI just implemented a parser based on the Lisa Pascal 3 specification (see https://github.com/rochus-keller/LisaPascal https://github.com/rochus-keller/LisaPascal) and started to analyze the published Lisa source code. So far I only saw two of the ~350 Lisa OS source files looking like Clascal (both from the Lisa toolkit). Lisa Pascal has quite a lot of essential features not present in original Pascal; an important one for system programming is the possibility to take the address of things which was not possible with original Pascal.
- musicale 4y ago> an important one for system programming is the possibility to take the address of things which was not possible with original Pascal I believe with (unsafe, packed) case variant records you could often get the address of anything that was allocated on the heap: ... type ptrAddr = packed record case Integer of 0: (addr: Integer); 1: (ptr: ^Something); end; var p: ptrAddr; var somethingPtr: ^Something; begin new(somethingPtr); { allocate a Something } p.ptr = somethingPtr; { copy its pointer } writeln('Allocated something at', p.addr); ... (Apologies for any errors - I don't write Pascal very often and haven't tested this.) This obviously relies on implementation-specific behavior such as integers and pointers being the same size. With this sort of trickery you can do all sorts of (unsafe) things including pointer arithmetic, custom memory allocators, garbage collectors, (unsafe) type casts, (unsafe) low-level memory and memory-mapped I/O access, etc..
- pmontra 4y agoPascal and C where the two most used languages in the kind of software development world I was living in around 1990, hobby, university and consulting, UNIX and some Windows. I remember reading one Oberon and one Modula 2 paper. I didn't know anybody using them to build anything real. Pascal had its heyday on DOS and Windows with Turbo Pascal and Delphi. It slowly faded away because everybody started building GUIs with Visual BASIC instead, or Visual C++ for the very technical people. Then came the web and Java and PHP and the early Linux corporate adoption and by 2000 it was buried under a geological layer.
- kmoser 4y agoModula-2 was definitely a niche language. Back in the late 1980s I wrote an add-on to a commercial Modula-2 library that earned me a few bucks. Literally, a few bucks. I used Logitech's Modula-2 compiler, which I don't remember being slow, but Turbo C and Turbo Pascal were far more popular, likely because of their fast compilation speed.
- bhaak 4y ago> I remember reading one Oberon and one Modula 2 paper. I didn't know anybody using them to build anything real. FWIW there was a huge following for the Wirth languages on the Amiga. I don't quite know how that came about but at times it felt like the programs written with Modula-2 or Oberon were as numerous as the ones written in C or Assembler. That was mostly for Public Domain, Freeware, and Shareware software though.
- MarcusE1W 4y agoI have bought the M2 Amiga Modula-2 compiler after saving my pocket money for ages. It came with complete modules/interfaces to the native Amiga system libraries and the type system prevented you from shooting into your own foot at every corner. Amiga system developed is very pointer heavy. Modula-2 could not prevent all issues but at least catch some. Made sense to me at the time. Plus I could do my computer homework in Modula-2 on my Amiga and then quickly rewrite it to Turba Pascal in school