Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Zigs lack of operator overloading means math code will be illegibly gibberish, which kills any possible interest I had in it.


Why would you need operator overloading in a low-level language? It's not like you are gonna write Jupyter notebooks with it. Zig is not meant to replace MATLAB, Python or Julia. I would use it instead to build the backbone of such a data science platform.


> Why would you need operator overloading in a low-level language?

Have you ever heard of matrices and vectors? You need them in a lot of DSP (digital signal processing) applications, like audio and video filters, or in 3D graphics. Being able to write

    x = m * y
instead of

    x = m.vector_mult(y)
makes life so much more pleasant.


In Zig you write libraries that should be explicit and maintainable.


    x = m * y
is even more explicit than

    x = m.vector_mult(y)
because the * operator is side-effect free by convention, while a method like vector_mult() might or might not be mutating (i.e., it could work like the *= assignment operator).


I use operator overloading in C++ all the time, you seem to be looking at it from a data science perspective, but other fields use math also, such as gamedev.


I would have imagined that in game dev you prototype first with a high level language and then you would write the math code. How much of game dev is actually math code, aside from critical components like rendering, physics, etc.?


No that is not how it is done, the math is written directly in C++.

If you have fast iterative build times, lots of assertions, and good debugger there is no reason to waste time writing it in another language first.

Almost every system uses basic vectors and matrices/quats, most gameplay code also uses them etc.


Consider the fact that QuakeC had a native vector datatype back in the day, despite the fact that all rendering and physics was done in native C code.


3D rotation is maths. How many 3D game objects don't rotate anything in gameplay?


How is adding `Duration` to `DateTime` related to jupyter notebook? I use that much more often than element-wise matrix multiplication.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: