#in zig vs odin which is more low level
1 messages · Page 1 of 1 (latest)
I've never used it but I believe they're pretty much at the same level
You can write fast code in both, and you can write slow code in both
Try them both out and see which you prefer :)
Am coming from golang.
I tried both
But zig looks like more capable than odin because
- Built in funcs like @aligncast, @bitcast, @addrspacecast, @setalignstack
Is These things done with odin or not
You will be able to do things like this in odin yes, but I'm not sure how they're done as I don't use odin
Zig takes a very explicit approach here; it's possible Odin is more relaxed about these types of casts and merges them into more general operations
alignCast isn't necessary in Odin because alignment isn't part of the type there.
You use an intrinsic function to load or store in an unaligned manner.
@as(T, @bitCast(x)) is just transmute(T)x in Odin.
@addrSpaceCast currently doesn't exist in Odin because it doesn't support CPUs that have multiple address spaces.
@setAlignStack isn't really necessary in Odin because it aligns the stack for you based on the target automatically.
But yes - Odin can do anything that C can do. It's a low level systems programming language, just like Zig is.
Imo both are great languages it’s just personal preference which one you use
as a person who primarily uses and prefers zig, Odin is a delightful language to use
You, @sharp fractal, have asked this question on the Odin Discord as well, but seem to be confused by a few concepts.
Odin and Zig are just as "low level" as each other and just as "powerful" as each other.
@cerulean slate has done a lovely summary of those things.
Just because Zig may have some other built-in @ functions does not mean that Odin is lacking, rather that Odin doesn't need them or has something else entirely for the same problem those things try to solve.
P.S. if we ever do start supporting platforms with multiple address spaces, then I'll add the equivalent of an address space cast to Odin, but no sooner.