News for hackers. Stuff that matters.
Re:Problems of C, and how Zig addresses them by Gibbon1 on Monday July 03, 2023 @04:12PM (#36578153)
Maybe I'm small brained but built in vector types align with heavily platform optimized libraries. Meaning you don't want this stuff implemented in the compilers front end. You want it handled in the compilers back end.
Re:Problems of C, and how Zig addresses them by pixelpoet on Monday July 03, 2023 @05:48PM (#36579265)
Performance is equivalent in both representations, but the important thing is being able to write

  vec4 c = a * 4 + b;
instead of

  vec4 c = vec4_add(vec4_mul(a, 4), b);
i.e. infix vs postfix order, with simple * and +/- operators etc. I would very much like to appeal to the Zig authors to see the beauty in the former expression compared to the latter, for a huge class of real-world mathematical applications.
Re:Problems of C, and how Zig addresses them by eska on Tuesday July 04, 2023 @06:10PM (#36593167)
If this wasn’t math code we’d refactor such code into helper functions, but somehow when it’s math we refuse to.

vec4 c = a * 4 + b;

vec4 c = vec4_add(vec4_mul(a, 4), b);

vec4 c = vec4_fma(4, a, b);