r/ProgrammingLanguages • u/badd10de • Mar 19 '26
The Oni Programming Language
Hello folks, I've been lurking here for a while and I think I'm finally ready to share Oni, my personal programming language.
Been working on it since 2021 and it underwent a number of iterations and evolutions, starting off as a Lisp and morphing into a low-level Algol-like language. It is self-hosted and easily bootstrapable. The current backend emits C11 code and I've been using it almost exclusively for all my hobby projects for a while now, including some experiments with audio DSP stuff, and PlayDate console development. I'm very proud of it and wrote it mostly for myself, not looking for it to gain a lot of users, but I would be happy to help any folks who would like to try it :)
The lispy roots remain, and while there are infix operators now, most things require a keyword prefix. It supports generics, methods and ADTs. Additionally, it's highly compatible with C and can interop bidireccionally (C -> Oni and Oni -> C). In its current form it aims to be a "high-level C" kind of in the same vein as C is a "high-level assembler", and there are some compiler directives to directly emit C code or modify code generation in several ways, which is handy to make bindings to C libraries.
The standard library is small and practical, with some basic generic data structures built-in, will grow as needed. The convention in the stdlib is to pass Allocator objects for any operation that requires manual memory management. There are also some IO.Reader and IO.Writer interfaces and a text formatter system that works a bit differently to the usual printf stuff.
Another goal was to be able to override the standard library as needed on a per-project basis, for example, if you want to override the stdlib `panic` function, which is used in several places of the stdlib.
Here is the current manuscript for the language reference for more details:
https://git.sr.ht/~badd10de/oni-lang/tree/main/item/docs/language_ref.md
I'll try to work on a nice simple website landing page in the near future.
Looking forward to see your feedback :)
11
u/AustinVelonaut Admiran Mar 19 '26
This looks very nice; congratulations on your project! Having it be self-hosted shows that the implementation is pretty robust. What was the hardest problem you encountered when developing it? What was the most interesting?
4
u/Real_Dragonfruit5048 Mar 19 '26
Cool! What's the namesake? (It reminds me of the Onimusha video game series.)
3
u/vanderZwan Mar 19 '26
How does
oni-runwork? Does it compile, run and then delete the C output? Or do you have an interpreter of your language?1
u/Botahamec Mar 23 '26
Very cool. I especially like what you did with raw strings.
I'm curious how much of Lisp still exists in the language internally. I had an idea at one point of writing a shell that used various syntactic sugars on top of Lisp to look more like a scripting language. From the examples I saw, it looked nothing like Lisp, which makes me think that most of the Lisp origin is gone.
1
u/fdwr Mar 24 '26
Interesting, a language with both
letandsetin its vocabulary. There is a linguistic poetic symmetry to it. I also considered (hobby language) using@for pointers, feeling like @x would mean the address of x.The postfix dereference makes sense to me, and I've thought it would have made C simpler in ways (e.g.
p*.xwould work directly instead of needing parentheses wrapped around it like(*p).x, a or separate arrowp->x).I appreciate the no-semicolons, because it's always felt silly when you get a compiler error like "expected ; here", which makes me think, "ok, if you're smart enough to know that's the end of the statement, then treat it like the end of the statement" 😉. I've written C++ for 20 years now, and I still occasionally forget that stupid semicolon after a
classstatement. Not sure how I feel about using it for comments though (despite being used to it for x86 asm and ini files, it feels odd in a higher level language)Thank you for going with a readable fragment rather than a devoweled 'fn', because functions are more fun with u than without u 😉. Also I kinda like the aesthetic of the next statement lining up with the indentation.
Nice. It's so useful for one-off cleanup where you don't want to invent a whole scope guard thingie just to use RAII (seems you did it the clearer way too, just based on scope like the C TS and zig, rather than go's deferred accumulation list that waits until function exit).
Needing to declare the methods outside the class definition is kinda annoying because one has to repeat the class name over again, but on the flip side, it's nice to be able to re-open the scope and add more (useful for partial classes).
The closing braces help my eyes see the logical block structure more clearly than asymmetric languages do (there's also a balanced feeling to it).
Yeah, I like it. 👹
-12
u/porky11 Mar 19 '26
Most important: The documentation is visually not appealing.
Generally, C and Lisp are the most important inspirations for my own minimal language.
I just skimmed it, doesn't look like anything special to me. Also you took some of the annyoing c baggage with you like
void.At least you have a
funkeyword, allowing search for functinos, which seems important to me. And you have some Rust enums, which is nice.I prefer the Rust keywords like
fnforfunorimplformethods.