Remix.run Logo
▲ jdswain 6 hours ago

I've got a long-term project of building an Oberon compiler. Oberon is a language in the Pascal family, the newest language from Wirth, and an attempt to remove any unnecessary features from his languages, indeed he went a little too far in some early versions of Oberon and restored a feature or two in successive versions.

Mostly I've learnt a lot from building a compiler, in particular the back-end which I didn't have much experience with. But also I've started using Oberon more and more. My compiler targets the 65C816 processor, but I ended up porting the front-end to LLVM so that I had native oberon, and used it to build a number of tools, an emulator, and actually the compiler (there was a C intermediate step).

In the end I've started to really like Oberon, and I don't miss much from more modern languages. I did add some extensions so I have a very simple form of object-orientation, and used it to implement a UI toolkit similar to AppKit, but much simpler. Some of the modern language features add more complexity than they give in benefits. And sometimes it's just better to write code than learn a new language feature or library.

Plus it's a very readable language.

▲whartung 2 hours ago | parent | next [-]

> My compiler targets the 65C816 processor

Of all things...

I also have a (unpublished) '816 focused language and compiler (me and the AI).

I'm keeping it pretty conservative, as the goal is to rewrite the compiler in itself, and have it self-host. But a fellow posted this [1] about "Micron", an Oberon inspired system language.

And I'm giving a keen eye to how it handles Interfaces. I'm not sure if it will really fit, but it's an interesting idea that should be reasonably cheap on the compiler, and have no impact on the runtime.

I must say having an introspective CPU simulator as part of your unit tests can really help with writing a compiler. Not only can you test that the code is generating what it's supposed to, you can test that the code actually does what it’s supposed to.

[1] https://news.ycombinator.com/item?id=50413266

▲jdswain 2 hours ago | parent [-]

I also had the goal of self hosting, and that is working, although I have made it a little easier on myself by extending the 65C816 in some small ways. The most significant for the compiler is a small extension to the registers so that the direct page and stack can be located anywhere in memory. This is primarily to allow larger operating system and app images, the compiler is quite large now so it needs this. I have a limit of 64k for each module.

One breakthrough in the compiler was when I could start to use AI to interpret instruction traces, before that I was doing it by hand and it took a very long time. Now the AI pinpoints my errors very quickly, although I'm past that stage now and don't often come across compiler errors. I do this with an emulator, also written in Oberon.

▲pjmlp 5 hours ago | parent | prev | next [-]

Which version though?

While my interest got spiked initially by the original Project Oberon, I was more found of the paths taken by Component Pascal and Active Oberon, as language evolution.

Anyway, it was what initially opened my eyes to systems programming with GC enabled languages, and drew me into the rabbit hole of Cedar, Modula-2+, Modula-3 and co.

▲wormius 3 hours ago | parent | next [-]

Was Active Oberon the foundation of A2/Bluebottle? My memory fails me.

I haven't dug into Oberon, because it's not quite Pascal enough for me to love it, and felt a bit heavier than I had hoped for syntax wise.

I'm enjoying Odin lately, and if I felt i had more time/use for Oberon I'd probably try driving it. But feel that as a "living" project Odin is more usable, it feels more constrained in syntax and concision than the larger Oberon project.

This is similar to like Genera/Lisp Machines, where I'd love to explore more (and even plan9, though that's less related to OS/Language integration in the way Bluebottle/A2 and Genera/Lisp Machines.

▲jdswain an hour ago | parent | prev [-]

[dead]

▲giancarlostoro 5 hours ago | parent | prev | next [-]

Oberon is definitely an interesting language, and there's a few self-hosting compilers coded in Oberon itself in under 6 thousand lines of Oberon.

▲vintagedave 5 hours ago | parent | prev | next [-]

If a language features adds more in complexity than benefits, it doesn't feel very Wirth-ian (Oberon or Pascal.)

What features do you have in mind?

▲dapperdrake 5 hours ago | parent [-]

Floating point for GUIs is a rare and important exception. Compilers rarely need floating point.

▲Rochus 5 hours ago | parent | prev [-]

> indeed he went a little too far in some early versions of Oberon and restored a feature or two in successive versions

Actually the most minimalistic version is the one he made for his retirement project, Oberon-07. Oberon-2 (by Mössenböck et al.) had most features. My Oberon+ is a superset of all (original) Oberon versions.