3 ms·
Going to be downvoted for this, but it would be cool if Go had operator overloading. That way, you could write matrix code in it. I think if Go did this, the la
by ogogmad 5y ago
Going to be downvoted for this, but it would be cool if Go had operator overloading. That way, you could write matrix code in it. I think if Go did this, the language could end up being used in computer graphics and Deep Learning.
Oh, and maybe this goes against the Go ethos, but Python has a library called Sympy for Computer Algebra, and it's quite nice. It clearly relies on operator overloading.
I'm guessing this won't happen for a long time because operator overloading has a reputation (rightly or wrongly) for being abused. Oh well!
[edit]
More philosophical point: Overloading in programming started with mathematical operators, no? The motivation for having it as a language feature is very clear (if you know enough mathematics). What happened?
- kwhitefoot 5y ago> if Go did this, the language could end up being used in computer graphics and Deep Learning. People have written programs in both of those areas using Fortran-IV which doesn't have overloading either.
- ogogmad 5y agoI think your comment is designed to troll me. The fact that it's so short and arrogant makes this more likely to be true. Just to be clear: Deep Learning means ConvNets or something fancier, which only became a hot research topic circa 2010 (though they also existed as a prototype in the late '80s). I doubt anybody has programmed ConvNets in Fortran IV; a language from 1962. And even if they did program a prototypical form of ConvNets (I suppose because they were originally an obscure proposal from the '80s) in Fortran-IV, it wouldn't be able to use such essentials as the GPU, or convenience features like autodiff, so in today's world it would be a toy. I suppose I've fed the troll.
- Cthulhu_ 5y agoI hear what you're saying, but why make one language look like another when that other language is more suitable for those purposes (graphics and deep learning)? Isn't Python the go-to language for deep learning? It's probably better to stick to that one, because the field itself is hard enough already - learning another language on top will just put people off.
- ogogmad 5y agoI appreciate the broad philosophy of Go, which is that it's a simple language. Much simpler than Python which (and this is subjective) has made some questionable design choices. I also like how it's not exotic or surprising; you can just get straight to hacking. I also like that Go is fast. It appears that some Python code is being rewritten in Go to make it go faster. Python's slowness is a problem in both the areas I've mentioned, and I know the usual workarounds.
- coopierez 5y ago> Much simpler than Python which (and this is subjective) has made some questionable design choices. One of the reasons golang is so simple is that they move very carefully on issues like this. It has its benefits and its drawbacks. Adding operator overloading kind of opens a can of worms here. If they add that, why not arithmetic types? Why not exceptions? Why not x, y, z... Everyone wants just _one_ extra feature that would improve the language. Trouble is everyone disagrees on what that one feature should be.