logoalt Hacker News

Ygg2 • today at 4:26 PM • 3 replies • view on HN

BS. Using operator overloading with SIMD makes it easier to translate algorithms into code. I wrote my own U8x32 wrappers and a + b is way better than a.add(b).


Replies

pron • today at 4:53 PM

I'm not disputing that some people like user-controlled operator overloading (Zig does have + etc. for vectors), but clearly others prefer no user-controlled overloading of any kind (don't know what the LLMs prefer, if they have any preferences at all). In the safety-critical space where I once worked, where people could get hurt or die if there's a stack overflow, the more common preference was against (user-controlled) overloads or any implicitness. That's why we need options.

➕ show 1 reply
bunderbunder • today at 5:22 PM

The example you choose is rather telling, though. It indicates that the use case you have in mind is not at all the one that Zig is targeting.

A more humble critique would be to just acknowledge that you don’t seem to be a member of Zig’s target audience, and move on.

cornstalks • today at 5:00 PM

You can do a+b in Zig with SIMD vectors. No operator overloading required

➕ show 1 reply