4 ms·
I'm honestly glad that Go, unlike C++, does not have features that are useful only for a small subset of programmers. The only 2 cases I've seen where operator
by PopsiclePete 12y ago
I'm honestly glad that Go, unlike C++, does not have features that are useful only for a small subset of programmers. The only 2 cases I've seen where operator overloading is useful are:
1. String concatenation (Go has it)
2. Matrix/vector operations
That's it. Any other use case for operator overloading is dubious at best. It sucks for scientific programmers, but Go is a general purpose language, not a Scientific Programming language.
Complicating parsers, the grammar, readability, all those things, just to please your sub-group -> no thanks.
- gejjaxxita 12y agoI don't disagree with you. I'm not suggesting that Go designers made the wrong decision with the goals they had. I am jealous that it's less useful to me though.
- mattyw 12y agoforgive my ignorance, why is operator overloading particularly useful in scientific computing?
- aaronblohowiak 12y agoSo your code can still look like math when the operands are complex types.
- NateDad 12y agoBecause it lets your math code look more like math and less like code. v := Vector{} v2 := Vector{} to add the two vectors, currently you have to do something like result := v.Add(v2) rather than the nicer result := v + v2 In the small scale, it doesn't seem like a big deal. In a large and complicated scientific program, it can make the code a lot harder to read. Note: I think it is good that Go does not have operator overloading, though I think it's a shame that means it's not as good for scientific & math programming.
- munificent 12y ago> Complicating parsers, the grammar, readability Operator overloading has absolutely no effect on the parser or grammar. It may harm readability but that's more a question of naming. An operator is just a name. If you use that name to refer to something unexpected, you'll harm readability. If you use it for something intuitive, you'll improve it.