Have a Nice Steaming Cup of Java 5 859
wap writes "The language/VM/religion that everyone loves to hate is now serving another cup: Java 1.5 is ready for download. The new features of 1.5 have been discussed here before. I, for one, welcome our new virtual machine overlord. I have been using the release candidate, and startup times are noticeably faster, as is overall performance, and the new features like typesafe collections and static imports are great to have. Let the Java flames begin!"
I wait! (Score:5, Insightful)
The language wars never ceases to amaze me (Score:4, Insightful)
I try to stay pragmatic about the programming languages that I use. For some jobs, Java would be my last choice, and for some it seems a natural fit. When writing hardware near code, or platform dependant stuff on driver level, nobody in their right mind would attempt to use Java. For high level rapid prototyping, Java is a often a quick and easy way of getting things done.
Re:Nice language... bad interface (Score:3, Insightful)
Java is not open source, hence I do not go around compiling it anywhere.. I just wait and hope that Mr. Star gives a yellow light on the project.
Re:Stability/memory leaks (Score:1, Insightful)
For example, you could have the following code:
This could be fixed by inserting "hugeObject = null" right before while(true){...}. So, yes, you can have memory leaks in Java, but if you do, it's really your own fault.
Re:Stability/memory leaks (Score:5, Insightful)
Java should never have memory leaks...
All the memory managment should be done by the VM as far as I know...
unless there is some advanced stuff i'm just not aware of?
Not memory leaks as such, but "memory leaks" for all practical purposes. How? Well, if you forget to nullify references to objects you no longer use, the garbage collector obviously cannot reclaim that memory..
Write once, run anywhere (Score:3, Insightful)
Bytecode Compatibility (Score:5, Insightful)
Whilst code that uses the new language features must obviously be compiled with the v1.5 JSDK, this means that it must also be run on the v1.5 JRE.
This may inhibit the use of Java 5 by projects that want their programs to run on a v1.4 JRE.
- Brian.
Re:Thanks to our supporters (Score:5, Insightful)
your cut is the fact you can use it for free!
A. Coward
mod parent down (Score:5, Insightful)
No, I don't think you should write ls or grep in Java. However, I'd say that you also shouldn't be writing an invoice processing system in C or C ++.
Re:5 or 1.5? (Score:5, Insightful)
Fairies have wings, not tails.
I agree though, the naming of Java is consistently confusing. Should I upgrade from Java 2.. err.. J2SE.. err.. Java 1.3.1_08 to Java 5 or to Java 1.5 or indeed Java 1.5.0. Oh, and is J2EE 1.4 compatible with this new one?
It could be much simpler..
~Cederic
Re:Still no operators... (Score:3, Insightful)
I take it from this comment that you haven't actually tried java. You can "explorate" to your hearts content, and there are many ways of doing the same thing (some obviously better than others)
> mostly because of the plethora of APIs (WebLogic, etc.) that corporations force you to use over it...
Now this comment just has me bamboozled... You mean that Weblogic holds sway over you and force you to code in one way over another? Surely weblogic [bea.com] is just an appserver? Which runs code designed to the standard J2EE API spec? The same as using Tomcat [apache.org] , JBoss [jboss.org] or Geronimo [apache.org] or even Hibernate [hibernate.org]? (All of which are free and opensource, and follow the same J2EE spec that Weblogic does -- they just solve separate parts of it, and can be combined to do it all if you require)... I fail to see how this is a corporation forcing you to use one method of coding?
Sure, if you are only going to look at one way of achieving your goals, then there is only one way to go...
Dear Sun (Score:2, Insightful)
Re:Nice language... bad interface (Score:1, Insightful)
I don't particularly like the idea of many colleges wanting to move to Java as the language of choice. Sure it hides a lot of things from a new programmer, but if someone is going to college in computer science - they shouldn't have it hidden from them! Not to mention that C++ is somewhat of a 'standard' language. Learn it and you can move to other languages REALLY easily. Just my $0.02....
Re:The new for loop and type safe collections rock (Score:5, Insightful)
Re:Bytecode Compatibility (Score:3, Insightful)
I would hope that 1.2, 1.3 and 1.4 bytecode would run in the 1.5 JRE. I think it's ambitious to expect 1.5 bytecode to run in a pre-1.5 JRE - the language has new features that such JREs don't know about or support.
While you could obviously write code that interprets 1.5 bytecode so that it will run on a 1.4 JRE, and make it possible to automagically create that code at compile-time, including it by default in the compiled 1.5 code would be wasteful as it's not required to run in a 1.5 environment.
So yes, it will inhibit the use of Java 5 by projects that wish to run on JRE1.4. And trust me, I'm extremely distressed that my company is still stuck on Weblogic 6.1 as that only works with JRE1.3, so I haven't even been able to make use of J2SE 1.4 capabilities in code, but life goes on.
~Cederic
Re:Man, that's not really fair (Score:3, Insightful)
Re:Is it C# yet? (Score:4, Insightful)
Priority #1 for Sun was not to break the bytecode format. Priority #2 was to ease the life of programmers
The only thing which really will make a difference on code generation level will be the meta data, this one will make life easier for the implementors and for the users of servers. Soap instantly comes to my mind with the C# like @webmethod metadata. No more post and precompilers for doing that stuff, yiehaa.
Hjelfsberg is a smart guy, although I dont share his views on unmanaged exceptions, he is dead right with his comment on this.
Re:Well, since you people ask this.... (Score:3, Insightful)
http://www.joelonsoftware.com/articles/APIWar.h
If you like C#, VB and
I love the hate (Score:5, Insightful)
There are two things that make any really big language a target: 1) people start using it for everything, including things its not suited for. 2) junior folks without a lot of compiler or cross-language experiences will cut their teeth on Java, and at that point in one's career it is sometimes considered cool to blame a bad application's flaws on the language it's written in.
Java has plenty of problems. There are brilliant essays written on it; some of them by Sun engineers. But the complaint linked to in story was so bad by comparison, however, I doin't feel offtopic in addressing some points it raised:
there are a thousand "super-efficient"
No.
it takes 12 objects instantiated in 4 containers to flip a bit in a byte
Oh, I see. You're flipping bytes.
there is the substitution of native performance of compiled code to code compiled "Just Too Late" combined with exceptional memory usage that entails
The VM is more work. Strangely, you will have trouble finding benchmarks that make other comparable high-level languages look way faster than Java on the same _non-user-facing_ application.
As always, code in C, assembler, or another specialized language if you really need to.
The speed thing is well-addressed elsewhere. Enough said for now.
we get the garbage collector which is scientifically fine-tuned to run just when user is expected to interact with the application in most time sensitive manner
People love to bitch about client-side Java. It's as if all the flaws they're used to from other client side systems are fine, because they're used to them, and every foible of Java is worth agonizing over as if it were the worst thing in the world.
I dunno what else to say, but I wrote an enormous graphic-intensive video game in it and it runs fine. And what I did is nothing; somebody cloned the QIII engine to the point where it plays actual Q3A maps (with multiplayer) at respectable framerates.
Once again, someone shows me a shitty client app written by a team of 30 22 year olds in Thailand and claim it's proof that Java sucks. Congratulations.
multiple, insideously incompatible with each other, versions of the so-called "universal" VM
Yes, leaving aside the fact that Microsoft deliberately broke VM compatibility. Not just in one or two big ways. In a lot of little ways. As in on purpose. Great example. Very honest.
There is a giant test suite. Gets better all the time. Reputable VM's pass it. Most of all, though, I just don't run into the cross-VM problem in the first place unless I'm doing 1.1 development for browsers, see above...
We actually abandoned DB2 8.x release because noone could deal with the havoc the DB2 admin tools were causing with various other retarded banking related Java apps.
There we go. The truth outs. You overpaid for a shitty product. Congratulations. You can do that in C or Fortran, too.
Blame the language, though. Don't blame yourselves for picking a bad app.
Oh well, time to have me shot on sight.
Have a nice day.
Re:Stability/memory leaks (Score:5, Insightful)
Java's garbage collection sort of creates a general laziness among some coders who don't clean up because they don't have to.
This is a missconception of yours. In Java, you CAN'T clean up. In C++ you say , in Java you just say Probably I should correct my sentence above: freeing memory IS CLEANING UP, nothing else, so all Java programmers clean up automatically.
All it takes is one pointer *ahem* reference to some object that contanis a reference to another, that contains an array... If you've got a few hashes and arrays in the way, it may be difficult to tell exactly where memory is being used, thus memory leaks.
Well, for a GC that is not difficult to tell at all. Not harder as for a human
In C++ somewhere somehow one had called delete. So at the point where in Java a hughe amount of memeory is referenced, and probably never used again, you have a dangling pointer in C++.
but would what happen if two objects referenced each other but nothing else referenced them. Would gc know to follow the links between the two and see that nothing in the main app is using them?
Of course, thats the point about garbage collection
If you have a memory leak in java then it comes from things like that: If you do somewhere something like this you will run into an OutOfMemoryException sooner or later
It is really no difference if one "forgetts" a delete in C++ somewhere or one forgets a x = null; in Java somewhere, but the Java program won't crash indeterministic, thats a difference.
angel'o'sphere
Re:J2EE -- 1.3.1 still (Score:2, Insightful)
Help me out here. Are you after a specifically IBM implementation of the Java VM for Windows, or is there another reason why you can't go to http://java.sun.com/j2se/1.5.0/download.jsp and download the Windows version from there?
No intent here to flame, just curious about your reasoning..
~Cederic
Re:Write once, run anywhere (Score:3, Insightful)
Rather than mod you troll, here's a simple answer.
I honestly wasn't trying to troll. If you walk into a computer store and look at all the off-the shelf consumer-level software products, they're all for Windows. I was hoping that Java would have changed this so that you can buy one of these off-the shelf products and run it on any platform. I know that it has gained acceptance at the enterprise level, I was actually referring to the consumer level.
Re:Java is to C as ... (Score:3, Insightful)
Re:Is it C# yet? (Score:3, Insightful)
A C# fan accusing Java of copying?
Excellent. Go Sun, Go!
Re:Java is to C as ... (Score:3, Insightful)
I was about to mod this as Funny, but then I realized that you weren't making a joke.
Back in the day, the tagline was "C -- all the speed of assembly, with all the programming ease of assembly."
--
Free gmail invites [slashdot.org]
Re:The language wars never ceases to amaze me (Score:3, Insightful)
If you compare language to language, say Java to C, C# or even Ruby and Python, it is easy to see why Java is "slow" and "bloated". But Java is to be compared to something like
Java is a platform. Java provides on-the-fly class loading and verification including digital signing of the code, very fine-grained security model (you can create your own sandbox with whatever security rules you want), first-class GUI (fast and responsive if you know what you are doing), tons of class libraries, enterprise APIs (which, minus ill-fated EJBs, are very popular), crypto and much more. .NET and this is what you need to measure Java against.
So the only "other" platform of similar mugnitude is
They fucked up Java (Score:2, Insightful)
Now they added a lot of features that are nothing but crappy compiler sugar. Most of them badly implemented.
With java generics you can compile this: Of course, you cannot assign the return value to a T[] because it is really an Object[], so, where is the type safety? All this is without mentioning that Java generics don't provide any performance benefit (which you would naively expect because you believe that you do not have to cast anymore).
Java generics are just compiler sugar for automatically generating casts.
Maybe the fact that Java is now managed by a comittee instead of a few people who do know about language/compiler design has something to do with this.
Maybe they are just trying to make it "easier"for those who don't know how to program. Again, it doesn't work.
Something more or less like this happened when C++ was standarized. They came up with an overly complicated monster language, but at least the specification was not a broken one, just complex.
They could have added pass of parameters by reference (at least for primitives), which would have been very useful in real world situations. But instead they decided to add a ton of crap.
Java is doomed now. Too bad it was my favorite language. Now I have to look for another language. Maybe D [digitalmars.com]?
Re:hmm. but how does this compare with Mono (Score:3, Insightful)
You dont see companies developing 5k class projects in Mono, but thousands (if not more) do with Java and
My city last month?
60% Java
15% Perl
10% C/C++
5%
5% COBOL
5% other
I cant hire Java and Perl programmers fast enough.
Re:Passe... (Score:1, Insightful)
Awkwardness in syntax? Sorry, just don't see it and haven't heard any legitimate complaints. No, it's not Visual Basic because it actually has to do something. The virtual machine that is provided in Java is generic and a simple environment to code in. The language tends to enforce decent coding style due to the VM restrictions (no odd pointer dereferencing/wordsize assumptions).
If you are really looking for C/C++, you can always leverage the native integration that has been available since day 1 to ease the migration to the Java platform.
Hats off to K+R for C is appropriate, but don't revise history by thinking that Java was developed in in vacuo of other languages. It stood on the successes of C and C++ and closed up language holes by providing a better class/inheritance/object representation.
A.C.
Exactly (Score:3, Insightful)
Re:Passe... (Score:1, Insightful)
Why? ML manages generic collections perfectly well without wrapping everything in an object.
Re:Rapid learning (Score:5, Insightful)
Joking aside, it kills me to see the amount of research and due-diligence that goes into debunking a Microsoft-sponsored benchmark, but when it comes to Java most everyone starts spouting nonsense. People will remember their experiences from 8 years ago, or a bad app, etc. and immediately conclude that Java must suck for every conceivable application.
Java is a tool - no more, no less. Use it where you think it is useful and leave on the shelf if you don't think it will help solve your current problem. Most mature developers know when and where a tool should be applied.
SLOW (Score:3, Insightful)
Since 1.0 there have been three major speed holdbacks preventing me and many others from adopting java:
1) array access too slow due to boundary checking (no, their optimizer doesn't work for my cases, and this is a problem a lot of scientists/performance hungry people have).
#1 has some good solutions on 64-bit platforms developed at the university of georgia, but sun won't include them, nor will they enable a flag on the jvm to turn of bounds checks. GCJ lets you do it, but can't compile everything I need yet.
2) casting raw memory to objects requires a copy. Java needs a structured object without a header to overcome this, such as the struct proposal, which is in the top 25 rfe's yet has no comment from sun.
#2 has a well understood solution that sun is apparently too lazy to even consider implementing.
3) No way to do fast 2d/3d rendered graphics. Too many call overheads & copies.
Sun needs to ditch AWT/Swing, and probably needs to open source java to overcome this. They've proven their inability to keep up a reasonable mapping to modern featuresets.
I'm probably going to have to give up and learn c# since I'd like a more modern language with good tools, but java just doesn't have the speed.
Re:Swing on OpenGL (Score:3, Insightful)
Any idea if there's a way to turn this on or off programatically?
Having this on the command line is ok, but if someone is using Mesa3d(software openGL on Linux) instead of hardware acceleration, it will be slower than the default rendering path of X11.
Here's [cox.net] a screenshot of my JTurtle [cox.net] application running on accelerated openGL with jdk1.5 and using the new look and feel.
Re:I love the hate (Score:3, Insightful)
there are a thousand "super-efficient" .jar libraries required by a "Hello World" app
No.
Well it certainly feels that way when you try to load those apps. They all have excruciating startup times. Perheaps I am wrong and instead they check the integrity of my bank account or weather in China for my convenience. I dont really care, but 5-6 seconds of startup for a few boxes of interactive input is not really acceptable.
it takes 12 objects instantiated in 4 containers to flip a bit in a byte
Oh, I see. You're flipping bytes.
I do not write Jave apps but I am quite familiar with OOP and also with the great zeal Java disciples apply it to everything. Like every other paradigm, one-size-fits-all applied to extremes allways results in the effects I described. My comment was to illustrate that if you go nuts and have hundreds of objetcs, events and containers all over the place, you are bound to end up with huge overhead. This is not restricted to Java by any means and many a C++ library suffers from the same issues. Java from what my (cursory I admit) glance at the language/libraries takes this to just such extremes.
there is the substitution of native performance of compiled code to code compiled "Just Too Late" combined with exceptional memory usage that entails
The "Just Too Late" was just a pun on the hype JIT is endowed with. The memory requirement (if you had read the thread where the original post was made) was confirmed by just about anybody including those who advocate Java. As I explained in there, if you have a 10-15 meg per JRE + 10-50 (memory managment seems to suck badly for the apps we use) per instance of an application (no way an OS can share DLLs or .so's here) in a multi-user environment, and this caused by 4 lines of input, ridiculous e-commerce apps, one has problems. Remember, I am not a Java theorist. Merely a user of apps written in your favourite cure-all language.
multiple, insideously incompatible with each other, versions of the so-called "universal" VM
Yes, leaving aside the fact that Microsoft deliberately broke VM compatibility. Not just in one or two big ways. In a lot of little ways. As in on purpose. Great example. Very honest
I dont care who broke whose toys. As far as I (the user) am concerned, the whole Java thing is an umanagable, deployment and maintenance-wise, mess. If I am forced to let people download and install JRE's du-jeur for each e-commerce craplet out there, this is far worse then any other "client side" app. Also as I indicated in my posts, all of these Java apps fail miserably because their purpose can be accomplished by much simplier and more reliable means: plain HTML with smart server-side processing. That would mean no client-side pandemonium for anyone. Java was hyped as a soultion to deployent of seamless, headache-less OS independent client side apps, and in my user experience it turned out to utterly fail in this area.
We actually abandoned DB2 8.x release because noone could deal with the havoc the DB2 admin tools were causing with various other retarded banking related Java apps.
There we go. The truth outs. You overpaid for a shitty product. Congratulations. You can do that in C or Fortran, too.
Besides rather flippant attidude, your thinking is simply wrong. Not only I have this problem with DB2, others have with Sun (Java's maker) admin tools and Oracle DB tools. But all of this is besides the point because the main place we use Jave in is also crap. Crap in many smelly varieties from many sources. While you might be a guru capable of writing 3D games and Self-conscious AI systems in Java, this is not what Java was advertised to us poor business sods for, and that which it was advertised for noone seems to be able to make work. And that is all I care about. Unfortunately for you, as I mentioned in another post, we the users will have the final word on this, not you in your Java 3D castle Mr.Java Wanker. Trust me on this one.
Re:5 or 1.5? (Score:1, Insightful)
No, no! Fairies wear boots!
Sugar != Bad (Score:3, Insightful)
Re:Stability/memory leaks (Score:1, Insightful)
First of all, there's nothing particularly optional about Python GC. It is compiled in by default. I don't even know exactly how to disable it. It's not a configure script flag.
Secondly, the "special GC flag that is added to the normal overhead of your classes" is just a bit flag (Py_TPFLAGS_HAVE_GC) that is OR-ed into the tp_flags field of a type struct in C. What overhead are you talking about?
Of course, most people write their Python classes in Python, so they don't need to fiddle with bit flags to benefit from Python's GC. The builtin Python types have this flag enabled, including object, the base type of all new-style classes.
The grandparent comment has a link to the gc module, which merely allows Python programmmers to set some parameters on the garbage collector. Just out of curiosity, is there any such package/class in Java?
Re:The new for loop and type safe collections rock (Score:4, Insightful)
The new for loop most certainly is syntactic sugar. It's taking something we could do before and shortening it into a new construct.
However, a lot of folks use 'syntactic sugar' as a derisive term. It's not. It saves programmer time. Generally the times that it's bad are when it's (a) hiding what's really happening to a degree that introduces bugs, or (b) misguided, like SQL's attempts at being English-like.
Generics != C++ templates (Score:5, Insightful)
Generics in Java have a smaller scope, when compared to C++ templates. The objective in Java is to provide a type-safety mechanism for containers. In C++, it is much more than that. Unfortunately, it is this extra ability in C++ that makes for some really complex code. Not sure if this has already been mentioned in this story, but it has been theorized that C++ templates are themselves turing complete (though I havent seen a proof to that effect).
I'm a bit puzzled by all the generics nay-sayers. I have tried out the feature, and they augment the language. I have yet to see a downside to this feature in Java (unless one counts the inability of the compiler to fully utilize the additional type-safety in compiler error messages). What is all the flap about?
Re:Java is to C as ... (Score:1, Insightful)
Don't get me wrong, I like C#/VS.Net quite a lot. But it's a different animal. I can run Java apps anywhere (yes, you can run .Net apps on Linux, but sorry, it's not an official part of the release and is reminiscent of the old Blackdown ports of the JDK/JVM: interesting, but not ready for production), while C# has some great aspects and a bit niftier development environment (I like IntelliJ better for what it does, but there are more tools in VS.Net). But basically C# only overrides Java if you're platform-dependent and I'm not even sure about then.
Not really. (Score:5, Insightful)
While I think "write-once, run-anywhere" is a bit of a misnomer, it does actually live up to the hype, imho.
You can't really appreciate it however, until you've spent weeks porting C code between platforms, and a few hours porting similar Java code.
I've had headaches porting perl too (though I must admit its much better now). Things these days are much better for people *trying* to develop cross-platform applications in Java and a number of other languages and APIs, but when it gets sprung on you as a requirement late in the game (latter revisions, new customers, etc) porting a Java app is a godsend.
There's alot of valid reasons to hate any language (I've studied 22 languages and in their own way, I think they all suck), but that particular reason doesn't apply to Java.
Re:I love the hate (Score:3, Insightful)
I'd love to see a code example for that.
Here's mine: Leave the declarations out and it's one line. Regardless, there are no objects or containers involved.
Are the rest of your assertions so flimsy?
Re:Passe... (Score:3, Insightful)
Re:I love the hate (Score:3, Insightful)
Stand and salute the logic!
Re:Stability/memory leaks (Score:4, Insightful)
That's the whole point of the garbage collector:
a = new Class1();
a = new Class2();
The Class1() object will be picked up by the garbage collector and deleted (assuming the garbage collector is not broken).
a = new Class1();
a = null;
a = new Class2();
This defeats the purpose of having a garbage collector.
Re:Stability/memory leaks (Score:3, Insightful)
a = new Class1();
a = new Class2();
The Class1() object will be picked up by the garbage collector and deleted (assuming the garbage collector is not broken).
Oh good grief. Isn't that blindingly obvious? Apparently not...
Perhaps I should have clarified my original comment by saying something like "nullifying references to reachable objects you no longer use", considering that my comment got, uh, about 10 responses which all totally missed the point. *sigh*
Yes, in most cases nullifying references is not needed since the application is usually designed so that objects go out of scope when they're no longer used. However, in certain circumstances that approach might not be enough.
Consider a situation like, say: Now, if doSomethingElse() takes a long time to finish (say, doing i/o or a heavy calculation etc.), or requires lots of memory, it might not be a bad idea to first nullify a, as in the example above.