Odin, a pragmatic C alternative with a Go flavour

bitshifters.cc

142 points by hmac1282 5 days ago


johnnyjeans - 4 days ago

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/

taylorallred - 5 days ago

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.

rednafi - 4 days ago

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.

pbohun - 5 days ago

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.

thegeekpirate - 4 days ago

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!

WhereIsTheTruth - 5 days ago

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

ossobuco - 4 days ago

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.

ultrarunner - 5 days ago

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.

mcbrit - 5 days ago

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 - 5 days ago

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

gitroom - 5 days ago

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?

gusfoo - 4 days ago

Here is the website: https://odin-lang.org/ - which was not obvious.

fuzztester - 3 days ago

Is anyone doing desktop GUI apps with Odin? If so, what libraries are you using?

throwawaymaths - 5 days ago

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

Dwedit - 4 days ago

How does this compare with Zig or Beef?

yawaramin - 4 days ago

Can someone explain how Odin achieves memory safety? Eg how does it avoid use-after-free?

dang - 4 days ago

Related. Others?

Understanding the Odin Programming Language - https://news.ycombinator.com/item?id=42348655 - Dec 2024 (97 comments)

Moving my game project from C to the Odin language - https://news.ycombinator.com/item?id=42030704 - Nov 2024 (19 comments)

Golang developers should try Odin - https://news.ycombinator.com/item?id=41969839 - Oct 2024 (7 comments)

Marketing the Odin programming language is weird - https://news.ycombinator.com/item?id=41913319 - Oct 2024 (101 comments)

Odin isn't getting more features. The syntax is done - https://news.ycombinator.com/item?id=40873431 - July 2024 (3 comments)

Introduction to the Odin Programming Language - https://news.ycombinator.com/item?id=40688899 - June 2024 (60 comments)

Odin Programming Language - https://news.ycombinator.com/item?id=38836512 - Jan 2024 (102 comments)

Small joys of programming in Odin - https://news.ycombinator.com/item?id=36812175 - July 2023 (61 comments)

A Review of the Odin Programming Language - https://news.ycombinator.com/item?id=32799499 - Sept 2022 (140 comments)

I like Odin - https://news.ycombinator.com/item?id=32626543 - Aug 2022 (204 comments)

Odin Programming Language - https://news.ycombinator.com/item?id=30394000 - Feb 2022 (42 comments)

The Odin Programming Language - https://news.ycombinator.com/item?id=22199942 - Jan 2020 (141 comments)

The Odin Programming Language - https://news.ycombinator.com/item?id=20075638 - June 2019 (3 comments)

mistrial9 - 4 days ago

re Odin -- I do not like reusing important names in this way. Can I be the only one?

leelou2 - 5 days ago

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!

throwaway81523 - 4 days ago

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.

James_K - 5 days ago

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.