Does really game development on Java suck? Why are we still here?

If I understand what you talking about, Scala allows you to do this. So you “+” is just a method and scala has special syntax rules for two parameter methods that allows you to make nice infix code. I’ve used it in my vector implementation and it is nice to be able to say

newPosition = currentPosition + velocity*elapsedTime

where velocity, newPosition, and currentPosition are my Vector3Ds and elapsedTime is a long but every non-mathematical, non-trivial use of it that I have seen has been down right ugly. SBT (Simple Build Tool) is a perfect example.

So I guess I am glad Scala has it, and wouldn’t mind if Java got it but I wish people would use a lot more restraint when using it.

An infix operator is a one-parameter method, and the other side is the object defining it. Sure you can reasonably think of ‘this’ as a parameter, but the language syntax doesn’t see it that way. Scala has very permissive rules for what constitutes a valid method name. Unfortunately, instead of being able to declare fixity, it hardwires “ends with a colon” to mean right-associative.

SBT’s use of operator overloading is quite reasonable, especially for a DSL with a limited domain – you’re not likely to embed it in an app not related to build management after all. You want operator abuse, take a look at Unfiltered. It’s the price of expressiveness, that someone might express in a way that doesn’t make sense to you. My solution is simply to not use Unfiltered. I too have my limits, believe it or not :wink:

I suppose if I dug in and used SBT long enough I’d be able to work with it more easily (truth be told I don’t even like the “!” and “!!” used with Actors). I’ll take all look at Unfiltered if for no reason other than to get my agita up.

Within the context of Java. The most important operators would be getters and setters. And not C# style automagic. I’m about to head out for vacation so I don’t have time to do a proper write-up. And in the special case of getter/setter NOT being pure syntax sugar handled by the AOT compiler, but VM aware constructs…any other operators can be pure sugar. Think hiding implementation details and the fact that all classes other than the implementer shouldn’t care if a “field” is a real field or a pair of methods.

I’ve seen C++ code where people overloaded the new operator and the parentheses operator - ()

Fucking awful beyond belief. You have to read the whole code base to understand any of it.

Human obfuscation ;D

Overloading new and delete operators is incredibly handy for doing custom memory pools and allocators. You can detect memory leaks this way, and on memory-limited platforms (ie. consoles) it’s vital to be able to segregate different allocations into different pools with different lifetimes.

Overloading can be handy when:
(1) people do exactly what they’re supposed to do with the operator (what’s the proper usage for parenthesis overloading?)
(2) don’t abuse it
(3) make all the corner cases consistent
(4) have a use case where all the operations are covered (how do I do dot operator for vectors?
(5) the precedence for primitives matches the precedence for objects (why should a vector cross operator using * have higher precedence than addition using + when these aren’t precedence rules of vector mathmatics?)
(6) you don’t mind having to read the class definitions of all expressions involving operators to know whether the code means what it looks like or not.

Regarding the new operator - I wrote a memory leak (and boundary overrun detecting) allocator by replacing alloc(). You don’t need operator overloading to do that. Besides which, why operator overloading at all for that use case? If you want to be able to specialise allocators why not have a pluggable allocator rather than the option to make new() do absolutely anything - which is what operator overloading gives you.

It’s exactly the sort of thing that makes C++ so “hard” and one of the key differentiators from Java. Yuk. But method operators would be ace.


public operator Vector3f cross(Vector3f left, Vector3f right) {...}
...
Vector3f a = left cross right;

Cas :slight_smile:

If you give everyone the freedom, they will use it. Everyone thinks they know how to do things better then everyone else.
That was the demise of c/c++.

see this Dear maintainer entry.

Add in the spec writers giving in to tantrums from language migrators wanting ‘features’ from every language added, and you will have a mess.

Java is limited, statically defined and whatnot, but that is IMHO a good thing. It means it is reduced to things that EVERYONE can use and understand.
Would I like to see operator overloading? Yes, I could actually use it right now! But I know what could happen if you add it, thus I would rather not have it.

There are some valid points among the debate. I see it as that there are basically two “camps” - the people who work more for themselves (such as private gaming projects) who want a language which gives freedom. There are also the people who work in (big) teams on a daily basis that would loathe the day that the language would open up more possibilities for team members to create the utter maintenance hell.

I certainly appreciate Java’s “you ain’t gonna do it” design mentality when I see what kind of people I usually have to work with. The kind that likes to fabricate 5 layers of code where 1 suffices. Please, god, don’t let operator overloading ever make it into the Java base language…

If operator overloading is important, there is always Scala and now to some extend Kotlin (http://blog.jetbrains.com/kotlin/), which seems to be a nice compromise between Java and Scala. Haven’t tried it yet, but with the now available language support plugin for the free Idea Community Edition, it might be worth checking out (and creating a decent math library with it’s operator overloading feature…)

Yeah I know what you mean. There just aren’t any apps written in C++ any more. ::slight_smile:

(hey what the hell happened to the eyeroll emoticon?)

::slight_smile:

Hmmm, reluctant matching methinks :wink:

C++ is still the gaming language but on other parts of software industry it has been in steady decline about ten years. c++ is never ment to be language for every solution but it was misused in many places where perfromance wasn’t crucial.

Sure, C++ is very powerful and has a huge foothold in gaming studios, but no-one seriously argues that C++ is well designed! If C++ came out with the design of D, it might be that we’d never have bothered trying to find better languages, but that wasn’t the case.

Yeah, it’s worth noting that C++ is ranked under C in the Tiobe language index. When the language you were designed to replace has a resurgence to become more popular than you, you’ve failed.

You really think TIOBE is an accurate measurement of industry?

How many job reqs do you see that list “C/C++” as if it were somehow the same language?

c++ is ranked under java, c, c# and soon even objective-c goes above it. c++ is dying language but I can’t see it would fade anywhere from gaming scene at least in this decade.

@sproingie: I think OverKill means the ranking position.

You probably mean “C/C++/C#”, which just shows how important a name is - those hiring have no clue whatsoever.