Introduction to the Odin Programming Language
zylinski.se
zylinski.se
I've just spent a week doing ~ nothing other than writing C. It's been great. The language does exactly what you tell it to. Generating C to do things from tables of data is very easy. I especially like the zero context switching that comes from being able to remember the language. Python or C++ involve far too much looking up documentation.
It's the wrong tool for solving most problems but the right tool for telling a computer what to do.
* Undefined behavior, there are apparently over 100 of them. I can probably name about 5, maybe 10. Will the compiler warn me if I accidentally trigger undefined behavior? Of course not, it assumes that I am super-human who never makes a mistake.
* Code sharing using '#include', god I hate 'em.
* No namespaces, which means a single global namespace for all functions.
* Strings: every time I have to manipulate strings in C, I want to shoot myself.
* Arrays decaying into pointers, very clever, causing so much misery.
* Array length decoupled from the array pointer. No way to pass around both of them together, and checked automatically by the compiler.
* The C preprocessor #define magic. Love 'em when they are mine, hate 'em when they are someone else's. Hate 'em even more when they are mine 6 months later.
* The #define/#ifdef spaghetti code. There ought to be better ways to support multiple architectures.
Those are just off the top of my head. I'm sure I could come up with a few more items.
The includes and raw pointers are a build your own abstraction thing. Annoying if the abstraction you're building is the one a different language gives you to work with. For example, a struct with multiple arrays of the same length - in C that's multiple pointers and one size, in other languages that's probably multiple sizes and asserts that they haven't diverged.
It's not a perfect language but it's really rather good.
I also really love Zig but for some reason I still prefer C
In this, they make a good point about refactoring more with Rust than other languages. In some cases, "fighting the compiler" is not always want you want to do, especially when mocking some code/game state.
Any languages that want to be recognizable to people comfortable with the C-lineage are going to converge on a lot of points.
Why Odin -- Can someone tell me ?
> Data-Oriented, Simplicity, High Performance, "Batteries Included", Open Source (BSD 3)
https://odin-lang.org/docs/faq/
A shame that it isn't broken out into an explicity "Why Odin" page.
This make me think that every programming language web site should have a Why $language page, either as the home page, or prominently linked from it.
The only one I can think of is Ada.
Of course - modern Pascal (Free Pascal, Delphi, etc) might have evolved a lot since.
// C
void some_func(int a) {
int b = a + 10;
printf("hello %d\n", b);
}
{ Pascal - Going by memory, so might be a tad wrong }
procedure SomeFunc(a : Integer)
var
b : Integer;
begin
b := a + 10;
WriteLn('hello ', b);
end;
I have been playing around with Odin for a little while, now. It may have been inspired by Pascal in a number of ways but it certainly isn't as cumbersome to write. I am liking the syntax much more. // Odin
some_func :: proc(a : i32) {
b := a + 10
fmt.println("hello ", b)
} > If you want to use one of Odin or Zig but don’t know which one, then I recommend spending 1-2 weeks using each and then make up your own mind.
That's fair enough, but has anyone who has done this got any thoughts? Zig seems to have a lot of admirers on HN. Is Odin on par with Zig?Odin inherits a lot of warts from horrible languages like Go, and they seem to have run out of ideas to solve some problems at some point.
Still waiting on you to list what those "warts" may be. I mean sure golang may be overly conservative in its design but calling it "horrible" is a very wild take.
The only evil I know of that golang has perpetuated is making an unused-variable error an compile error that will block compilation instead of an linter error. This makes prototyping much more annoying.
Ironically a design mistake that Zig has copied as well. Not sure if Odin does actually
It could have been the perfect language for me, it's unfortunate