Re:Problems of C, and how Zig addresses them
by syntheweave on Monday July 03, 2023 @04:23PM
(#36578272)
As a comptime macro, yes, you should be able to slot in a DSL for all your vector math and essentially "pass in a string, get the function calls back". It would not be that hard, if you're up on your parser-writing skills, and definitely much cleaner than any C-style equivalent.
[ Parent
| on HN ]
Re:Problems of C, and how Zig addresses them
by pixelpoet on Monday July 03, 2023 @05:57PM
(#36579353)
Yep that seems comptime possible but a little heavy handed with string work, no? With everyone writing their own parsers and language tools...
In any case, if something practical is done here I'd be interested. Aesthetically I prefer the "vectors and matrices are first class types" (and maybe complex numbers could be too), but I guess Andrew isn't so sympathetic to these types being part of the standard language :/
There's a proposal for complex numbers: https://github.com/ziglang/zig/issues/16278
Vectors are already first-class types via @Vector, aren't they?
Re:Problems of C, and how Zig addresses them
by pixelpoet on Monday July 03, 2023 @07:32PM
(#36580196)
Whoa, I haven't been keeping up to date about this, there seems to be good related discussion here: https://github.com/ziglang/zig/issues/7295
I'll hope for some future news of Zig having vector and complex number support! It will be a great day for fast ray/path tracers :)
Unfortunately, vectors in Zig are the kind you use in SIMD and not in graphics programming. Perhaps there's some overlap, but I'm unfamiliar with both fields so I can't say to what degree.