4 ms·
Part of Zig's core philosophy is that you can readily assess the "cost" of any particular expression is doing. There are no hidden function calls. If an express
by nemo1618 6y ago
Part of Zig's core philosophy is that you can readily assess the "cost" of any particular expression is doing. There are no hidden function calls. If an expression doesn't contain (), you can be completely confident that it's not jumping away to some other piece of code.
btw, I know it's not as nice as first-class operator overloading, but Zig's comptime might enable writing DSLs for e.g. vector/matrix math: https://www.reddit.com/r/Zig/comments/g83h12/comment/foleoa8 https://www.reddit.com/r/Zig/comments/g83h12/comment/foleoa8
- banachtarski 6y agoComptime is certainly nice but not usable in this context I’m afraid. Also I’ve heard that argument a ton. It’s total complete rubbish as far as I’m concerned. Extrapolating, if you see a function call, what really can you say about the “cost” of that function? To me, without actual investigation, the answer is zilch. The function might be inlined, in the i-cache, referencing a lazily loaded symbol. It might be a small function, it might be huge, it may flush the cache, idk. If the goal was to be able to estimate the performance at a glance, well, we should use assembly, and even then the performance isn’t always clear.