5 ms·
Sure, but this is only true because C allows for assembly code so you can always write assembly that beats zig. If you limit it to actual C and don't include a
by P5fRxh5kUvp2th 4y ago
Sure, but this is only true because C allows for assembly code so you can always write assembly that beats zig.
If you limit it to actual C and don't include assembly, it's possible the statement is true but I would expect it to also be false depending on the circumstances.
zig is going to have more opportunities to optimize but may be paying a cost in terms of offered features that C doesn't have.
But in general, yes, zig is very fast and competes with C in terms of performance.
- pjmlp 4y agoInline Assembly is not part of ISO C and plenty of languages have such extensions.
- P5fRxh5kUvp2th 4y agoIf you read closer, my point was that anything Zig can do, can be done in C due to it's ubiquitous ability to bypass the compiler and move straight to assembler. I can't think of a major C compiler that does not allow for this, can you? The only thing I could imagine coming close is something like compiling to a very specific target such as GPU shaders, but even that's a bad example considering shaders have been standardized.
- pjmlp 4y agoMSVC, inline Assembly is only available on x86 mode, everywhere else requires compiler intrisics or MASM.
- P5fRxh5kUvp2th 4y agoJust checked, apparently that's right for MSVC. My point still remains but I take your point about its limitations. My post was more a caveat on the original point anyways, I wouldn't expect most people to drop down to assembly except in very specific circumstances.
- boltzmann-brain 4y agoassembly is not the ultimate in speed, that's a myth. for many problems there are often high level approaches that offer orders of magnitude of speed up which are simply not expressible in assembly code due to the complexity of the assembly that would be needed to express them making it infeasible to program these approaches in assembly.
- P5fRxh5kUvp2th 4y agoanything expressible above assembly is expressible in assembly, both at the macro and micro level, only assembly can hyper-optimize the use-case in a way that a generalized compiler often can't. There is no myth here, it's a simple statement of fact. The Zig compiler does things C compilers can't. C developers can get access to those same techniques by bypassing C compilers to express them directly in assembly. This is not arguable, it simply is.
- boltzmann-brain 4y ago> anything expressible above assembly is expressible in assembly parser for unicode, go. I'll wait over here.
- P5fRxh5kUvp2th 4y agoIf I grab a C library that does this, compile it, and hand you the resulting assembly, will your mind explode?
- boltzmann-brain 4y agothat's not written in assembly, just compiled to assembly.
- P5fRxh5kUvp2th 4y agoWhen you start trying to argue semantics, you've given up the point.