Odin: Moving Towards a New "core:OS"

(odin-lang.org)

49 points | by ksec 5 days ago

4 comments

  • sidkshatriya 2 hours ago
    I like Odin and hope for it to gain more momentum.

    I have an important metric for new "systems" languages: does the language allow NULL for it's commonly used pointer type. Rust by default does not (References may _not_ be NULL). Here is where I think Odin makes a mistake.

    In the linked blog post Odin mentions ^os.File which means pointer to File (somewhat like *FILE in C). Theoretically the pointer can be NULL. In practice, maybe I would need to check for NULL or maybe I would not (I would have to scan the Odin function's documentation to see what the contract is).

    In Rust, if a function returns &File or &mut File or Box<File> etc. I know that it will never be NULL.

    So Odin repeats the famous "billion-dollar mistake" (Tony Hoare). Zig in comparison is bit more fussy about NULL in pointers so it wins my vote.

    Currently this is my biggest complaint about Odin. While Odin packages a lot of power programming idioms (and feels a bit higher level and ergonomic than Zig) it makes the same mistake that Golang, C and others make regarding allowing NULL in the default pointer type.

    • rtpg 0 minutes ago
      One thing I think worth considering for systems languages on this point: if you don't want to solve every expressiveness issue downstream of Result/Option/etc from the outset, look at Swift, which has nullable types.

      MyObject can't be null. MyObject? can be null. Handling nullability as a special thing might help with the billion-dollar mistake without generating pressure to have a fully fleshed out ADT solution and everything downstream of that.

    • leecommamichael 1 hour ago
      Odin offers a Maybe(T) type which might satisfy your itch. It's sort of a compromise. Odin uses multiple-returns with a boolean "ok" value for binary failure-detection. There is actually quite a lot of syntax support for these "optional-ok" situations in Odin, and that's plenty for me. I appreciate the simplicity of handling these things as plain values. I see an argument for moving some of this into the type-system (using Maybe) when it comes to package/API boundaries, but in practice I haven't chosen to use it in Odin.
      • sidkshatriya 42 minutes ago
        All the standard libraries use naked ^T .

        Maybe(T) would be for my own internal code. I would need to wrap/unwrap Maybe at all interfaces with external code.

        In my view a huge value addition from plain C to Zig/Rust has been eliminating NULL pointer possibility in default pointer type. Odin makes the same mistake as Golang did. It's not excusable IMHO in such a new language.

  • gethly 2 hours ago
    I've been actively toying with Odin in past few days. As a Gopher, the syntax is partially familiar. But as it is a lower level language wiht manual-ish memory management, simple things require much more code to write and a ton of typecasting. Lack of any kind of OOP-ism, like inheritance(bad), encapsulation(ok), or methods(nobrainer), is very spartan and unpleasant in 2025, but that's just a personal preference. I don't think I ever used fully procedural language in my entire life. It requires a complete rewiring on one's brain. Which I'd say is a huge obstacle for most programmers, definitely from the younger crowd. For low-level guys, this is quite a nice and powerful tool. For everyone else, it's a bit of a head ache(even Zig has methods and interfaces). The language still lacks basic things like SQL drivers, solid HTTPS stack, websockets, and essentially anything related to web and networking(which has the bare bones functionality). As a Gopher, I am biased, but the web rules the world, so it is objective complaint. In the end, this is a solid language with great support for 2D and 3D graphics and advanced mathematics, which naturally makes it a very niche language for making games or anything to do with visual programming. Definitely try it out.

    PS: I just read a funny comment on YT video: "Odin feels like a DSL for writing games masquerading as a systems language."

    • messe 2 hours ago
      > even Zig has methods and interfaces

      Zig doesn't have interfaces as a language level feature. It uses manually implemented vtables and wrapper methods.

      You can do the same in Odin with wrapper functions around a vtable.

      • leecommamichael 1 hour ago
        There's even syntax-sugar for it in Odin with the `->` operator.
        • messe 39 minutes ago
          Oh, nice. I have to admit I'm not all that familiar with Odin, because I've been all-in on Zig for a long time. I've been meaning to try out a game dev project in Odin for a while though, but haven't had the time.
  • apitman 34 minutes ago
    Anyone have a good comparison of Odin vs C/C++/Rust/Zig/Hare/etc? I'm particularly interested in how simple it is to implement a compiler in the given language.
  • MangoToupe 2 hours ago
    Odin claims to be pragmatic (what language doesn't lol) but "All procedures that returned allocated memory will require an explicit allocator to be passed". Charitably, is this aimed at c/zig heads?
    • ycombinatrix 1 minute ago
      How do you allocate memory without an allocator?
    • BigJono 2 hours ago
      I'm guessing it's aimed at game development since Vulkan has a similar pattern in every function call (although optional, the driver does it's own allocation if you pass null).
      • astrange 1 hour ago
        That's a pretty heavyweight pattern. Wouldn't dynamic scope be better?
    • messe 2 hours ago
      > All procedures that returned allocated memory will require an explicit allocator to be passed

      All procedures in core/os. Odin isn't removing the allocator from implicit context in the rest of its APIs.

    • leecommamichael 2 hours ago
      All you've got to do is write `context.allocator` to abide.