Rendered at 16:47:36 GMT+0000 (Coordinated Universal Time) with Cloudflare Workers.
giancarlostoro 1 hours ago [-]
Odin is one I've run into when looking at modern systems languages that seems interesting. Imagine a funny blend of Go and Rust, but somewhere in the middle? Someone will rip my head off probably, but that's how it looks like to me so far, haven't deep dived it, but it does seem interesting. It's goal is to be closer to C or C++ but modern, so the niceness of Go being able to compile instantly, I do see that it is used with game engines a bit, so it's definitely got its own niche.
boltzmann64 1 days ago [-]
i love odin.
- manual memory management
- arena and pool allocators
- go style err!=nill style exception handling
- first class support for soa and vectorized simd, linear algebra and swizzling
if you haven't heard of odin, you should definitely consider it.
jazzypants 1 days ago [-]
> - go style err!=nill style exception handling
Is this not widely considered to be the ugliest part of the language? Why do you prefer having to do this manually?
iaaan 23 hours ago [-]
As someone who is primarily a Go dev, I never understood this criticism and have never seen a language do it any better (but I'm open to suggestions). I think try/catch is worse. I kinda like JS's promise syntax with the `.then()` and `.catch()`, but it doesn't appear that different to Go's approach.
sn9 21 hours ago [-]
Returning Result/Options that the compiler forces you to check so you can't forget.
Common in ML-family languages and Rust. They've been brought into most mainstream languages like Java by now because of how useful they are.
wahern 15 hours ago [-]
You don't necessarily need a result/option type. Go could add a dependent typing facility that let you express a relationship between the first and subsequent return values.
Very few languages do that; an option type is simpler to implement in many respects. But in the case of Go, especially at this juncture, it's possible the simplest route is a dependent type, at least a specialized one. You don't need to introduce a fully generic dependent typing facilty.
Even simpler would just be type qualifers, e.g. optional or nilable, on the first return value, though that doesn't help with multivalue returns, where a simple dependent typing facility could fully express success vs error return semantics.
You could also do it with contracts, though more obliquely. One of the criticisms with C++ contracts was that a contract made it easier to optimize a routine for the declared relationships, but without absolutely mandating enforcement that the callee or caller also obeyed the contracts, which is more difficult to do. That meant there was the potential for contracts to result in more bugs caused by interactions between undefined behavior and the optimizer.
HeavyRain266 20 hours ago [-]
Odin has @(require_results) that forces you to do something with returned values (e.g. T, Maybe(T), (T, bool))
Where Maybe is a polymorphic union of T and nil but the core library returns either (T, bool) or (T, E) where E is an error enum.
iaaan 19 hours ago [-]
Ahhhh, got it: enforced correctness. Fair enough, I can definitely see the benefit of that. I do wish Go had more ways to do that, like first-class enum support, exhaustive switch cases, and, yeah, forced error handling. golangci-lint does a lot of this heavy lifting on behalf of the Go compiler, but it would be nice to have the compiler enforce it.
slifin 18 hours ago [-]
I hope that doesn't mean the compiler inherits the extra work
I'm considering glojure as an interesting new hobby language to try because it's benchmarks are impressive
If the go compiler ends up bloating itself with checks its static analyser could/should have done it would be a shame
iaaan 11 hours ago [-]
I mean that I run an external CLI tool called golangci-lint (a linter), and it does some things that the compiler arguably should do instead.
vips7L 22 hours ago [-]
Personally I think Go style is worse, because the runtime and compiler don't force you to handle the error. I just had to fix a critical issue because a dev forgot to check the result coming from a function, exceptions would have forced it to happen.
Tadpole9181 20 hours ago [-]
> I kinda like JS's promise syntax with the `.then()` and `.catch()`, but it doesn't appear that different to Go's approach.
These days async/await is first-class and the function-based callback form of promises is largely discouraged. And for, at least in part, the same reason: it's harder to enforce correctness.
ixwt 1 days ago [-]
It is, which is why the or_return[1] keyword was created.
In only one of those examples do you get a T that's invalid.
childintime 4 hours ago [-]
Some patterns, notably when a reasonable default can be provided, are better handled in Go. In such a case the error handling can often be omitted entirely. Neither Rust or Go recognize this pattern explicitly, however. In Go, as your comment, the function signature doesn't say the result value is actually a valid default when there is an error.
segfaltnh 21 hours ago [-]
True, Go does require you to follow a convention here (dont use T if err is not nil). In practice it works pretty well, though obviously not bullet proof.
I believe some exceptional languages are similar, like Ruby. If you rescue but dont abort, the variable on the left hand side gets a nil when that may otherwise not be possible. Of course, that is handled cleanly as its own error.
vips7L 21 hours ago [-]
I don't see how. Unless it's the Go example where you get (nil, err)?
12345hn6789 17 hours ago [-]
Yes it is and it's frankly odd we are still designing languages this way. It's a mess and a Result with typed errors is much more ergonomic and should be the standard. See either in scala for more.
sham1 8 hours ago [-]
I see your Either types and raise you a checked exception. People might have soured on the idea due to the way Java specifically implements the idea, but they can absolutely be done properly. They're also more ergonomic than an Either type, so that's nice.
I guess I have to justify my last statement, so here goes. We need to first establish the fact that checked exceptions and an Either type used in error handling are isomorphic constructs. Both are part of your type system (there is no difference between a function returning an `Either<T, E>` and a function returning a `T` or throwing an exception `E`), although one could correctly argue that an Either type is more widely applicable. Okay, so error handling ergonomics. The main thing about exceptions is that they separate out your happy path code from error handling. This is often a physical separation via having separate blocks with a try and a catch. You can of course have this kind of separation with an Either type, but at least in my experience the ergonomics are such that it's often nicer to just have the error boundary close to the fallible expression. Either that, or you have to start doing stack unwinding until you find an appropriate place for error handling -- except unlike with exceptions, this unwinding is done by hand.
Another thing that most exception systems give you are post-operations, usually in the form of some sort of a `finally` type dealio. And yeah, you can absolutely do the same thing with Either-based error handling, but it's not nearly as ergonomic as a finally-block.
And if people get annoyed at these being called exceptions, because they're not always exceptional, then we could call them something like "error conditions" or whatever floats one's banana, that's just bikeshedding.
The place where Java went wrong with its checked exceptions was two-fold:
a) you can't parameterise properly over the exceptions you get thrown
b) whether an exception is checked or not is a property of its place in the class hierarchy instead of being separate from it
A large part of the first one is due to generics being added after the fact to the language, trying to preserve backwards compatibility which also lead to the kind of type erasure etc. you get in Java. And the second one is mostly just a mistake in the design of the exception hierarchy. Sadly that's now impossible to fix in Java specially so we're stuck with it, but other languages could still learn from it.
christophilus 1 days ago [-]
LLMs are pretty good at it, too. I recently had Haiku rewrite all of my Quickshell Linux UIs (dux) to Odin + an immediate mode GUI library: launcher, Niri bar, WiFi manager, process manager, lock screen, HUD audio/brightness, etc. Did all but the process manager in a day, while I was spending 99% of my time paying attention to my day job.
Anyway, Odin is my favorite of the new systems languages. Lightweight, ergonomic, decent stdlib. It’s quite good.
christophilus 22 hours ago [-]
For the record, the library I used was Skald[0]. It's decent. Not 100% fully featured yet, but performant and fairly low resource, especially compared to Quickshell.
What's the decision-making in choosing Odin over something similar like C3 or Zig?
Verdex 24 hours ago [-]
I can't speak for the implementor. And for that matter I also don't know what facilities c3 and zig provide.
However Odin comes prepackaged with a lot of bindings for helpful 3rd party libraries. Likely makes this sort of work a lot less tedious.
vconnor 23 hours ago [-]
I have tried all three, and I chose Odin because I prefer the syntax (especially over Zig) and the vendored libraries are a killer feature for me. You get a lot of graphics, maths and gamedev-adjacent packages with the language, that can take you very far without having to shop for third-party packages.
Odin for me is the (low level) systems language nirvana, along with Elixir which is my distributed system nirvana. They spark so much joy.
fuzztester 18 hours ago [-]
maybe stability or completeness?
C3 and Zig are still evolving. Not sure about Odin. Check it.
varispeed 19 hours ago [-]
Why not just use C?
sitzkrieg 15 hours ago [-]
odin is way more ergonomic than any c standard
Panzerschrek 12 hours ago [-]
> manual memory management
Ergo memory leaks.
> arena and pool allocators
A poor's man replacement for RAII.
> go style err!=nill style exception handling
Literally the most criticized part of Go.
> first class support for defer statements
Again, defer is used, because there is no RAII.
> consider it
No, thanks. I will continue using Rust or even C++. I don't want wasting time debugging memory leaks and corruptions.
boltzmann64 10 hours ago [-]
there is definitely a tradeoff here: would you rather hunt for memory leaks or hunt for references (to satisfy the borrow checker).
some of really want to do it the old way with arena/pool allocators than guarantees at the compile time. odin's target audience is not rust programmers, it's C programmers who want modern conveniences.
phplovesong 23 hours ago [-]
Did not C3 basically render Odin useless? Its basically C that did not stagnate in the mid 90s.
ternaryoperator 10 hours ago [-]
C3, Odin, Zig, and many other languages are all competing to be the ergonomic replacement for C. None of them has crossed the chasm to wide industry adoption, so there is not one of these that, to use your words, renders the others useless...yet.
AdmiralAsshat 1 days ago [-]
It's always interesting when the article title betrays the author's origins. I assume the author speaks British English rather than American English, because they tended to pronounce "NES" and "SNES" as acronyms ("Ness" and "Sness"), while we Americans tended to treat them as initialisms ("En-ee-ess"). So to my American eyes, I would have expected "An NES emulator" instead of "A NES emulator."
dwb 23 hours ago [-]
I always heard it “nez” and “snez” actually (south western England)
masfuerte 21 hours ago [-]
And in the Midlands. Ness is Nessie's home.
forgotpwd16 1 days ago [-]
Could also be native vs non-native English speaker. Especially in computing world, it's common for non-native English speakers to utilize American spelling/punctuation while grammar/pronunciation is influenced by their native language. This appears in this post, and, arguably, even the title. In many languages (incl. Spanish, probably author's native language) acronyms are read phonetically.
hobo123 20 hours ago [-]
I've also read people refer to the "Super Nintendo".
My friends and I in Germany always called them Nes and Super Nes.
lucypero 3 hours ago [-]
I didn't write "an" because I was thinking "A Nintendo Entertainment System emulator..." or "a [ness] emulator....". But now you peeps made me overthink this...
HeavyRain266 23 hours ago [-]
Author is Argentinian, I guess they teach British English in schools out there.
cubefox 23 hours ago [-]
Yeah in Argentina they probably teach the kids that NES is pronounced "ness" during English lessons.
lucypero 3 hours ago [-]
Actually, in Argentina we call this console system "La family", probably because in Japan it's called "Family Computer" or Famicom.
cubefox 2 hours ago [-]
> The Family Game [a Famicom clone] was manufactured by the Argentine company Electrolab S.A.[41][42] They distributed Super Family Electrolab Ending-Man (based on Ending-Man Terminator clone) and Electrolab Family Game with official distribution of Supervision.[43] At the peak of its popularity, its sales amounted 95% of the argentinian console market.[44]
The hardware from this era is always super interesting. Having circuitry in cartridges + in the console is wild when you think about it.
Nice to see other languages being used :)
Dwedit 17 hours ago [-]
How does Odin compare with C++, Zig, or Beef?
andyfilms1 17 hours ago [-]
C-like performance with a lot of modern conveniences and fairly straightfoward syntax. Lots of vendored libraries included. Makes worse burgers than beef.
fuzztester 18 hours ago [-]
Related: What are other C-like or systems programming languages other than Odin, Zig, C3 and Hare?
I have checked out all 4 some, only by reading the docs and examples so far.
Uneasy about Zig because of docs lagging code, and syntax.
Hare is Linux only. Doable, but prefer Windows too.
Need to try Odin.
Other interesting langs in this space whih are at a somewhat usable state, including docs and libs? I don't need a package manager or an LSP or much other tooling.
For now this is just for developing small apps of my own.
reilly3000 22 hours ago [-]
Among all of those interesting learnings, I suspect they will soon be learning the legal code too. Nintendo of America defends its IP ferociously and too excess.
luxurytent 22 hours ago [-]
What can Nintendo do if someone builds an emulator?
segfaltnh 21 hours ago [-]
Yeah this is true all the other emulator authors are in jail.
Source: onion article
debo_ 22 hours ago [-]
Yes, Nintendo famous for hunting down hobbyist NES emulators. Give me a break.
anthk 1 days ago [-]
Odin needs too recent LLVM versions to work. A pity this Reticulum client it's written on that,
because if it were written in Go it would be instantly portable to legacy machines:
On Odin itself, it looks really simple, and I'd love it
if it were self-bootstrapable or compilable with just
a C99 compiler like cparser, cproc or TCC.
- manual memory management
- arena and pool allocators
- go style err!=nill style exception handling
- first class support for soa and vectorized simd, linear algebra and swizzling
- sanely typed and namespaces
- explicit unambigious overloading, subroutine context
- first class support for defer statements
- zero friction C ffi
if you haven't heard of odin, you should definitely consider it.
Is this not widely considered to be the ugliest part of the language? Why do you prefer having to do this manually?
Common in ML-family languages and Rust. They've been brought into most mainstream languages like Java by now because of how useful they are.
Very few languages do that; an option type is simpler to implement in many respects. But in the case of Go, especially at this juncture, it's possible the simplest route is a dependent type, at least a specialized one. You don't need to introduce a fully generic dependent typing facilty.
Even simpler would just be type qualifers, e.g. optional or nilable, on the first return value, though that doesn't help with multivalue returns, where a simple dependent typing facility could fully express success vs error return semantics.
You could also do it with contracts, though more obliquely. One of the criticisms with C++ contracts was that a contract made it easier to optimize a routine for the declared relationships, but without absolutely mandating enforcement that the callee or caller also obeyed the contracts, which is more difficult to do. That meant there was the potential for contracts to result in more bugs caused by interactions between undefined behavior and the optimizer.
Where Maybe is a polymorphic union of T and nil but the core library returns either (T, bool) or (T, E) where E is an error enum.
I'm considering glojure as an interesting new hobby language to try because it's benchmarks are impressive
If the go compiler ends up bloating itself with checks its static analyser could/should have done it would be a shame
These days async/await is first-class and the function-based callback form of promises is largely discouraged. And for, at least in part, the same reason: it's harder to enforce correctness.
[1]: https://odin-lang.org/docs/overview/#or_return-operator
I believe some exceptional languages are similar, like Ruby. If you rescue but dont abort, the variable on the left hand side gets a nil when that may otherwise not be possible. Of course, that is handled cleanly as its own error.
I guess I have to justify my last statement, so here goes. We need to first establish the fact that checked exceptions and an Either type used in error handling are isomorphic constructs. Both are part of your type system (there is no difference between a function returning an `Either<T, E>` and a function returning a `T` or throwing an exception `E`), although one could correctly argue that an Either type is more widely applicable. Okay, so error handling ergonomics. The main thing about exceptions is that they separate out your happy path code from error handling. This is often a physical separation via having separate blocks with a try and a catch. You can of course have this kind of separation with an Either type, but at least in my experience the ergonomics are such that it's often nicer to just have the error boundary close to the fallible expression. Either that, or you have to start doing stack unwinding until you find an appropriate place for error handling -- except unlike with exceptions, this unwinding is done by hand.
Another thing that most exception systems give you are post-operations, usually in the form of some sort of a `finally` type dealio. And yeah, you can absolutely do the same thing with Either-based error handling, but it's not nearly as ergonomic as a finally-block.
And if people get annoyed at these being called exceptions, because they're not always exceptional, then we could call them something like "error conditions" or whatever floats one's banana, that's just bikeshedding.
The place where Java went wrong with its checked exceptions was two-fold:
a) you can't parameterise properly over the exceptions you get thrown b) whether an exception is checked or not is a property of its place in the class hierarchy instead of being separate from it
A large part of the first one is due to generics being added after the fact to the language, trying to preserve backwards compatibility which also lead to the kind of type erasure etc. you get in Java. And the second one is mostly just a mistake in the design of the exception hierarchy. Sadly that's now impossible to fix in Java specially so we're stuck with it, but other languages could still learn from it.
Anyway, Odin is my favorite of the new systems languages. Lightweight, ergonomic, decent stdlib. It’s quite good.
[0] https://github.com/BuLEEto/Skald
However Odin comes prepackaged with a lot of bindings for helpful 3rd party libraries. Likely makes this sort of work a lot less tedious.
Odin for me is the (low level) systems language nirvana, along with Elixir which is my distributed system nirvana. They spark so much joy.
C3 and Zig are still evolving. Not sure about Odin. Check it.
Ergo memory leaks.
> arena and pool allocators
A poor's man replacement for RAII.
> go style err!=nill style exception handling
Literally the most criticized part of Go.
> first class support for defer statements
Again, defer is used, because there is no RAII.
> consider it
No, thanks. I will continue using Rust or even C++. I don't want wasting time debugging memory leaks and corruptions.
some of really want to do it the old way with arena/pool allocators than guarantees at the compile time. odin's target audience is not rust programmers, it's C programmers who want modern conveniences.
My friends and I in Germany always called them Nes and Super Nes.
https://en.wikipedia.org/wiki/Famiclone#Argentina
Nice to see other languages being used :)
I have checked out all 4 some, only by reading the docs and examples so far.
Uneasy about Zig because of docs lagging code, and syntax.
Hare is Linux only. Doable, but prefer Windows too.
Need to try Odin.
Other interesting langs in this space whih are at a somewhat usable state, including docs and libs? I don't need a package manager or an LSP or much other tooling.
For now this is just for developing small apps of my own.
Source: onion article
https://github.com/Quad4-Software/Ren-TUI
Reticulum in Go:
https://github.com/Quad4-Software/Reticulum-Go
On Odin itself, it looks really simple, and I'd love it if it were self-bootstrapable or compilable with just a C99 compiler like cparser, cproc or TCC.