Re:Why Zig when there is already C++, D, and Rust?
by colejohnson66 on Friday January 15, 2021 @06:25PM
(#25798011)
I don’t think I’ve ever seen a library overload math operators when they didn’t do what you’d expect. And just because a language feature is abused doesn’t mean it’s bad. Typescript’s generics are Turing Complete, but they’re still great.
[ Parent
| on HN ]
Re:Why Zig when there is already C++, D, and Rust?
by whatshisface on Friday January 15, 2021 @06:28PM
(#25798040)
Look at it this way - let's say you're a programmer who never uses math. As a result, 100% of your exposure to operator overloading will be, by definition, to cases that have nothing to do with math. While a programmer that uses math will see 1,000,000 good uses and 10 bad uses, a programmer who never uses math will see 0 good uses and 10 bad uses. I saw a similar effect in the Go community where they were debating whether or not the complex type should be removed. It's absolutely crucial for signal processing, but to the rank and file REST-ist, it's just another annoying case to type out in a generic-less language.
Re:Why Zig when there is already C++, D, and Rust?
by Quekid5 on Friday January 15, 2021 @06:30PM
(#25798063)
What programmer never uses math?
I mean, most of us aren't going use linear algebra, but still...
Re:Why Zig when there is already C++, D, and Rust?
by whatshisface on Friday January 15, 2021 @06:36PM
(#25798120)
I'm using math in a colloquial sense to refer to "mathy math," not "computer science math." So linear algebra would be a leading example, along with stuff like vectors and complex numbers. Accounting math would be another example, because it requires a bignum implementation that doesn't drop decimals like float can.
Re:Why Zig when there is already C++, D, and Rust?
by Quekid5 on Friday January 15, 2021 @06:37PM
(#25798132)
Ah! Might be helpful to specify that up front. Even so: Interval math could be quite helpful for lots of things that ... aren't using it.
Re:Why Zig when there is already C++, D, and Rust?
by hnlmorg on Friday January 15, 2021 @07:00PM
(#25798317)
> Might be helpful to specify that up front
I thought his post was pretty clear tbh. For example he mentions complex types so that should be an indicator that he's not talking about the kind of high school maths that the average developer can coast along with.
Re:Why Zig when there is already C++, D, and Rust?
by im3w1l on Saturday January 16, 2021 @02:42AM
(#25800800)
Do you have an example of someone solving a real-world problem with interval math? I've only ever seen toy examples and theoretical justifications.
Re:Why Zig when there is already C++, D, and Rust?
by Quekid5 on Saturday January 16, 2021 @04:08PM
(#25805524)
1) Most of (micro-)benchmarking in computing. Of course you want a tiny bit more analysis in that case.
2) Slightly more real-world: Measuring things when you only have approximate rulers, have difficult things to measure (odd surfaces, etc.), or have to calculate from 2nd hand measurements (pictures with rulers, etc.)
Not sure if that qualifies as Real World, but...?
Re:Why Zig when there is already C++, D, and Rust?
by im3w1l on Saturday January 16, 2021 @11:28PM
(#25808122)
By real world I mean code running in production and making someone money. Or a popular open source package. And I'd be interested in which company or project that is and if they have a writeup.
Re:Why Zig when there is already C++, D, and Rust?
by hobofan on Friday January 15, 2021 @06:44PM
(#25798190)
So for those use cases where you will be using a library with custom types anyway, choose one that doesn't overload the operators for those types? This very much seems like a problem on the library- and not the language-level.
Re:Why Zig when there is already C++, D, and Rust?
by Ar-Curunir on Friday January 15, 2021 @07:39PM
(#25798645)
Also, in Rust if you don't want to use the overloading, you can still write your code to directly use function calls `a.add(b)`, where `a` is a type that implements the `Add` trait.
Re:Why Zig when there is already C++, D, and Rust?
by Arelius on Friday January 15, 2021 @06:52PM
(#25798257)
I get the truth in that statement. But as a game programmer, I find it interesting the contrast that linear algebra is precisely what is commonly used.
Re:Why Zig when there is already C++, D, and Rust?
by Quekid5 on Saturday January 16, 2021 @04:12PM
(#25805554)
Hah! Touche!
Weird to think that game programming is (weirdly) kind of a niche thing at this point. Compared to programming boring CRUD apps, that is. :)
Re:Why Zig when there is already C++, D, and Rust?
by cycomanic on Saturday January 16, 2021 @09:08AM
(#25802221)
I encountered something similar when I was trying out Nim. In Nim - ^ is the exponentiationoperator, so x^2 means x squared. The way operator precedence is implemented in Nim is that the unary negate (-) takes precedence over the ^, so - 2^2=4. It threw me off quite a bit (coming from a physical science background I assumed it should always be - 4,took a while in my debugging to figure this out). I went to their discord (?) channel and asked about this, some of the people there could not understand how it would be any other way, which just shows that the way someone who largely translates math into code (like myself) things about code very differently then someone who never does this.
Re:Why Zig when there is already C++, D, and Rust?
by amluto on Friday January 15, 2021 @06:29PM
(#25798046)
Have you ever used Boost?
Re:Why Zig when there is already C++, D, and Rust?
by lttlrck on Friday January 15, 2021 @06:44PM
(#25798193)
First thing that came to mind was Boost Spirit: https://www.boost.org/doc/libs/1_48_0/libs/spirit/example/qi...
Lovely.