Odin, a Pragmatic C Alternative with a Go Flavour by hmac1282
Odin is a general-purpose systems programming language authored by Bill “gingerBill” Hall.
Designed as a modern alternative to C, Odin emphasizes simplicity, performance, and readability
without sacrificing control over low-level details.
The website says it’s “data-oriented”, and features such as SOA (structs-of-arrays) and implicit zero initialization tie into that. Despite this focus, the language surprisingly has dynamic
maps and arrays built into the language itself. While the memory is still manually managed,
it’s uncommon to see such built-ins.
This perhaps sets the tone of Odin: it tries to be ergonomic and easy to write by offering a lot out of the box. Odin also comes with “vendor”, containing bindings to a wide variety of popular libraries. This makes the language very easy to get into.
Design Philosophy
Odin focuses on practical solutions to real-world programming challenges—in other words, it favours pragmatism over idealism (I’ll return to this when I later discuss Zig). Rather than introducing complex features, Odin focuses on code that is simple and clean to read and reason about. This is the polar opposite of Zig’s embracing of metaprogramming for as much as possible.
Odin also has a fairly old-fashioned view of types. The current trend is to make programming languages increasingly more complex so that they can describe more and more types in the language itself. Odin instead harkens back to older languages where built-in types flourished. Consequently, Odin does not just offer the aforementioned hashmaps and dynamic arrays, but also numerical types
such as complex numbers, vectors, matrices, and even quaternions. This makes up for its rejection of operator overloading by a wide margin. It’s not a coincidence that the flagship app to demonstrate Odin’s capabilities, EmberGen, is a math- and graphics-heavy tool.
A quick look at the syntax
Odin has a fairly straightforward syntax for a beginner. The fact that there is no excessive nagging about mutability or constness makes things just work as expected.
The declaration is otherwise very inspired by Jai and fairly minimal. Odin’s concession to modern fashion shows up in its removal of the traditional ;
.
Odin produces code anyone used to C or other low level languages can read at a gl
18 Comments
WhereIsTheTruth
I like odin a lot, however, there are two things that just don't stick with me, and i ended up quitting:
– RTTI: just give me compile time type introspection and let me disable RTTI without making the language unusable
– when/import: just let me wrap an import inside a when block, being forced to split my file in 3 made me quit the language
pbohun
I've started experimenting with Odin for some personal projects and it's been great. The built-in vendored libraries make creating certain programs trivial. For example, just `import rl "vendor:raylib"` and you can use `rl.InitWindow(800,600,"Test")`. No need to install Raylib, add to path or use special linker directives, just `odin build .`!
Also I think Odin struck the right balance of features while trying to keep to the spirit of C.
throwawaymaths
> This is the polar opposite of Zig’s embracing of metaprogramming for as much as possible.
I found this claim a bit strange. do people actually use metaprogramming in Zig a lot?
James_K
A C alternative means a language that will last for 50 years, whereas this seems more like "whatever's popular by way of LLVM". I can see some real smart stuff coming out of languages like Zig and Rust, where Odin seems just to follow along.
taylorallred
Odin really hits the sweet spot for everything you would want from a language for the game dev and game-dev-adjacent space in terms of simplicity, convenience, and speed. I think a major design decision of the language that will make or break it for users is the fact that the language gives you common features instead of giving you the means of abstraction to make those features yourself. For example, instead of preprocessor macros you get the `when` clause for conditional compilation because in Bill's estimation, that's one of the only real needs for macros. The same goes for data structures. Odin gives you the certified classics like dynamic arrays and maps but doesn't give you a whole lot to make your own custom data structures (it's possible, just not encouraged by the language design). All in all, I think if you want to make an application with a language that has batteries included and you don't need a lot more than that, Odin is nearly flawless.
mcbrit
I am currently limiting myself to 500 lines of (particle engine) code while listening to visual artists talking about their workflow in UE5 or Houdini, and Odin+Raylib are lovely to work in.
GingerBill has shouted out Go, but Odin doesn't particularly feel like a Go flavo(u)r.
vandyswa
FWIW, another take on "C Alternative" is the D programming language:
https://wiki.dlang.org/Tutorials
Comparatively mature, there's even a freeware book which is quite good:
http://www.ddili.org/ders/d.en/index.html
ultrarunner
As a completely incidental observation (and maybe related to the article from a few days ago considering the importance of language skills compared to math skills for software development), I'm interested in what people choose to capitalize when developing languages. With c, lowercase seems to be the default, signifying variables or function calls. Adding inheritance in c++ leads to Proper Nouns like classes being capitalized, while their instances are often lowercase. This communicates a subtle "feel" for the language, meta information about what's being accomplished.
Capitalizing method calls (`rl.InitWindow()`) seems to place the importance on the Method being called, but at first glance (ASP, or Go off the top of my head) it muddies the waters. If this isn't clear, consider that capitalizing ALL code would reduce clarity as all letter shapes are now essentially the same (a box).
I spend most of my time in c, c++, ruby, and javascript, but maybe I should try to do a personal project in Go (or Odin) for this reason alone.
leelou2
Odin seems to strike a really interesting balance between simplicity and practicality, especially for game development. I like the idea of having “batteries included” without too much abstraction getting in the way. For those who have used both Odin and Go, how do you feel about the differences in day-to-day development? Are there any features in Odin that you wish Go had, or vice versa? Would love to hear more real-world experiences!
gitroom
been playing around with odin and honestly the ease of getting started feels way better for me than most c-like stuff ever has. you ever think these smaller pain points keep more folks from switching than big technical features?
johnnyjeans
For me, I don't really look at Odin as a successor/fixer of C. There are other languages that can make a better case for that[1][2]. Instead, I look at it more like a successor/fixer of Pascal. It doesn't fall down the OO hole that so many others did. It has type casting, dynamic arrays, parametric polymorphism in both functions and data structures, is much less noisy (and in my opinion far more skimmable), more useful built-in primitive data structures like associative arrays and matrices, custom allocators, function overloading, reflection, etc.
You can find odds and ends of these things in other Pascal successors like Delphi, Oberon and Object Pascal. Truth is though, I never found these languages compelling. Why? Because none of them were anywhere close to being the same kind of simplicity as Pascal, and they were too wrapped up in flashy, trendy things that went out of style. Where Odin wins out is that it distinctly lacks the 90's OO craze hangover, and it never feels particularly more complicated or bloated. It's an audaciously tasteful proposition for a language. A C replacement? No, not really. But as a C++ programmer who's fed up with the lack of things like structure introspection and ergonomic sum types, I'm keeping a very close eye on Odin.
[1] – https://c3-lang.org/
[2] – https://harelang.org/
thegeekpirate
When I first saw Odin, I wrote down a list of everything I didn't think I'd like.
After several thousand lines, it proved all of my major worries incorrect, and has been an absolute pleasure.
It has since replaced my usage of Go, which I had been using since release.
I would highly recommend giving it a proper shot!
Dwedit
How does this compare with Zig or Beef?
mistrial9
re Odin — I do not like reusing important names in this way. Can I be the only one?
yawaramin
Can someone explain how Odin achieves memory safety? Eg how does it avoid use-after-free?
throwaway81523
I don't understand the point of this. When I say "Go flavour" I thought it would have lightweight threads like Go, but there is no mention of that in the description page. So it's another uninteresting curly brace language as far as I can tell. I'd rather use one with more traction.
rednafi
Odin truly feels like a C successor, and as someone who likes Go, it appeals to me a lot more than Zig or Rust. Partly because it took inspiration from the Pascal, Delphi, Oberon branch, same as Go.
I don’t particularly enjoy working on the types of problems Zig or Rust aim to solve. I spend the majority of my time working at layer 4, and Go makes it immensely enjoyable. But sometimes I want a bit more control over the hardware and don’t want to pay the cost of a GC. Odin feels just right.
In my case, the assortment of syntactic features like OOP, compile-time macros, or even the borrow checker suck all the fun out of programming. That’s why I still enjoy writing C programs, footguns and all.
ossobuco
I've been using Odin for the last ~6 months, wrote a 15k loc project and it's been an absolute pleasure. This is my first low level language after 10 years of web dev, and it feels much higher level than it is, while giving you the control and performance of a language like C.
I like pretty much every choice that has been taken when designing the language, except maybe the lack of namespaces, which can be solved anyway with prefixes.
The lack of OOP features is the best part for me, it's rewiring my brain in a good way and I can now also reason much better about RDBMS schemas. Data oriented design is the most helpful approach I've stumbled upon in my career.