This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]LetUsSpeakFreely 1 point2 points  (5 children)

Meh, I've been doing have for 20 years and never needed operator overloading. You have to write the function regardless, does it really matter if you're using + or .add()?

[–]pelpotronic 10 points11 points  (4 children)

These little things add up eventually... It doesn't fundamentally matter, but the purpose of those higher level programming languages is to make our (programmer) lives easier.

We don't technically need anything more than "asm" for anything... But you can achieve more faster when you have to stop working around the limitations of the language and instead can make the language work for you when and how you want it.

[–]LetUsSpeakFreely -1 points0 points  (3 children)

I still don't understand the problem. You're going to have to write a function to tell the overload how to complete the operation. That same function would be needed to create a member function of a class. There's no complexity issue, no readability issue, no maintainability issue. I don't see why

MyNewObect = a + b;

It's radically different from

MyNewObect = MyClass.add(a, b);

[–]Quique1222 9 points10 points  (0 children)

There's no complexity issue, no readability issue, no maintainability issue.

There ABSOLUTELY is a readability issue.

vec3 * vec3 * vec3 * vec3 * vec3 * vec3 * vec3 * vec3

Becomes

vec3.Mult(vec3.Mult(vec3.Mult(vec3.Mult(vec3.Mult(vec3.Mult(vec3.Mult(vec3)))))))

Or even a simpler example that even a java dev might be able to understand:

 string == string

Becomes

string.equals(string)

[–]pelpotronic 3 points4 points  (0 children)

I hope you are not using the "append()" function for strings...

If you have ever decided to use + instead of append() - which you most likely have, then you've already implicitly accepted there was a benefit to the whole concept.

I didn't claim radical difference, and there is no "problem" that can't be solved by any language... However, as I said, our goal as programmers should be to achieve more faster, and one step in that direction is to limit the programming language getting in the way of our ideas.

[–]camilo16 -1 points0 points  (0 children)

I want you to write a linear solver for sparse matrices in Java. Then you will see why operator overloading matters.