4 comments

  • sidkshatriya5 hours ago
    I like Odin and hope for it to gain more momentum.<p>I have an important metric for new &quot;systems&quot; languages: does the language allow NULL for it&#x27;s commonly used pointer type. Rust by default does not (References may _not_ be NULL). Here is where I think Odin makes a mistake.<p>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&#x27;s documentation to see what the contract is).<p>In Rust, if a function returns &amp;File or &amp;mut File or Box&lt;File&gt; etc. I know that it will never be NULL.<p>So Odin repeats the famous &quot;billion-dollar mistake&quot; (Tony Hoare). Zig in comparison is bit more fussy about NULL in pointers so it wins my vote.<p>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.
    • rtpg3 hours ago
      One thing I think worth considering for systems languages on this point: if you don&#x27;t want to solve every expressiveness issue downstream of Result&#x2F;Option&#x2F;etc from the outset, look at Swift, which has nullable types.<p>MyObject can&#x27;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.<p>To people who would dismiss ADTs as a hard problem in terms of ergonomics: Rust makes it less miserable thanks to things like the question-mark shorthand and a bazillion trait methods. Languages like Haskell solve it with a monads + do syntax + operating overload galore. Languages like Scala _don&#x27;t_ solve it for Result&#x2F;Option in any fun way and thus are miserable on this point IMHO
      • tialaramex1 hour ago
        I like to think about how many problems a feature solves to judge whether it&#x27;s &quot;worth it&quot;. I believe that the Sum types solve enough different problems that they&#x27;re worth it, whereas nullability solves only one problem (the C-style or Java-style null object) the Sum types can solve that with Option&lt;T&gt; and also provide error handling with Result&lt;T, Err&gt; and control flow with ControlFlow&lt;Continue, Break&gt; among others so that&#x27;s already a better deal.<p>Nullability is a good retro-fit, like Java&#x27;s type erased generics, or the DSL technology to cram a reasonable short-distance network protocol onto the existing copper lines for telephones. But in the same way that you probably wouldn&#x27;t <i>start</i> with type erased generics, or build a new city with copper telephone cables, nullability isn&#x27;t worth it for a new language IMO.
      • noelwelsh2 hours ago
        The Scala solution is the same as Haskell. for comprehensions are the same thing as do notation. The future is probably effect systems, so writing direct style code instead of using monads.<p>It&#x27;s interesting that effect system-ish ideas are in Zig and Odin as well. Odin has &quot;context&quot;. There was a blog post saying it&#x27;s basically for passing around a memory allocator (IIRC), which I think is a failure of imagination. Zig&#x27;s new IO model is essentially pass around the IO implementation. Both capture some of the core ideas of effect systems, without the type system work that make effect systems extensible and more pleasant to use.
      • _flux2 hours ago
        I personally don&#x27;t enjoy the MyObject? typing, because it leads to edge cases where you&#x27;d like to have MyObject??, but it&#x27;s indistinguishable from MyObject?.<p>E.g. if you have a list finding function that returns X?, then if you give it a list of MyObject?, you don&#x27;t know if you found a null element or if you found nothing.<p>It&#x27;s still obviously way better than having all object types include the null value.
        • lock11 hour ago
          Well, in a language with nullable reference types, you could use something like<p><pre><code> fn find&lt;T&gt;(self: List&lt;T&gt;) -&gt; (T, bool) </code></pre> to express what you want.<p>But exactly like Go&#x27;s error handling via (fake) unnamed tuple, it&#x27;s very much error-prone (and return value might contain absurd values like `(someInstanceOfT, false)`). So yeah, I also prefer language w&#x2F; ADT which solves it via sum-type rather than being stuck with product-type forever.
        • ecedeno49 minutes ago
          Your example produces very distinguishable results. e.g. if Array.first finds a nil value it returns Optional&lt;Type?&gt;.some(.none), and if it doesn&#x27;t find any value it returns Optional&lt;Type?&gt;.none<p>The two are not equal, and only the second one evaluates to true when compared to a naked nil.
    • leecommamichael4 hours ago
      Odin offers a Maybe(T) type which might satisfy your itch. It&#x27;s sort of a compromise. Odin uses multiple-returns with a boolean &quot;ok&quot; value for binary failure-detection. There is actually quite a lot of syntax support for these &quot;optional-ok&quot; situations in Odin, and that&#x27;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&#x2F;API boundaries, but in practice I haven&#x27;t chosen to use it in Odin.
      • sidkshatriya3 hours ago
        All the standard libraries use naked ^T .<p>Maybe(T) would be for my own internal code. I would need to wrap&#x2F;unwrap Maybe at all interfaces with external code.<p>In my view a huge value addition from plain C to Zig&#x2F;Rust has been eliminating NULL pointer possibility in default pointer type. Odin makes the same mistake as Golang did. It&#x27;s not excusable IMHO in such a new language.
        • tialaramex1 hour ago
          Both Odin and Go have the &quot;zero is default&quot; choice. Every type <i>must</i> have a default and that&#x27;s what zero signifies for that type. In practice some types shouldn&#x27;t have such a default, so in these languages that zero state becomes a sentinel value - a value notionally of this type but in fact invalid, just like Hoare&#x27;s NULL pointer, which means anywhere you didn&#x27;t check for it, you mustn&#x27;t assume you have a valid value of that type. Sometimes it is named &quot;null&quot; but even if not it&#x27;s the same problem.<p>Even ignoring the practical consequences, this means the programmer probably doesn&#x27;t understand what their code does, because there are unstated assumptions all over the codebase because their type system doesn&#x27;t do a good job of writing down what was meant. Almost might as well use B (which doesn&#x27;t have types).
  • apitman3 hours ago
    Anyone have a good comparison of Odin vs C&#x2F;C++&#x2F;Rust&#x2F;Zig&#x2F;Hare&#x2F;etc? I&#x27;m particularly interested in how simple it is to implement a compiler in the given language.
  • gethly5 hours ago
    I&#x27;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&#x27;s just a personal preference. I don&#x27;t think I ever used fully procedural language in my entire life. It requires a complete rewiring on one&#x27;s brain. Which I&#x27;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&#x27;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.<p>PS: I just read a funny comment on YT video: &quot;Odin feels like a DSL for writing games masquerading as a systems language.&quot;
    • messe5 hours ago
      &gt; even Zig has methods and interfaces<p>Zig doesn&#x27;t have interfaces as a language level feature. It uses manually implemented vtables and wrapper methods.<p>You can do the same in Odin with wrapper functions around a vtable.
      • gethly1 hour ago
        I have not looked much into it. Someone mentioned it once, so i just remembered it.
      • leecommamichael5 hours ago
        There&#x27;s even syntax-sugar for it in Odin with the `-&gt;` operator.
        • tialaramex19 minutes ago
          This gets you dynamic dispatch, roughly via the C++ route (inline vtables in implementing types). This means you must always pay for this on the types which provide it, even if you rarely use the feature, removing those vtables makes it unavailable everywhere.<p>A lot of programmers these days want static dispatch for its ergonomic value and Odin doesn&#x27;t help you there. Odin thinks we should suck it up and write alligator_lay_egg_on(gator, egg, location) not gator.lay_egg_on(egg, location)<p>If we decide we&#x27;d prefer to type gator-&gt;lay_egg_on(egg, location) then Odin charges us for a vtable in our Alligator type, which we didn&#x27;t need or want, and then we incur a stall every time we call that because we need to go via the vtable.
        • messe3 hours ago
          Oh, nice. I have to admit I&#x27;m not all that familiar with Odin, because I&#x27;ve been all-in on Zig for a long time. I&#x27;ve been meaning to try out a game dev project in Odin for a while though, but haven&#x27;t had the time.
    • sitzkrieg2 hours ago
      i&#x27;m kinda glad it&#x27;s lacking typical webdev stuff at the moment. if nothing else for developers focus. its absolutely excellent for game development. i have written 2 complete games in odin and working on a third. all using just vendor raylib and absolutely flying. build time, language server, debug cycles. i complete entire features every session, very productive language. i look forward to its maturity
      • gethly1 hour ago
        I think Odin should market itself for aforementioned games and graphics. Otherwise it will become very niche language. Even now, I think there is only about 5k Odin repositories on github while it is essentially a complete language. Contrast it with Zig, which is still evolving and has breaking changes, being still at 0.x without clear sight of 1.0, and it has over 27k repositories and big projects like Ghostty, Bunt or Tiger beetle are written in it.<p>Once Jonathan Blow&#x27;s Jai comes out next year, the language that inspired conception of both of these, Odin will likely have no chance competing on the marketing side of things with programmers and will be taken over by Jai, and Zig in a large extent as well. So the future of the language might not be as solid as it might seem and it might end up just as an internal tool for JangaFX, which is how it originated.<p>Having the &quot;web stuff&quot; can attract literally millions of developers whom can elevate the language into more stable and broadly used language. More documentation would become available, libraries, youtube videos, internet presence in general.
        • _bohm4 minutes ago
          &gt; the language that inspired conception of both of these<p>I haven’t heard this before. Do you have a source on this?
    • enigma1011 hour ago
      lot&#x27;s of what you say is simply not true. Maybe before sharing opinions educate oneself.
  • MangoToupe5 hours ago
    Odin claims to be pragmatic (what language doesn&#x27;t lol) but &quot;All procedures that returned allocated memory will require an explicit allocator to be passed&quot;. Charitably, is this aimed at c&#x2F;zig heads?
    • messe5 hours ago
      &gt; All procedures that returned allocated memory will require an explicit allocator to be passed<p>All procedures in core&#x2F;os. Odin isn&#x27;t removing the allocator from implicit context in the rest of its APIs.
    • BigJono5 hours ago
      I&#x27;m guessing it&#x27;s aimed at game development since Vulkan has a similar pattern in every function call (although optional, the driver does it&#x27;s own allocation if you pass null).
      • astrange4 hours ago
        That&#x27;s a pretty heavyweight pattern. Wouldn&#x27;t dynamic scope be better?
    • ycombinatrix3 hours ago
      How do you allocate memory without an allocator?
    • leecommamichael5 hours ago
      All you&#x27;ve got to do is write `context.allocator` to abide.