Remarkable that Bill is interested in a version of Oberon-07. It's even more minimalistic than the previous Oberon versions. I spent a lot of time with the original Oberon language versions and experimented with extensions to make the language more useful for system programming (e.g. https://oberon-lang.github.io/ and https://github.com/rochus-keller/oberon/). Eventually I had to give up backward compatibility to get to a language which I really consider suitable for system programming (and still minimal in the spirit of Oberon, see https://github.com/micron-language/specification/ and https://github.com/rochus-keller/micron/); it's still evolving though.
If I get it right, Bill's language is considered for teaching purpose, which is also a goal of Wirth's languages, and for which these languages are well suited (especially for compiler courses). Also note that the name "Oberon" was not inspired by Shakespeare, but by the Voyager space probe's flyby and photography of Uranus's moons during the mid-1980s when the language was being developed (see https://people.inf.ethz.ch/wirth/ProjectOberon/PO.System.pdf page 12).
gingerBill 45 minutes ago [-]
Please note the project isn't even 24 hours old yet.
But I am using Oberon-07 as base, and I might deviate from it quite soon too. But I won't be going in the direction of things like Oberon+ (which adds generic and OOP programming) or Micron which adds the entire type system necessary to interact with foreign code. I just wanted something to explain to people how to do tokenizing, parsing, semantic checking (not just basic types), and machine code generation, and this seemed like the best language to choose.
n.b. I know the name does comes from from the Voyager space probe, but I wanted to keep it directly related somehow, and Titania was the best fit. It's also a moon of Uranus, and there is a story relation to Oberon (Fairy King).
Rochus 38 minutes ago [-]
Supporting lowercase keywords and making (at least some) semicolons optional already makes Oberon much more attractive ;-)
gingerBill 27 minutes ago [-]
And removing unnecessary keywords and modernizing it too. `[N]T` for arrays and `^T` for pointers, rather than `array N of T` and `pointer of T`. And supporting C++ style code `/*/` and `//`.
And as I develop this, I'll tweak it more so that people can actually understand without having to know the full histories of Pascals or Oberons or whatever.
Rochus 21 minutes ago [-]
I have also implemented these and other simplifications in my languages, and I don't think it makes them any less readable. Looking forward to seeing your final design.
Lerc 8 hours ago [-]
Having done a fair degree of programming in Wirthwhile languages, I think the only main design decision that I think was a mistake was the variables at the top.
I'm not sure of the value of seeing all of the variables used listed in one place, it has certainly led to me encountering a identifier scrolling up to determine the type then scrolling back down. When the variable is only used on a few consecutive lines it's just adding work to read and adding work to create. I daresay I have written harder to read code than I intended because I didn't want to go up and declare another variable for short term use. The temptation to inline the expression is always there, because you know what all the parts mean when you write it. It's only when you come back later that you get the regret.
It's possible it could be mitigated by defining something like (not sure if this is a valid grammar)
and bring in scoping on statement sequences. maybe call it stmt_block so that stmt_sequence can be a component that really is just a sequence of statements.
munificent 5 hours ago [-]
> I'm not sure of the value of seeing all of the variables used listed in one place
It means the compiler knows how much memory the function's activation frame will take and the offset into that for every variable before it encounters any code in the function.
Basically, it makes it easier to write a single-pass compiler. That was important in the 70s but is less important these days.
Rochus 1 hours ago [-]
This design decision makes compiler implementation easier and especially enables single-pass compilation. Later Oberon versions at least supported more than one declaration section in arbitrary order, but still no in-place declarations.
gingerBill 2 hours ago [-]
When I write the backend (this repo isn't even 24 hours old yet), you'll find out why variable declarations are at the top of a procedure. (Hint: it has something to do with the stack).
troupo 53 minutes ago [-]
Wirth was obsessed with the idea of creating the absolutely minimal useful language, and many of his languages' warts come from that.
Variables are at the top because:
- you immediately see them (so, perhaps, easier to reason about a function? I dunno)
- the compiler is significantly simplified (all of Wirths' languages compile superfast and, if I'm not mistaken, all are single-pass compilers)
However, I feel that Wirth was overly dogmatic on his approaches. And "variables must always be at the top" is one of those.
foldl2022 7 hours ago [-]
A nice side-effect of "variables at the top": you keep your functions short.
Turskarama 6 hours ago [-]
"Functions should always be short" is also one of those guidelines that people treat like a hard rule. There are occasions when a 100 line function is easier to read than 5 20 line functions, or god forbid 20 5 line functions.
Stop being overly dogmatic, it ALSO leads to worse code.
gingerBill 2 hours ago [-]
This repo isn't even 24 hours old yet and it's on HackerNews...
Just wow....
smartmic 1 hours ago [-]
Is the language/project somehow related to Odin or its ecosystem, or is it completely independent?
If the latter, I wonder how you can manage another programming language alongside Odin — anyway, thank you and great respect for both!
gingerBill 43 minutes ago [-]
Completely independent of Odin (except being written in Odin). It's a plan to be a teaching tool to learn compiler development, that's it.
ivanjermakov 1 hours ago [-]
Not surprising, it appeared in 1.3k github feeds of your followers.
geokon 3 hours ago [-]
> teach compiler development with
Not trying to be confrontational,
genuinely curious..
but why is this an area where you'd want a DSL?
My initial reaction is : When I'm learning a topic,
the last thing I want to be worrying about is learning the ergonomics of a new language
I'm guessing there's a good rational I'm missing
it'd be nice to see some piece of compiler related code in this language that'd be ugly in a general purpose language
rubystallion 17 minutes ago [-]
He's the author of Odin, so he has experience writing compilers, so he also wrote a toy compiler in his language as a fun weekend project I guess. Of course it's only a good learning resource for people familiar with Odin. I don't know much about Odin, but from glancing at the code it looks like there are some memory management related features that he's using, which would look uglier in other languages.
wiz21c 47 minutes ago [-]
I have teached Pascal 25 years ago. The idea was to teach the basic principles of programming (loops, variables, arrays, linked lists, sorting, etc.) without worrying about the technical details (C was too tricky, python was not there). Plus Pascal is quite simple and has very few pitfalls.
Once students where proficient in Pascal, we could introduce compiler classes and, when sufficiently advanced, show what the Pascal BNF grammar looked like. So students had a complete picture of a language. Pascal's BNF grammar is very simple.
Also, Pascal enforces strong program structures (BEGIN, END, PROCEDURE, FUNCTION, etc). which helps to frame practical work.
gingerBill 2 hours ago [-]
Oberon is a general-purpose programming language, not a DSL. Even though it is very minimal, you can still do quite a bit in it.
But the point of teaching compiler development is to teach people how to do the basic things from tokenizing, parsing, semantic checking, and code generation (directly to machine code).
I have found this is actually a skill most programmers don't even know how to do, especially just tokenizing and parsing, so I thought I'd use Oberon-07 as a base/inspiration for it.
n.b. at the time of this comment, the repo/project is not even 24 hours old yet.
__d 11 hours ago [-]
Clever name.
It'd be nice to see some discussion of the motivation for its departures from Oberon07.
jasperry 8 hours ago [-]
Very nice project, I'm a big fan of implementing Wirthian languages to learn compilers.
Also, in true Wirth style, the documentation mainly consists of the language grammar :)
gingerBill 1 hours ago [-]
The project is not even 24 hours old...
And I might plan on making this a recorded series of explaining how to make compilers from scratch with this language as a reference.
Rochus 1 hours ago [-]
> the documentation mainly consists of the language grammar :)
It's a bit more than just the grammar, but I agree it's generally underspecified.
loumf 10 hours ago [-]
Looking at your source, I was introduced to Odin -- now I want to hear a lot more about that.
khaledh 9 hours ago [-]
He is also the creator of Odin :)
Panzerschrek 3 hours ago [-]
We need more context. Why Odin's creator created yet another programming language?
ruslan 10 hours ago [-]
No pointers ?
doug-moen 9 hours ago [-]
from the grammar:
> pointer_type = "^" type.
fijiaarone 10 hours ago [-]
A modest proposal…
Instead of having println() or it’s equivalent in your programming language, add a new special character that denotes a newline after a string:
print(“Hello world”.)
Jtsummers 8 hours ago [-]
Is your idea that that would always work? Like:
s := "Hello world".; -- equivalent to "Hello world\n"
Or only in `print`? If only in `print`, then you've suddenly made a context-sensitive grammar. And if the former, just use "Hello world\n" instead, since the tokenizer already supports that.
keithnz 6 hours ago [-]
I think the point is to add the correct end of line depending on OS.
kouteiheika 27 minutes ago [-]
The correct end of line is always '\n'. Even Windows' Notepad supports it nowadays. I will gladly die on this hill. :P
coderedart 9 hours ago [-]
That would mess with dot syntax usually reserved for method calls. Like rust's "hello".to_string();
cxr 9 hours ago [-]
Oberon doesn't have string methods (and people who opt not to parenthesize for cases like that deserve the punishment).
If I get it right, Bill's language is considered for teaching purpose, which is also a goal of Wirth's languages, and for which these languages are well suited (especially for compiler courses). Also note that the name "Oberon" was not inspired by Shakespeare, but by the Voyager space probe's flyby and photography of Uranus's moons during the mid-1980s when the language was being developed (see https://people.inf.ethz.ch/wirth/ProjectOberon/PO.System.pdf page 12).
But I am using Oberon-07 as base, and I might deviate from it quite soon too. But I won't be going in the direction of things like Oberon+ (which adds generic and OOP programming) or Micron which adds the entire type system necessary to interact with foreign code. I just wanted something to explain to people how to do tokenizing, parsing, semantic checking (not just basic types), and machine code generation, and this seemed like the best language to choose.
n.b. I know the name does comes from from the Voyager space probe, but I wanted to keep it directly related somehow, and Titania was the best fit. It's also a moon of Uranus, and there is a story relation to Oberon (Fairy King).
And as I develop this, I'll tweak it more so that people can actually understand without having to know the full histories of Pascals or Oberons or whatever.
I'm not sure of the value of seeing all of the variables used listed in one place, it has certainly led to me encountering a identifier scrolling up to determine the type then scrolling back down. When the variable is only used on a few consecutive lines it's just adding work to read and adding work to create. I daresay I have written harder to read code than I intended because I didn't want to go up and declare another variable for short term use. The temptation to inline the expression is always there, because you know what all the parts mean when you write it. It's only when you come back later that you get the regret.
It's possible it could be mitigated by defining something like (not sure if this is a valid grammar)
and bring in scoping on statement sequences. maybe call it stmt_block so that stmt_sequence can be a component that really is just a sequence of statements.It means the compiler knows how much memory the function's activation frame will take and the offset into that for every variable before it encounters any code in the function.
Basically, it makes it easier to write a single-pass compiler. That was important in the 70s but is less important these days.
Variables are at the top because:
- you immediately see them (so, perhaps, easier to reason about a function? I dunno)
- the compiler is significantly simplified (all of Wirths' languages compile superfast and, if I'm not mistaken, all are single-pass compilers)
However, I feel that Wirth was overly dogmatic on his approaches. And "variables must always be at the top" is one of those.
Stop being overly dogmatic, it ALSO leads to worse code.
Just wow....
If the latter, I wonder how you can manage another programming language alongside Odin — anyway, thank you and great respect for both!
Not trying to be confrontational, genuinely curious.. but why is this an area where you'd want a DSL?
My initial reaction is : When I'm learning a topic, the last thing I want to be worrying about is learning the ergonomics of a new language
I'm guessing there's a good rational I'm missing
it'd be nice to see some piece of compiler related code in this language that'd be ugly in a general purpose language
Once students where proficient in Pascal, we could introduce compiler classes and, when sufficiently advanced, show what the Pascal BNF grammar looked like. So students had a complete picture of a language. Pascal's BNF grammar is very simple.
Also, Pascal enforces strong program structures (BEGIN, END, PROCEDURE, FUNCTION, etc). which helps to frame practical work.
But the point of teaching compiler development is to teach people how to do the basic things from tokenizing, parsing, semantic checking, and code generation (directly to machine code).
I have found this is actually a skill most programmers don't even know how to do, especially just tokenizing and parsing, so I thought I'd use Oberon-07 as a base/inspiration for it.
n.b. at the time of this comment, the repo/project is not even 24 hours old yet.
It'd be nice to see some discussion of the motivation for its departures from Oberon07.
Also, in true Wirth style, the documentation mainly consists of the language grammar :)
And I might plan on making this a recorded series of explaining how to make compilers from scratch with this language as a reference.
It's a bit more than just the grammar, but I agree it's generally underspecified.
> pointer_type = "^" type.
Instead of having println() or it’s equivalent in your programming language, add a new special character that denotes a newline after a string:
print(“Hello world”.)