

Meanwhile, I'll have to stick to writing that kind of abomination in Java. If Sun doesn't start fixing this sort of thing in Java, then Microsoft just might take the lead. Indeed, it seems that C# is what Java SHOULD HAVE BEEN. I am aware that C# supports some (all?) of the above, but it doesn't as yet have as much portability as Java does.
AEGISUB CREATE BOX AROUND SUBTITLES CODE
If Java is supposed to be a cleaner and easier version of C++, then why is it that writing that sort of code in Java is much harder and much less robust? While many programs don't suffer from those problems much, there are certain applications that become a true nightmare to write and maintain - physics simulations or anything to do with vectorial math are the obvious example (that's why I kept using "Vector3f" classes above). (In case you're wondering, I also had to add a clone() to the set method, because otherwise the caller might call the set method, but keep the reference that it passed to it and modify it later.) Java offers no solution for this problem. What if, instead of a vector, it was an image? And what if it was accessed many times per second? This could quickly become impossibly slow.

The second problem is that returning an entire copy might be SLOW. Since the user will have no way to tell if he's getting the actual position or a copy of it (unless he enters the original source or look in the documentation), he might try to modify the position that he got, and then be surprised that it doesn't work. There are two major problems with this: First, the previous code STILL COMPILES.
AEGISUB CREATE BOX AROUND SUBTITLES FULL
In other words, you're now returning a full copy of the object. Private Vector3f position = new Vector3f() Since Java lacks this feature, you are forced to use annoying workarounds (such as keeping pools of objects) if performance becomes critical. Stack building makes this much faster, not to mention EASIER. In many situations, you will have to allocate many small temporary objects and then never use them again. Not only does it involve complex algorithms for determining WHERE to allocate the memory, but it also means that you're giving more work for the garbage collector when you're done with the object. For the rest of this post, I will write snippets in both C++ and in Java to illustrate the differences.Ĭreating objects on the heap is slow. Three, in particular, have always bothered me: stack building, operator overloading, and const-correctness. This is a mostly off-topic rant that is being posted because I know that a good portion of our user base is composed of programmers.Įver since I started working with Java, a few months ago, there have been many things that I have felt SHOULD be there, but aren't.
