Why must Java suck?

Page 4 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: BikeDude
Originally posted by: jbourne77
While I see his point, I also recognize that regardless of whether or not the exceptions are checked, you've busted the app in most cases by introducing behavior that is unexpected by B. Granted, without checked exceptions, the app will at least run, but it will likely act quite unpredictably.
Not necessarily. In my experience you rarely care for specific exceptions. Most exceptions will halt whatever operation is currently taking place, and those specific that you care about you typically handle as needed.
The problem being that you can easily lose track of those important exceptions without the compiler's help.
And I doubt DLLs has much to do with this. Consider Anders' background (one of the lead designers of Borland Delphi) and I think you'll find DLL-hell doesn't factor into this. If you use a third-party library (in Delphi they usually come with full source), it should be reasonably simple to update said library without breaking your own code. If your code has to know about every exception thrown by methods in that library, then something is awry. (The developer will be punished each and every time the libraries are updated)
I guess people in the java world are just better at carefully planning and sticking to their apis ;). But seriously, it might be nice to have an updated library "just work" despite small changes but it's that kind of Microsoftian attitude that makes you believe that everything is just fine and then, months later, someone discovers the huge security hole that you didn't anticipate. You should always know what is going on in every piece of you code (you don't have to keep it all in your head at the same time, that's bad design, but at some point you should understand the intricacies of every piece).
My guess is that checked exceptions makes it difficult to develop large Java projects.
I wouldn't have it any other way :) Sometimes I wish there were no unchecked exceptions, although obviously that's not possible. The most destructive things I've seen are when seeming harmless pieces of code, like log statements, throw an unchecked exception and blow the hell out of a large transaction. There's enough trouble dealing with the ones you can't plan for.
Bottom line though: I can't help but notice that our competitors who use Java, they staff more people, incur bigger downloads, use more disk space (OK, not really important any more), burn more memory, use more CPU and... Their products look like crippled versions of our software (feature wise).
I'd love to take that bait but that argument's been had many times :p I think jbourne77 summed it up pretty well.
It is very hard (impossible) to beat Borland Delphi if your target is 32-bit Windows and you have any sort of GUI in your app. And for many apps it provides an easy entry into .net as well. (as well as x86 Linux) Its aging compiler is only on par with VC++ 2.0 or so optimization-wise, but compared to Java the result flies... (plus the compiler speed is insanely fast)
Agreed, Delphi is a sweet platform.

As for the exception thing again, I guess I don't care too much one way or the other, you just have to be aware of your situation and put yourself in an appropriate coding mindset and use appropriate patterns. If I have a choice, I like checked :)
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: znaps
A lot of the newer J2EE frameworks are moving away from checked exceptions. Spring for example rethrows all those JDBC related exceptions as unchecked Spring exceptions. So the trend in Java is similar to C#.
Interesting, iirc, hibernate does something similar. I think the design philosophy there is to allow you to write really light-weight code, functional almost, where you're just saying what should happen rather than how. Then everything else becomes an aspect, to be handled in an orthogonal manner. That is a nice way to do business logic, I guess, but I'd be scared to write anything really heavy weight with it (that would be used as an api for other layers) without investing some code in error handling and comprehension.
 

itachi

Senior member
Aug 17, 2004
390
0
0
whoops.. didn't mean to post.
they really need a delete option.. or something to check for empty posts.
 

znaps

Senior member
Jan 15, 2004
414
0
0
Originally posted by: kamper
Originally posted by: znaps
A lot of the newer J2EE frameworks are moving away from checked exceptions. Spring for example rethrows all those JDBC related exceptions as unchecked Spring exceptions. So the trend in Java is similar to C#.
Interesting, iirc, hibernate does something similar. I think the design philosophy there is to allow you to write really light-weight code, functional almost, where you're just saying what should happen rather than how. Then everything else becomes an aspect, to be handled in an orthogonal manner. That is a nice way to do business logic, I guess, but I'd be scared to write anything really heavy weight with it (that would be used as an api for other layers) without investing some code in error handling and comprehension.


Exactly - it's really nice to be free from all the fluff and just concentrate on your objects and how they interact. Everything else is not exactly an 'aspect' in the coding sense of that word, but it is dealt with outside the scope of your normal business logic. It's a combination of aspects and the 'Inversion of Control' pattern.
 

replicator

Senior member
Oct 7, 2003
431
0
0
The java language itself is quite good, but Java web frameworks are pretty fugly compared to asp .net. (except for maybe tapestry)

I recently joined in on a pretty large struts project with a budget that has been overextended by millions of dollars and with a long ways to go still. Primarily, the business didn't get the requirements right but productivity with jsp and struts is far behind asp .net.
 

C++ is utter crap. Plain C is a great language, C++ is a bloated sack of crap. When talking OOP, Java rapes C++. C++ is the most disjointed, confusing, cluttered language out there. People think they're cool because force themselves to work with all the bass-ackwards constructs in C++, but all they are doing is wasting time on an archaic relic of a language. You can't retroactively graft OO on a language, C++ is the proof. Ok, I am bitter having programmed in it for over 10 years.

Bjarne Stroustrup is always talking trash about Java. Maybe thats Java currently tops it? Performance-wise Java sucks, but if I can get paid the same slinging Java or C# vs C++, hell yeah I will take the modern language.

PS: Spring & Hibernate rock. Total revolution even thought it's a revolution to the way things should have been in the first place. EJB sucks.
 

znaps

Senior member
Jan 15, 2004
414
0
0
R0xors | Sux0rs
---------------------------------------
Java | C++
Spring | EJB
Hibernate | Bjarne Stroustrup
 

imported_BikeDude

Senior member
May 12, 2004
357
1
0
I hope this link hasn't been posted yet: http://www.mindview.net/Etc/Discussions/CheckedExceptions

I've read that article before and it dives into the heart of the checked vs unchecked exception debate.

What I don't quite understand is what is done about the exceptions raised by the RTL and compiler generated checks?

E.g. in Delphi, the following will trigger exceptions:
i := 0;
x := 100 / i; (EDivByZero exception, unless fpu exceptions have been disabled)
given an Integer i, i := MaxInt + 1 produces an ERangeError exception

What I'm getting at is that there's even some CPU related exceptions that you can catch, but I guess the Java VM doesn't have to worry about that...? OTOH, surely Java has a division by zero exception?
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: BikeDude
What I'm getting at is that there's even some CPU related exceptions that you can catch, but I guess the Java VM doesn't have to worry about that...? OTOH, surely Java has a division by zero exception?
Java does have unchecked exceptions. Anything that subclasses RuntimeException need not be explicitly handled. That covers arithmetic errors, null pointers and such. There's also Error which is sort of a sibling of Exception (both are subclasses of Throwable). Errors don't have to be caught either, and they generally shouldn't as they get thrown when something is wrong with the vm (like missing classes or out of memory).
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: znaps
Exactly - it's really nice to be free from all the fluff and just concentrate on your objects and how they interact. Everything else is not exactly an 'aspect' in the coding sense of that word, but it is dealt with outside the scope of your normal business logic. It's a combination of aspects and the 'Inversion of Control' pattern.
I don't really know the meaning of the word aspect. I was taking a stab and evidently I missed :p

I read an intro article about IoC the other day, featuring Spring and some others. I haven't had the chance to work with it professionally but I hope I find the time sometime to fool around with it at home.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: BikeDude
I hope this link hasn't been posted yet: http://www.mindview.net/Etc/Discussions/CheckedExceptions

I've read that article before and it dives into the heart of the checked vs unchecked exception debate.
His point about the dangers of swallowing exceptions is a good one but I'm not quite convinced. Swallowing exceptions blindly is horrible thing to do, you either need to put in a comment saying why this was expected and fits with the business rules, or at the very least, log the error message, stack trace, and the entire chain of exceptions if there is one.

Speaking of which, I didn't see a date but I bet the article is pretty old because the sample code duplicated the idea of exception chaining which was introduced in 1.4, I believe. I think the burdens of checked exceptions are somewhat relieved by chaining because you can easily wrap a low level exception in a more coherent high level one, simplifying the error handling but still allowing you to see full stack traces for debugging.
 

Stuxnet

Diamond Member
Jun 16, 2005
8,392
1
0
That's a really interesting article... I especially appreciate the ExceptionAdapter class. I might play around with that just to experience unchecked exceptions in Java.
 

SinNisTeR

Diamond Member
Jan 3, 2001
3,570
0
0
I love java. You can basically learn it on your own. Documentation is impecable and language is versatile. No complaints here.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: jbourne77
That's a really interesting article... I especially appreciate the ExceptionAdapter class. I might play around with that just to experience unchecked exceptions in Java.
There's not a whole lot you can do with that ExceptionAdapter that you can't do with:

} catch (Exception e) {
..throw new RuntimeException(e);
}

With the adapter you're putting in extra, redundant work and you're losing the stack trace between when the adapter is thrown an caught.
On the other hand, throwing the plain RuntimeException leaves you without a visual pattern (catching RuntimeException isn't necessarily intuitive) and it could get in the way if you're dealing with other specific runtime Exceptions like with Spring or Hibernate.
If I was to use that pattern, I'd just subclass RuntimeException with copies of all the constructors and leave all the default method implementations.
 

EpsiIon

Platinum Member
Nov 26, 2000
2,351
1
0
Originally posted by: Deeko
Doing an assignment for my OOP class that must be done in Java.

It would be so much easier in C++.

Java is awful.

Easier in C++? Never heard that one before...

EDIT: Ahh, multiple inheritance, gotcha.