(After trying it for one day!)
It's very similar to Zig but:
- a little bit less verbose to write
a := 3
for variables,a :: 3
for constants, instead of in zigvar a = 3;
,const a = 3;
- struct init does not require members
myStruct : MyStruct = { 1, 2 }
, vs in zig you must have membersvar myStruct = MyStruct{ .field1 = 1, .field2 = 2};
- no semicolons at end of statements, no parenthesis around conditionals
- heap allocations are sometimes unclear
- strings can be both static, or on stack or heap depends how you use them, and its not immediatelly obvious
- it has a global variable called "context", where you can set the state of some things in the program
- like which allocator is used in the next heap alloc
- so instead of zig where you have to pass allocators explicitly every time, in odin its hidden in some global state. Not a fan of this feature
- there are no member functions (inside structs), like in C
- so you write functions separately and have to pass in the struct as an argument, makes it a little more verbose and you cant chain nested struct functions
myStruct.otherStruct.func()
- so you write functions separately and have to pass in the struct as an argument, makes it a little more verbose and you cant chain nested struct functions
- it uses directories as "packages", but I haven't tested that out yet
- it has named multiple return parameters in functions, in effect similar to "out" params in C#. It gives you back named parameters, but the syntax is really strange requiring an empty
rturn
statement at the end which is not immediately obvious using
keyword can introduce statements from one scope into another, which can be used to create a sort of a static inheritance by including struct into another.- Seems to me like this has great potential of name conflicts in big projects, but is an interesting concept but it has a weird return that returns nothing because it expects everything to be assigned earlier
- the only thing I really like in Odin is that arrays and vectors are the same thing
- so theres no need to make vector types, you can just pass around
[3]f32
everywhere. - and you can do math operations on them,
- and also you can swizzle like in glsl with vec.xyz = vec.xxx or vec.rgb
- meanwhile in zig @Vector(3, f32) is not an array, you can do math operations on it, and you can swizzle but not with .xyz syntax
- but the difference is that zig vectors are SIMD aligned vectors out of the box, that is why they cant be the same as normal arrays. Not sure how that works in odin, maybe it considers 2, 3, 4 sized vectors as SIMD too, idk
- so theres no need to make vector types, you can just pass around
- everything is zero initialized by default
- in zig you must initialize explicitly (or explicitly leave unitialized)
- you can also explicitely leave uninitialized in Odin with
---
- no arbitrary width integers, which is one of the coolest features in Zig (it does have packed structs tho)
- no package manager, but it has an integrated vendor library that includes a lot of gamedev packages like raylib, glfw, etc..
So, that's so far what I got.
Basically, the feeling i have is zig makes no compromizes, no hidden allocations means no hidden allocations ever while odin is like some compromizes are okaaay, and then makes arbitrary decisions on what compromizes to take.