OBNC Oberon Compiler
miasap.se
miasap.se
One question I haven't researched enough is, how did the people at ETH Zürich used Oberon for OS programming. AFAIK, all Wirthian languages have garbage collection, and the common narrative is that you cannot use a GC'ed language in an OS kernel. How did Wirth et al. work around this in the Oberon OS family?
https://www.inf.ethz.ch/personal/wirth/ProjectOberon/Sources...
The exposed procedures (exposed symbols have a star after their name in their declaration) are New (it is treated in a special way by the compiler to remain type safe even if the language itself wouldn't allow it normally), Mark and Scan. It seems that it uses a block allocator that the garbage collector uses itself privately. These procedures use special "GET"and "PUT" procedures which are translated to raw memory access by the compiler (these are also used to access the hardware which is memory mapped). A test for garbage collection is called periodically as seen below (check PROCEDURE GC):
https://www.inf.ethz.ch/personal/wirth/ProjectOberon/Sources...
The collection occurs either when the system is in low memory or some countdown is reached (set by a call to Collect, although looking at the code it seems other bits can change it too).
The rest of the OS just uses the above facilities.
There are many examples of system programming languages, used to implement OSes with GC at kernel level.
- Interlisp-D/Lisp Machines
- Smalltalk
- Mesa/Cedar
- Modula-2+
- Modula-3
- Oberon, Oberon-2, Active Oberon, Component Pascal, Oberon-07
- Sing# and System C#
- D
The only problem is having a company willing to put enough money so that the naysayers don't have other option other than adopting the platform.
However given the short sight of business regarding roadmaps, there isn't a company willing to go full speed on it.
So we get the half-way solution, with Swift, Android, UWP, ChromeOS, .NET. The kernels might not have a GC, but almost everything on userspace is done in GC enabled languages.
Yeah, but are there any examples of "system programming languages, used to implement OSes with GC at kernel level" where said OSes are fast, practical, and used by way more people and businesses than 100 researchers and hard core fans?
Or IoT deployments from Oberon Systems and Astrobe, with Astrobe still focused on selling Oberon compilers for embedded development.
As mentioned, it is always a matter of money and business willingness.
Joe Duffy mentions on his Rustconf talk how his team had to deal with lots of Luddites, even though they had Midori running in front of them.
If the likes of Apple, Google and Microsoft were willing to spend the same money as they did/are making JavaScript JIT compiliers fast, we would already get something in mainstream.
Instead they focus on the easy path, closing down the kernel access, and making the userspace available to GC only languages.
Well, I think this falls in the "researchers and hard core fans" of my range.
Then again I am used to people not believing in a future with modern safe OSes.
No, they were just forced to use it for the researchers to prove a point.
Nothing about this speaks to its practically and success. Is it still in use in that organization? If not, why not?
Was it fast enough? Did it actually crash less or just under different conditions? Did it make it easy to connect and use the huge existing ecosystem of code available for other major OSes? Did it have hangups unique to it?
>Then again I am used to people not believing in a future with modern safe OSes.
Well, "belief" is not that scientific or pragmatic a criterion, is it?
All those answers are available on relevant papers.
A few decades ago a company believed JavaScript could be made into a fast language and here we are.
Midori was a very real OS, not welcomed by management, that is hardly a scientific criterion.
I have feeling that Go is a Modula-2/Pascal with a garbage collector and may be with a better concurrency story. Would that be a fair assessment ?
However you should look into Active Oberon, where active objects are similar to co-routines. Messages are passed around active objects via message handlers.
https://oberoncore.ru/_media/wiki/lang/reali_p.active_oberon...
As the influence for channels, though, they mention Alef.
The diagram is on page xii of the publicly available preview: http://www.gopl.io/ch1.pdf
If you need dynamic allocation in such sections, you can still do so as long as you set safety limits to ensure sufficient memory will be available, or e.g. let the latency critical code allocate from separate parts of the heap or using a different allocation scheme (e.g. pre-allocated arenas).
There are lots of details to get right, but the "common narrative" basically assumes you're not able to disable the collector when you want to and no way of safely pre-empting the collector. But making it possible to selectively disable a GC and ensure your latency critical code can safely do so is fairly straightforward.
OS do not consist only of a kernel (nitpicking, sorry). Oberon hides the low-level functionality in special modules where implementations are provided by the compiler (in assembly language if needed), i.e. „builtins“. In other words, what is part of the kernel in e.g. Linux can be implemented as a language feature (system module) in the compiler and the resulting code can run on „bare metal“.
[Prior to edit:] Modula-3 had nothing to do with Modula-3 though.
Modula-3 is the evolution of Mesa/Cedar, after the researchers went to DEC and created Modula-2+, an improved version of Mesa/Cedar.
They collaborated with Wirth on their work.
"The design of the programming language Modula-3 was a joint effort by the Digital Systems Research Center and the Olivetti Research Center, undertaken with the guidance and inspiration of Niklaus Wirth."
What?
The next thing you can do is use lightweight formal methods, static analysis, etc on the unsafe code. So, those primitives are verified in unsafe HLL or in assembly. You know they'll probably act right given preconditions are met. Then, the rest of code is protected by type- and memory-safety. Combining best tool for each job makes your whole system safe despite unsafe code.
One person I know had a successful test of using SPARK Ada for fast, otherwise-unsafe components of Go applications. My Brute-Force Assurance idea would likely, given most use C language underneath, do these in Frama-C compiled with CompCert or C0 after I threw every static/symbolic analyzer, concurrency checker, and fuzzer at it. Very unlikely to have trouble out of anything that passes all that if the spec or mental model itself is correct. Rest is safe, memory-managed code. It also helps to keep same data types, calling conventions, and so on to prevent abstraction-gap attacks. There's ongoing work on abstraction-safe, verified integration of components in different languages, though.
Also, note that you can use different memory managers in different apps or even parts of an app. The runtime has to be designed to do that. JX OS in Java is one that is. There are GC's optimized for throughput, average latency, hard real-time, size, and so on. A standard allocator gives the code a block to use, they assign to or divide it up for the other GC's, and they work from there. There might also be some work to do on scheduling how they run, too. I can't remember how easy or difficult that is on a common platform. It was mostly done on custom OS's.
Darwin itself is mostly unix+C. Hence, this does not respond to the parent, asking about GC in the OS itself.
You're right, but just to clarify WRT your first paragraph, Obj-C did briefly have a GC'd runtime between the eras of manual and automatic ref counting.
Although it was possible to link frameworks compiled in mixed modes, it lead most of the time to crashs and the C semantics did not help.
Hence the pragmatic solution of ARC, which basically has the compiler inserting the retain/release calls that used to be done manually.
While not the same, it was a good enough solution.
https://developer.apple.com/documentation/foundation/object_...
I see a problem with mapping SYSTEM to unsafe, though, as unsafe is not as feature rich.
Not Pascal at least and I don't think Modula has it either.
ALGOL-W, Pascal, Modula 2 (and probably the original Modula) did not have GC as part of the base language or library.
But Worse is Better - https://www.dreamsongs.com/WorseIsBetter.html
I studied those things when they came out, but I have forgotten most of it.