▲ | ecshafer 5 days ago | |
The first programming language that used overloaded operators I really got into was Scala, and I still love it. I love that instead of Java's x.add(y); I can overload + so that it calls .add when between two objects of type a. It of course has to be used responsibly, but it makes a lot of code really more readable. | ||
▲ | lelanthran 4 days ago | parent | next [-] | |
> The first programming language that used overloaded operators I really got into was Scala, and I still love it. I love that instead of Java's x.add(y); I can overload + so that it calls .add when between two objects of type a. It of course has to be used responsibly, but it makes a lot of code really more readable. The problem, for me, with overloaded operators in something like C++ is that it frequently feels like an afterthought. Doing "overloaded operators" in Lisp (CLOS + MOP) has much better "vibes" to me than doing overloaded operators in C++ or Scala. | ||
▲ | Attrecomet 4 days ago | parent | prev [-] | |
Exactly, not allowing operator overload leads to Java hell, where we need verbose functions for calls that should be '+' or similar. |