4 ms·
Not to brag -- hum, ok, YES, to brag --, but Dusk's Oberon compiler[1][2] is less than 1500 lines of Forth code and it compiles directly to native code (no tran
by vdupras 1y ago
Not to brag -- hum, ok, YES, to brag --, but Dusk's Oberon compiler[1][2] is less than 1500 lines of Forth code and it compiles directly to native code (no transpiling to C). Yes, Oberon is simple.
[1]: https://git.sr.ht/~vdupras/duskos/tree/master/item/fs/doc/comp/oberon.txt https://git.sr.ht/~vdupras/duskos/tree/master/item/fs/doc/co...
[2]: https://git.sr.ht/~vdupras/duskos/tree/master/item/fs/comp/oberon https://git.sr.ht/~vdupras/duskos/tree/master/item/fs/comp/o...
- jll29 1y agoThanks for sharing. Yes, compare that to the smallest possible, ISO-compliant burst laughing C++ compiler implementation in any language... Complicated means "likely full of errors that are hard to identify"...
- nurettin 1y agoEarly 2000s, compiler authors basically had to guess how types resolved and implement what made most sense. One week did not pass without filing a new kind of internal compiler error to gcc (well, I was lazy so I kept filing to debian). The specs improved immensely in the past 20 years. So much so that you can actually implement the entire grammar from the spec and the order of type resolution is well known. You could cut corners by ignoring every "compiler hint" and optional optimization that is left for the implementation to get things going, then go back and finish those.
- Rochus 1y agoCool. Which version of the Oberon language does it support?
- vdupras 1y agoI'm guessing we call it Oberon-07? The one from "The Programming Language Oberon", written in 2007, revised in 2016. As the documentation states, it's not 100% on specs, for a better fit with Dusk interoperability, but it's very close. 100% specs compliance wouldn't affect implementation size by much.
- Rochus 1y agoOk, I see, thanks; so it's the same version as implemented in OBNC posted above. It's the last version Wirth specified, and quite different from the versions used for the Oberon systems 2, 3 and 4 in the nineties. Personally I consider Oberon-2 the most useful version, but I still had to get rid of a lot of orthodoxies to really use it in my projects (see https://github.com/rochus-keller/Oberon https://github.com/rochus-keller/Oberon). Your Forth implementation is fascinating.
- bobsh 1y agoWow! I have been in a potentially unhealthy love relationship with Oberon (especially the -07 version, once it appeared) since the mid 1990s. It has no basis in reality, my obsession, that I am aware of. But, so, on the one hand, I "get it" about Oberon. And, also, Forth - very long time Forth fan here! But, but, why, for DUSK, are you doing this? I hope you have the coolest frickin' reasons ever! :-)
- vdupras 1y agoTo port Oberon itself to Dusk. The effort is already well underway[1]. I'm of the opinion that the architecture of Oberon, w.r.t. to its graphical user interface, is sound. Dusk so far only has a console-based interface, Oberon is going to give it a GUI. To borrow your words, yes it's going to be frickin' cool. [1]: https://git.sr.ht/~vdupras/duskos/tree/master/item/fs/doc/oberon.txt https://git.sr.ht/~vdupras/duskos/tree/master/item/fs/doc/ob...
- Rochus 1y agoThe Oberon system version corresponding to Oberon-07 (see http://www.projectoberon.net/ http://www.projectoberon.net/) is not really a "GUI" and very bare-bone compared to previous Oberon system versions. Wirth mainly wanted to implement his own computer including CPU using an FPGA; to reduce his effort he left out many things from the past. You could have a look at https://github.com/rochus-keller/OberonSystem3 https://github.com/rochus-keller/OberonSystem3 instead which indeed has a GUI with an Oberon based widget framework; the referenced implementation should be easy to port to your OS (see ObxPal.obx).
- vdupras 1y agoMy taste for minimalism are a bit on the extreme side. Dusk OS isn't really about having a GUI, but graphical applications such as a PDF viewer are part of its design goals. I was planning on not having a Desktop Environment at all and just have graphical applications use the whole screen, but I was intrigued by Viewers and Texts architecture. Their fundamental simplicity is rather elegant and I feel that mixing this with Forth's own radically simple elements, there's something quite powerful to be had. I'm not sure yet how it will materialize, but I still have that feeling. I'm not really looking to write new graphical applications for Dusk, so I'm not planning on ever needing a Oberon-based gadget framework. The idea behind Dusk is to port existing applications onto a radically simpler platform (compared to your typical POSIX) with a minimal effort, not to write new software.
- trealira 1y agoThanks for sharing that. I've actually been learning some Forth recently and had been wondering how a parser or a compiler might actually look using Forth, and you actually already made one, which is pretty cool. I was wondering this because deterministic parsers are often already stack based (LL and LR parsers can both be implemented as imperative programs that manipulate a stack based on the input tokens, or just recursive descent). I still can't really understand everything just from reading the code, but I had assumed it would be some kind of explicitly stack-based state machine precedence parser, like this article describes: https://h14s.p5r.org/2014/10/shiftreduce-expression-parsing-by-douglas-gregor.html https://h14s.p5r.org/2014/10/shiftreduce-expression-parsing-... Kind of looks like you did that in expr.fs? Not completely sure, though.
- vdupras 1y agoI'm not of the academic type and this type of vocabulary quickly loses me. Lots of words to describe something that, at its core, is pretty simple. Mind twisting, but simple. Infix notation parsing happens in ast.fs[1]. It parses tokens left to right and builds a tree (the structure is Lisp-like cons) describe the expression in such a way that expr.fs[2] then just has to recursively process the top tree node to have proper codegen. In other words, operator precedence, prefix/postfix operators, etc. are all considered in ast.fs. Once in expr.fs is reached, all those things have been processed. AST tests[3] give a good example of what ast.fs does. I'm not sure I'd say that Forth being stack-based particularly help there. This logic is more "recursive-based" than anything. Lots of recursion all around. [1]: https://git.sr.ht/~vdupras/duskos/tree/master/item/fs/comp/oberon/ast.fs https://git.sr.ht/~vdupras/duskos/tree/master/item/fs/comp/o... [2]: https://git.sr.ht/~vdupras/duskos/tree/master/item/fs/comp/oberon/expr.fs https://git.sr.ht/~vdupras/duskos/tree/master/item/fs/comp/o... [3]: https://git.sr.ht/~vdupras/duskos/tree/master/item/fs/tests/comp/oberon/ast.fs https://git.sr.ht/~vdupras/duskos/tree/master/item/fs/tests/...
- trealira 1y agoThanks for explaining and giving me an overview of your code. I guess I was overly focused on Forth being stack based, when it's also perfectly capable of processing trees recursively. Yeah, I just think parsers are really cool, and have read enough about different parsing algorithms that I'm used to vocab like that.
- RetroTechie 1y agoGreat work there! As for Dusk OS: are there release tarballs/.zips or such anywhere available for download? (like for Collapse OS) All I'm seeing is a reference to "target a release", which (I'm assuming) refers to some git function? Hoping to bypass the need for using git just to download & check archive's contents.
- vdupras 1y agoSourcehut provides targz bundles for tags: https://git.sr.ht/~vdupras/duskos/refs https://git.sr.ht/~vdupras/duskos/refs
- RetroTechie 1y agoAh.. I overlooked those "refs" links. Thx!