NHacker Next
  • new
  • past
  • show
  • ask
  • show
  • jobs
  • submit
▲A NES emulator written in Odin (lucypero.com)
typicode 56 minutes ago [-]
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 :)

boltzmann64 7 hours 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

- 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.

jazzypants 6 hours 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 4 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 3 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.

iaaan 11 minutes 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.
HeavyRain266 2 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.

vips7L 3 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 1 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 6 hours ago [-]
It is, which is why the or_return[1] keyword was created.

[1]: https://odin-lang.org/docs/overview/#or_return-operator

wolttam 4 hours ago [-]
Errors as values instead of some special language construct is generally a nice thing (IMO)
vips7L 4 hours ago [-]
Exceptions are values. There's nothing different between:

    T someFn() throws E;
    fn someFn() -> Result<T, E>;
    func someFn() (T, E)
Dr_Emann 3 hours ago [-]
In only one of those examples do you get a T that's invalid.
segfaltnh 2 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 2 hours ago [-]
I don't see how. Unless it's the Go example where you get (nil, err)?
christophilus 7 hours 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 3 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.

[0] https://github.com/BuLEEto/Skald

varispeed 11 minutes ago [-]
Why not just use C?
DASD 6 hours ago [-]
What's the decision-making in choosing Odin over something similar like C3 or Zig?
vconnor 5 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.

Verdex 5 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.

phplovesong 5 hours ago [-]
Did not C3 basically render Odin useless? Its basically C that did not stagnate in the mid 90s.
AdmiralAsshat 6 hours 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."
hobo123 2 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.

forgotpwd16 6 hours 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.
dwb 5 hours ago [-]
I always heard it “nez” and “snez” actually (south western England)
masfuerte 2 hours ago [-]
And in the Midlands. Ness is Nessie's home.
HeavyRain266 4 hours ago [-]
Author is Argentinian, I guess they teach British English in schools out there.
cubefox 4 hours ago [-]
Yeah in Argentina they probably teach the kids that NES is pronounced "ness" during English lessons.
anthk 7 hours 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:

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.

reilly3000 4 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 3 hours ago [-]
What can Nintendo do if someone builds an emulator?
segfaltnh 2 hours ago [-]
Yeah this is true all the other emulator authors are in jail.

Source: onion article

debo_ 3 hours ago [-]
Yes, Nintendo famous for hunting down hobbyist NES emulators. Give me a break.
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
Rendered at 22:15:08 GMT+0000 (Coordinated Universal Time) with Vercel.