News for hackers. Stuff that matters.
Re:Oberon-2, a hi-performance alternative to C++ (1997) by ThinkBeat on Tuesday January 24, 2023 @07:39PM (#34512737)
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....

Re:Oberon-2, a hi-performance alternative to C++ (1997) by Rochus on Tuesday January 24, 2023 @07:57PM (#34512892)
The 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?
Re:Oberon-2, a hi-performance alternative to C++ (1997) by yjftsjthsd-h on Tuesday January 24, 2023 @08:05PM (#34512953)
Eh, that's fine, nobody writes OSs in standard C without compiler extensions either.
Re:Oberon-2, a hi-performance alternative to C++ (1997) by Rochus on Tuesday January 24, 2023 @08:13PM (#34513023)
There are a couple of operating systems which indeed use standard C; Linux is rather an exception in this respect.
Re:Oberon-2, a hi-performance alternative to C++ (1997) by yjftsjthsd-h on Tuesday January 24, 2023 @08:56PM (#34513396)
What OSs would those be? AFAIK none of the major ones - NT, Linux, illumos, or the BSDs are in standard C.
Re:Oberon-2, a hi-performance alternative to C++ (1997) by kevin_thibedeau on Wednesday January 25, 2023 @04:20AM (#34516215)
All of the embedded OSs. They need to support a mixture of commercial C compilers that don't support GNU extensions.
Re:Oberon-2, a hi-performance alternative to C++ (1997) by pjmlp on Wednesday January 25, 2023 @04:57AM (#34516499)
Since when is inline assembly and a couple of language extensions they have part of ISO C?
Re:Oberon-2, a hi-performance alternative to C++ (1997) by Rochus on Wednesday January 25, 2023 @05:40AM (#34516748)
There is no need for inline assembly. Modules written in assembler can be separate from C.
Re:Oberon-2, a hi-performance alternative to C++ (1997) by pjmlp on Wednesday January 25, 2023 @05:44AM (#34516773)
When I look at those embedded OSes, I see more than just what ISO C89 allows for, beyond //.
Re:Oberon-2, a hi-performance alternative to C++ (1997) by Rochus on Wednesday January 25, 2023 @06:31AM (#34517070)
My 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.
Re:Oberon-2, a hi-performance alternative to C++ (1997) by pjmlp on Wednesday January 25, 2023 @08:13AM (#34517841)
Many 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.

Re:Oberon-2, a hi-performance alternative to C++ (1997) by Rochus on Wednesday January 25, 2023 @08:56AM (#34518246)
Apple II and III Pascal (and in consequence Lisa Pascal, but there was e.g. not UNIT or USES syntax in USCD) were indeed based on USCD Pascal, but ISO 10206 was a decade later as far as I remember.
Re:Oberon-2, a hi-performance alternative to C++ (1997) by pjmlp on Wednesday January 25, 2023 @09:30AM (#34518633)
There were other Pascals around with system programing extensions, quite a few were eventually standardized in ISO 10206 (1991).

http://pascal.hansotten.com/

And while the discussions keep going around Pascal and its extensions, there is this little detail of Modula-2 being released in 1978, where all the issues with Pascal (as originally designed by Wirth) for systems programming were already fixed.

Re:Oberon-2, a hi-performance alternative to C++ (1997) by Rochus on Wednesday January 25, 2023 @10:07AM (#34519107)
Yes, the first ETH Report about Modula-2 appeared in 1978, around the time Lisa Pascal was developed; the latter refers to the Jensen/Wirth 1975 Pascal edition. I don't know whether there were contacts between Apple and Wirth before Clascal. Not to forget that Tesler came from PARC where they had Mesa, so he had the same source as Wirth had.
Re:Oberon-2, a hi-performance alternative to C++ (1997) by Rochus on Wednesday January 25, 2023 @02:54PM (#34523279)
Here I found an interesting Article by David Craig about where Lisa Pascal (and all the other Apple Pascal version) came from: https://www.applefritter.com/content/brief-history-apple-com...

Where Apple II and III Pascal was based on UCSD Pascal, Lisa Pascal was apparently directly based on Wirth's P4 compiler, not on UCSD Pascal. See page 4.

Re:Oberon-2, a hi-performance alternative to C++ (1997) by musicale on Wednesday January 25, 2023 @04:47PM (#34524622)
Great reference! Terrific to have a semi-original source, thoug I wish it included more detail and references.

> Therefore, Lisa Pascal lasted from 1981 to 1986, an eternity in the field of microcomputer languages.

;-)

> Tho (sic) Pascal will have the support of a small but vocal minority at Apple, C/C++ will be the dominant language for Apple and outsiders for the next decade.

RIP Pascal, you will not be forgotten - and you will live on as Delphi.

Re:Oberon-2, a hi-performance alternative to C++ (1997) by Kranar on Wednesday January 25, 2023 @12:11AM (#34514673)
Can 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.
Re:Oberon-2, a hi-performance alternative to C++ (1997) by foobarian on Tuesday January 24, 2023 @09:10PM (#34513506)
Even without compiler extensions the integration with the linker system is a huge strength of C
Re:Oberon-2, a hi-performance alternative to C++ (1997) by pjmlp on Wednesday January 25, 2023 @01:10AM (#34514974)
Just any compiled language.
Re:Oberon-2, a hi-performance alternative to C++ (1997) by musicale on Tuesday January 24, 2023 @10:19PM (#34513963)
The 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 original/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.

Regarding the @ operator and type casts, you could often hack something similar in standard Pascal implementations using case variant records, though I think it was technically undefined behavior in the standard. @ and type casts just make it an official feature with simpler syntax.

Re:Oberon-2, a hi-performance alternative to C++ (1997) by Rochus on Tuesday January 24, 2023 @10:40PM (#34514119)
I just implemented a parser based on the Lisa Pascal 3 specification (see 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.
Re:Oberon-2, a hi-performance alternative to C++ (1997) by musicale on Tuesday January 24, 2023 @10:51PM (#34514197)
> 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 Addr = packed record
        case Integer of
           0: (addr: Integer);
           1: (ptr: ^Something);
    end;
    ...
    function printAddressOf(somethingPtr);
    var somethingPtr: ^Something;
        ptr: Addr;
    begin
       ptr.ptr = somethingPtr;  { copy its pointer }
       writeln('Something was allocated at ', ptr.addr);
    end;
(Apologies for any errors - I don't write Pascal very often.)

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 things including pointer arithmetic, custom memory allocators, garbage collectors, (unsafe) type casts, etc..

Re:Oberon-2, a hi-performance alternative to C++ (1997) by Rochus on Wednesday January 25, 2023 @08:12AM (#34517836)
There were indeed loopholes in variant records you could misuse for all kinds of tricks, and Wirth was aware of these and finally replaced the concept by type extension. Instead of "not possible" I should better have stated "not officially supported". My point was instead, that Lisa Pascal added concepts, which were official part of the language specification, from which we can conclude, that (also) from the view of Apple original Pascal was not suited for the endeavor. Others came to the same conclusion (see e.g. the famous paper by Kernighan), and even Wirth added features similar to the ones found e.g. in Lisa Pascal to his Modula-2 language.
Re:Oberon-2, a hi-performance alternative to C++ (1997) by musicale on Wednesday January 25, 2023 @04:13PM (#34524254)
If you want to pick nits, many C and C++ programs and OS kernels also rely on technically undefined and implementation/machine-specific behavior.

From which I suppose we can conclude that C/C++ without undefined behavior has been found to be unsuitable for systems programming. Or that systems programs tend to be non-portable by nature.

Perhaps a more charitable conclusion is that languages like Wirth Pascal and K&R C (for example) contain loopholes and unsafe/technically undefined behavior which can be useful for systems programming but problematic for memory safety and security/reliability.

Sadly Pascal standardization seems to have stalled after ISO Extended Pascal in 1991, while C is still evolving into C23.

Re:Oberon-2, a hi-performance alternative to C++ (1997) by Rochus on Wednesday January 25, 2023 @04:43PM (#34524587)
All languages have loopholes; even Oberon has at least one, in the type case statement (uncovered by C. Szyperski).
Re:Oberon-2, a hi-performance alternative to C++ (1997) by musicale on Wednesday January 25, 2023 @04:35PM (#34524505)
> from which we can conclude, that (also) from the view of Apple original Pascal was not suited for the endeavor

Another conclusion might be that Apple started with UCSD Pascal (which was available for the Apple II and already included extensions to standard Pascal) and that they thought that certain extensions were useful even if they weren't technically necessary.

Clearly the Lisa didn't need Clascal or Object Pascal (the Macintosh didn't require them), but they provide advantages in terms of conciseness, modularity, reusability, etc..

Re:Oberon-2, a hi-performance alternative to C++ (1997) by musicale on Tuesday January 24, 2023 @11:15PM (#34514339)
> I just implemented a parser based on the Lisa Pascal 3 specification

cool!

> So far I only saw two of the ~350 Lisa OS source files looking like Clascal (both from the Lisa toolkit)

Have you looked for instances of SELF in the Lisa Toolkit and app sources?

Anything that is SELF.foo is a Clascal instance variable or instance method reference in a method. You can also use with SELF do... to make it more implicit like C++ or Java.

Also look for METHODS OF, SUPERSELF, CREATE, etc..

Re:Oberon-2, a hi-performance alternative to C++ (1997) by Rochus on Wednesday January 25, 2023 @09:25AM (#34518572)
I'm still troubled by the fact that I don't have implemented the preprocessor yet and the code is cluttered over hundereds of .txt files with diverse content (i.e. many modules are parceled to several .txt files). But from what I have seen so far some units in the Lisa_os seem indeed to be Clascal (estimated 5%).
Re:Oberon-2, a hi-performance alternative to C++ (1997) by musicale on Wednesday January 25, 2023 @04:08PM (#34524201)
It appears that the Lisa OS kernel is primarily straight Pascal and that Clascal is mainly used in the toolkit and apps (which are of course the most interesting bit of the Lisa.)
Re:Oberon-2, a hi-performance alternative to C++ (1997) by Rochus on Wednesday January 25, 2023 @12:15PM (#34521071)
Please also note that I'm talking about the Lisa OS (subfolder LISA_OS in the source code ZIP), not the Lisa Toolkit (subfolder Lisa_Toolkit in the source code ZIP).

It's actually not a surprise I see some Clascal files in the Lisa OS tree since LIBTK in LISA_OS/LIBS is apparently just a copy of the Lisa Toolkit.

Re:Oberon-2, a hi-performance alternative to C++ (1997) by HarHarVeryFunny on Wednesday January 25, 2023 @08:52AM (#34518204)
UCSD Pascal is as much a regression/subset of (Jensen &) Wirth Pascal as an evolution of it. It did add things like a function "exit" (cf return) keyword, string type and separately compiled units, but on the other hand it only supported local goto, and didn't bother to implement dispose(), instead opting for an odd stack-based mark() and release() scheme (i.e. there was no way of freeing an individual item allocated with new()).

The USCD P-System spec is here, for anyone interested:

http://pascal.hansotten.com/uploads/ucsd/ucsd/UCSD_PASCAL_II...

Re:Oberon-2, a hi-performance alternative to C++ (1997) by musicale on Wednesday January 25, 2023 @04:43PM (#34524574)
That's very interesting. Another vote for Wirth Pascal, which I think is an underappreciated language!

Modules are good though - hence Units, Modula-2/3, Oberon, etc..

Re:Oberon-2, a hi-performance alternative to C++ (1997) by pmontra on Tuesday January 24, 2023 @11:09PM (#34514302)
Pascal 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.
Re:Oberon-2, a hi-performance alternative to C++ (1997) by kmoser on Tuesday January 24, 2023 @11:46PM (#34514520)
Modula-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.
Re:Oberon-2, a hi-performance alternative to C++ (1997) by bhaak on Wednesday January 25, 2023 @04:56AM (#34516494)
> 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.

Re:Oberon-2, a hi-performance alternative to C++ (1997) by MarcusE1W on Wednesday January 25, 2023 @08:11AM (#34517815)
I 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