Operator overloading

I know that this is discussed ever since Java was released, and every other week someone comes around with the brilliant idea: “What if Java had operator overloading?”

Well, I understand the reasons against it, but did people at Sun ever questioned them? I mean, at all? Because it seems odd that a bunch of smart people would simply accept such arbitrariness without saying anything.

Operator overloading is a must for mathematical code. I can totally understand why some wouldn’t want to touch Java for games.

Was there ever a controversy about it?

There was a controversy then, there is now, and long story short, whatever you think about it, Java’s never going to have it.

I really don’t see what operator overloading has to do with games. The usual objection there is the costs associated with a managed runtime.

Everything, because you will use vectors and matrices a lot.

This simple feature makes Java very shitty for this type of application.

I hate operator overloading with a passion. Screw you C++.

@longino Just use a method.

If you are keen then you can always create a pre-processor for your code that translates your custom operators into legitimate java syntax (i.e. method calls etc)

You can even make it a plugin into your IDE so that it does the pre-processing step automatically.

How about I don’t do anything and just use a tool that does it for me, like, something other than Java?

What tool is that? I was not aware that one existed and that is why i suggested you make the tool your self… then others can benefit as well if they want operator overloading as well.

Visual Studio and C++ or C#.

um but that is because those languages support operating overloading explicitly… java does not. If you want to emulate operating overloading so you can… as i have suggested. If the underlying language does not support a feature there is no other way than to make your own tools (or create your own java-syntax based language that that compiles into bytecode that can run on a JVM)

Java’s not going to get operator overloading and no amount of whinging is going to change that. Live with it or use Scala.

Nope, operator overloading is just convinience stuff.
90% of mathematical high performance code is written in Fortran without any operator overloading.

And even in C++ it’s just nice for prototyping, but for performance, you do something other.
Working on SoA or AoS with unrolled loops and SSE optimizations.

Reading the thread till this point: Bye then! :slight_smile:

@Evil[1]: So I guess that Cray, IBM and Sun know nothing about high performance computing then.

You guessed correctly.

Okay… jokes aside. Cray is Tesla these days. IBM is the strongest FORTRAN player in the field. And Sun, no Sun never knew a shit about performance. And those Hadoop solutions on Cray… you exchanged throughput and scalability with performance. And what the f**k has this all to do with operator overloading? I just said, that for the real performance you don’t use operator overloading but tight SSE loops.

Or so to say, if you do this, you are doing it wrong:

for(int i = 0; i < count; i++) A[i] = B[i] + C[i];

I meant: chapel = cray, X10 = ibm, fortress = sun. Pretty much all attempts at a FORTRAN replacement include operator overloading.

Now, you’re the one the brought up SoA vs. AoS. Pretty much dead issue today isn’t it? Load is computation chain dependent SIMD ops have been adding horizontal ops. Load is data intensive, then massively parallel processors. Of course a non-issue here since we don’t have structures, concrete arrays nor SIMD access. Our only option is going to the gpu.

Now while it’s true that algebraic operator overloading is pure sugar, many useful features are pure sugar and often separates useful languages from the, well, not so useful.

Hell, Fortress has unicode operators.

HPC isn’t really concerned with syntax. They stuck with fortran all that time after all.

WRT: Fortress. I haven’t looked at it in ages, but it seemed like “a” goal was to allow code that pretty much looked like LaTeX output. Being a very long time Mathematica user, I have to say being able to write that code that looks like the equation is pretty awesome. Many, many operators is very useful in a fair number of mathematical fields.

WRT: HPC not caring about syntax. If you mean the non-programmers using existing libraries…then OK. But how many programmers that know more than a few languages and have a few years of experience don’t care about syntax or cringe at glaring holes in their set of languages?

Everything that is not assembly is sugar :slight_smile:

assembly is sugar for a hex editor / binary