Skip to main content
GameDev.net gamedev.net
🔒 Locked

JAVA is nuts - RANT

Started by owl Nov 4, 2009 at 6:51 PM 49 replies 7k views
Original Post
owl
owl
Is there some utility function to center a JDialog/JFrame so I don't have to code my own? How is it that things as simple such as centering a window demands me HOURS of researching? Is it because I'm drunk? I mean, I do it like this:

        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int height = screenSize.height;
        int width = screenSize.width;

        UsersForm.setLocation((width/2)-(UsersForm.getWidth()/2), (height/2)-(UsersForm.getHeight()/2));
        UsersForm.setVisible(true);
But Can I Has a '.setFramePosition(const)' method for once?
[size="2"]I like the Walrus best.
ukdeveloper
ukdeveloper
Java is a horrible abomination worthy of the deepest pits of Hell. I hear reliably that Sun themselves hate it, but it's become too successful and widely used for them to carry out the euthanisation process.

Java is like sat-nav; you want to go to the newsagent across the street from your house but it forces you to go via the neighbouring country. It forces you to take the long way around and shields you unhelpfully from doing things that might actually be useful or helpful because the abstraction has gone too far up.

It sucks balls and the only reason that so many enterprise shops use it is because their ancient version of Java will run on their ancient Linux environment. If the .Net framework ran natively on non-MS platforms, I'd happily bet a small amount of money that Java support would rapidly diminish.
Stani R
Stani R
Quote:
Original post by owl
But Can I Has a '.setFramePosition(const)' method for once?


No, but thou can haz .setLocationRelativeTo(null)

Haven't tested it myself, but everyone on Google says it works. Give 'er a whirl.
owl
owl
Quote:
Original post by lightbringer
Quote:
Original post by owl
But Can I Has a '.setFramePosition(const)' method for once?


No, but thou can haz .setLocationRelativeTo(null)

Haven't tested it myself, but everyone on Google says it works. Give 'er a whirl.


YES IT WORKS!! BUT IT WON'T WORK IF YOU SHOW THE FRAME LIKE THIS

ApplicationNameApp.getApplication().show(UsersForm);


ACTUALLY NOTHING WILL WORK IF YOU SHOW THE FRAME LIKE THAT.

arghhhhhhhh

rate++
[size="2"]I like the Walrus best.
KaptainKomunist
KaptainKomunist
I agree with your Java hate. Too many things were hacked into the language without much forethought. The largest being the collections library. Also, wrapper classes.
owl
owl
It's like it's missing things I'd think first if I had to code a library myself.

Howevwer I have to accept that it does an outstanding whole of stuff that would take me like 10 lifes to write myself.

ie = portability.
[size="2"]I like the Walrus best.
Oberon_Command
Oberon_Command
Reasons I personally dislike Java:

1) The Collections framework. The iterator design. The fact that the only way you can access the element the iterator is currently pointing to is by incrementing or decrementing the iterator. Ugggh.
2) The fact that there's no proper pass-by-reference, particularly for primitive types.
3) The fact that there's a distinction at all between "primitive types" and classes that have System.lang.Object as their top-most superclass.
4. No delegates or equivalent functionality, though to be fair there's a fairly easy workaround.
5. All public classes must be in their own source file and directory structure must correspond to package structure. Granted that I have a tendency to do that anyway in C++ and C#, but the fact that it is enforced on me pisses me off. I can think of occasions when I was working in C# and I had a collection of small, related classes and put them in the same source file. Not being able to do this in Java is annoying.
6. All methods must be defined in the same translation unit (the .java file) as the class. Again, granted that I don't use this much, but there have been occasions in C++ where I've put one group of methods in a class in one .cpp file and another group in another .cpp file. I haven't needed to do this in C# yet, but at least I know that I can do it via partial classes.
7. Checked exceptions. Thankfully Eclipse can handle this issue for me automatically (ie. by adding in some code that handles the checked exceptions for me) with a couple of clicks, but still.
Stani R
Stani R
Quote:
Original post by Oberon_Command
1) The Collections framework. The iterator design. The fact that the only way you can access the element the iterator is currently pointing to is by incrementing or decrementing the iterator. Ugggh.

Enhanced-for loop hides the iterator nicely though. Good for many occasions.

Quote:
Original post by Oberon_Command
2) The fact that there's no proper pass-by-reference, particularly for primitive types.

The alternative is pointer/reference syntax? I'd rather pass on that.

Quote:
Original post by Oberon_Command
3) The fact that there's a distinction at all between "primitive types" and classes that have System.lang.Object as their top-most superclass.

Autoboxing hides that, too. But why is it a problem?

Quote:
Original post by Oberon_Command
5. All public classes must be in their own source file and directory structure must correspond to package structure. ...

6. All methods must be defined in the same translation unit (the .java file) as the class. ...

I honestly think both of those are pretty sound principles and a blessing for code organization. It also makes it much easier to read other people's source code. Every time I download C++ code and go on a hunt for all the pieces that logically make up a class, I die a little inside. It's completely opaque.

Quote:
Original post by Oberon_Command
7. Checked exceptions. Thankfully Eclipse can handle this issue for me automatically (ie. by adding in some code that handles the checked exceptions for me) with a couple of clicks, but still.

Agreed on this one. I catch and rethrow as unchecked 95% of the time (in my own game code at least. It's a different story when writing libraries to access external resources). Java might hate me, but if I can't deal with an exception, I can't deal with it, and that's that. But stack traces are mildly helpful in figuring out why your program crashed. At least as long as it's single-threaded.

Things I hate about Java:

1) Exceptionally poor support for video playback. (Looking forward to Java Media Components)

2) All the verbose typing for using nio buffers.

3) Upcoming language features that will make it harder to read the code. (Proposals like null-safe, null-ignore, and JSR 308)
Hodgman
Hodgman
While we're ranting, I hate Java because it took C++, discarded the idiomatic way of writing good OO code with it, and reverted back to the "C with classes" way.

Want to write 3D math code? Lets write it like we would in C instead of "vecA + vecB"...

Want to assign one value to another? Screw "obj1 = obj2", that's too complicated! Let's force you to write an explicit assignment function.

Let's blur the distinction between values and addresses! People get confused by having to know about memory addresses, so lets pretend they're not even there, that'll make junior programmers write much better code for sure!

Oh and the best part, is how many different implementations there are, which make your "portable" code either simply not work, run terribly slow, or leak memory when transferred to different VMs! Lets use it as a language for low powered devices, so that you can't even write OO style code for performance reasons and have to re-implement polymorphism yourself with switch statements!
SamLowry
SamLowry
Let's not forget about the beautiful Cloneable interface, which is too absurd for words. How is one supposed to use it, since it contains no methods at all? Is one supposed to use instanceof and then... I don't know, use reflection to be able to call clone()? Is there anyone who knows of an actual use for it, one that makes Cloneable indispensable?

I know only two good things about java: I rather like its implementation of enums, they finally did something original instead of "let's look at how C did it and then copy it to our language even if the contexts are completely different and it doesn't make any sense whatsoever". And the fact that it's a rather small language (compared to C++, C#, ...) makes it nice to experiment (research) on it.
Wan
Wan
Not nuts, beans. They're called Java beans.
Fenrisulvur
Fenrisulvur
Guys, this is a pretty mind-numbing thread - it's friggin' easy to tear shreds out of a language.

I guess I'll scour this thread soon and see what balance I can bring, since I write a fuckton of Java, but really, this all seems like the sort of one-sided banter devised by people romanticized by Stroustrup's baby. Java is what I'd term a "nice language" - it's simple, clean, doesn't allow fucktards to write pseudo-cryptographic expressions for string copiers, organizes code-bases into really nice packages (no preprocessor? frickin' sweet), has lots of sweet next-gen (reflection) and "enterprise" (security, lots of the EE stuff) features, and my personal favourite, runs in a managed environment atop a hardware-agnostic virtual machine, where 99% of application-domain code should be*.

It doesn't offer the flexibility of C++ (eg I want to write my own operators damnit), doesn't have much language esoteria to boast about, and doesn't consider the programmer to be right - and so it doesn't get a lot of romanticism, which is probably a huge problem for the managed code cause. I'd like to see the C++ of the managed generation, because it would likely kick serious arse.

But by christ, this thread makes it sound like Java's a sin against nature, like VB or Perl.


*In my opinion. I wouldn't mind discussing this, mind.
BeanDog
BeanDog
Java drove me crazy. Fortunately, I've never been in a position outside of the University where I've been forced to use it for anything significant.

Honestly, I don't remember all the details of why it bothered me so much at the time I learned it. But what I do remember is that when I (not much later) picked up C#, the experience was 100% better. C# just felt better put-together, better thought out.

Also, my users don't have to "install" C# just in order to run my applications. And I'm not forced to advertise OpenOffice.org to my end users just because of my choice of language.
KaptainKomunist
KaptainKomunist
Quote:
Original post by Fenrisulvur
Guys, this is a pretty mind-numbing thread - it's friggin' easy to tear shreds out of a language.

I guess I'll scour this thread soon and see what balance I can bring, since I write a fuckton of Java, but really, this all seems like the sort of one-sided banter devised by people romanticized by Stroustrup's baby. Java is what I'd term a "nice language" - it's simple, clean, doesn't allow fucktards to write pseudo-cryptographic expressions for string copiers, organizes code-bases into really nice packages (no preprocessor? frickin' sweet), has lots of sweet next-gen (reflection) and "enterprise" (security, lots of the EE stuff) features, and my personal favourite, runs in a managed environment atop a hardware-agnostic virtual machine, where 99% of application-domain code should be*.

It doesn't offer the flexibility of C++ (eg I want to write my own operators damnit), doesn't have much language esoteria to boast about, and doesn't consider the programmer to be right - and so it doesn't get a lot of romanticism, which is probably a huge problem for the managed code cause. I'd like to see the C++ of the managed generation, because it would likely kick serious arse.

But by christ, this thread makes it sound like Java's a sin against nature, like VB or Perl.


*In my opinion. I wouldn't mind discussing this, mind.


I don't care that I can't create my own iterators or overload operators. I care that you can't have a list of int's. you can have a list of objects, which can be ints, or you can have a List of , but no list of int's. My largest beef with Java is the poor collections support and the requirements for wrapper classes.
Fenrisulvur
Fenrisulvur
Quote:
Original post by ukdeveloper
If the .Net framework ran natively on non-MS platforms

It does.

Quote:
Original post by owl
ApplicationNameApp.getApplication().show(UsersForm);

This strikes me as an immensely stupid snippet of code, considering that you already have a handle to the form. Frames/JFrames have a setVisible() method.

Quote:
Original post by lightbringer
Agreed on this one. I catch and rethrow as unchecked 95% of the time (in my own game code at least. It's a different story when writing libraries to access external resources). Java might hate me, but if I can't deal with an exception, I can't deal with it, and that's that.

You could add "throws Throwable" to your methods. The following:
public static void main(String[] args) throws Throwable {}

is valid.
Fenrisulvur
Fenrisulvur
Hmm,

Quote:
Original post by BeanDog
Java drove me crazy. Fortunately, I've never been in a position outside of the University where I've been forced to use it for anything significant.

Honestly, I don't remember all the details of why it bothered me so much at the time I learned it. But what I do remember is that when I (not much later) picked up C#, the experience was 100% better. C# just felt better put-together, better thought out.

It might be worth a revisit - I find C# and Java excessively similar.

Quote:
Original post by BeanDog
Also, my users don't have to "install" C# just in order to run my applications. And I'm not forced to advertise OpenOffice.org to my end users just because of my choice of language.

Well, yeah, it helps that the most common OS out there (and I'm not anti-Microsoft - I use and vehemently defend* my Vista install) comes with the CLR pre-installed, but a Java RE ends up on most Windows installs at some point anyway; and Mono doesn't come pre-configured on any other platform.

Also, what's so bad about advertising free open-source software? :(
OO.org is pretty good IMO; and somehow I'd rather that be plugged during an install process than the 6-month Office trial Toshiba shipped on my Laptop image. >_>


*Really depressing that we're driven to this, come to think of it.

Quote:
Original post by KaptainKomunist
I don't care that I can't create my own iterators or overload operators. I care that you can't have a list of int's. you can have a list of objects, which can be ints, or you can have a List of , but no list of int's. My largest beef with Java is the poor collections support and the requirements for wrapper classes.

Hmm, I've never felt hindered by Java's Collections; and on primitive wrappers, does this help out at all?
KaptainKomunist
KaptainKomunist
Quote:
Original post by Fenrisulvur
Hmm,

Quote:
Original post by BeanDog
Java drove me crazy. Fortunately, I've never been in a position outside of the University where I've been forced to use it for anything significant.

Honestly, I don't remember all the details of why it bothered me so much at the time I learned it. But what I do remember is that when I (not much later) picked up C#, the experience was 100% better. C# just felt better put-together, better thought out.

It might be worth a revisit - I find C# and Java excessively similar.

Quote:
Original post by BeanDog
Also, my users don't have to "install" C# just in order to run my applications. And I'm not forced to advertise OpenOffice.org to my end users just because of my choice of language.

Well, yeah, it helps that the most common OS out there (and I'm not anti-Microsoft - I use and vehemently defend* my Vista install) comes with the CLR pre-installed, but a Java RE ends up on most Windows installs at some point anyway; and Mono doesn't come pre-configured on any other platform.

Also, what's so bad about advertising free open-source software? :(
OO.org is pretty good IMO; and somehow I'd rather that be plugged during an install process than the 6-month Office trial Toshiba shipped on my Laptop image. >_>


*Really depressing that we're driven to this, come to think of it.

Quote:
Original post by KaptainKomunist
I don't care that I can't create my own iterators or overload operators. I care that you can't have a list of int's. you can have a list of objects, which can be ints, or you can have a List of , but no list of int's. My largest beef with Java is the poor collections support and the requirements for wrapper classes.

Hmm, I've never felt hindered by Java's Collections; and on primitive wrappers, does this help out at all?


Nope, doesn't help at all. Wrapper classes don't add anything. They are just there to fix the problem of generics and collections not being able to cope with base types.

Show me 1 single advantage of using a wrapper class instead of being able to use the base type and maybe, maybe you could get me to change my mind. But as far as I can tell, C# comes out on top when working with collections and generics.
Stani R
Stani R
Quote:
Original post by Fenrisulvur
Guys, this is a pretty mind-numbing thread - it's friggin' easy to tear shreds out of a language.


Maybe I am under the wrong impression, but I honestly thought (and still think) that we were just poking fun at Java. I use Java both at university and at home for all my game projects and I love it. I have even recommended it to many new people starting out in game programming, along with Python for the less demanding games. That doesn't mean that it is picture perfect and has no quirks, though.

I haven't tried C# since it does not really meet my needs in terms of platforms (I want mobile, web, windows, linux, mac). But there is no real problem deploying Java. For Windows it's perfectly possible to distribute a private JRE along with the game and wrap the startup in an EXE file with a custom process name and a custom icon - the end user won't be able to tell the difference between a Java game and a C++ game that way. Of course, if it's for a small game and the game file itself is ten times smaller than the runtime, then you won't get far unless you violate Sun's license and ship with a stripped-down JRE (but now that Java is open source, maybe there are ways around that?).

Quote:
Original post by Fenrisulvur
You could add "throws Throwable" to your methods. The following:
public static void main(String[] args) throws Throwable {}

is valid.


It would look rather poor to me though if half the methods in my program would be decorated that way. It doesn't add much value. Also, I capture and log throwables in or shortly before main(), I don't want them to escape from there.

Quote:
Original post by KaptainKomunist
Show me 1 single advantage of using a wrapper class instead of being able to use the base type and maybe, maybe you could get me to change my mind. But as far as I can tell, C# comes out on top when working with collections and generics.

The advantage is that the compiler does it for you. You don't actually have to use the wrapped type anywhere else since unboxing also happens automatically when you assign a wrapped type to a primitive type. I never really saw it as a big problem though.
Mike.Popoloski
Mike.Popoloski
Quote:
Original post by FenrisulvurI'd like to see the C++ of the managed generation, because it would likely kick serious arse.

You mean like C#? [grin]
Mike Popoloski | Journal | SlimDX
Fenrisulvur
Fenrisulvur
@lightbringer: Oh, victim of Poe's Law - my bad.

Also, yes, the licensing terms should permit you to hack OpenJDK (and one of many other open-source JDKs) to pieces, if you so desire.

Quote:
It would look rather poor to me though if half the methods in my program would be decorated that way. It doesn't add much value. Also, I capture and log throwables in or shortly before main(), I don't want them to escape from there.

Hmm, fair enough. You'd only want the Exceptions to fall through during development - shipping such a thing would be ridiculous - but yeah, I see why that'd be nice. A compiler option would probably suffice.

Quote:
Original post by KaptainKomunist
Nope, doesn't help at all. Wrapper classes don't add anything. They are just there to fix the problem of generics and collections not being able to cope with base types.

Show me 1 single advantage of using a wrapper class instead of being able to use the base type and maybe, maybe you could get me to change my mind. But as far as I can tell, C# comes out on top when working with collections and generics.

I'm not sure why you're hammering away at this - performance, or convenience? If I take Wikipedia's word on this one, both use wrappers - C#'s just a little more implicit in most aspects than Java. As far as I can tell, that rules out performance, so you're more concerned about syntactic salt?

Quote:
Original post by Mike.Popoloski
Quote:
Original post by FenrisulvurI'd like to see the C++ of the managed generation, because it would likely kick serious arse.

You mean like C#? [grin]

Really? You think C# carries even a quarter of the hubris and romanticism of C++? Where's the contrived stab at multiple inheritance? What about the fact that Microsoft came up with and "owns" the language? It comes a hell of a lot closer than Java, agreed, but I can still picture the undergrads storming out of programming 101-style lectures when they hear C# has replaced their precious C++ as the core language.

[Edited by - Fenrisulvur on November 5, 2009 11:46:20 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.