Have a Nice Steaming Cup of Java 5
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 for the first bug reports ... and version 1.5.1 ...
In typical /. style, as soon as Java is as much as mentioned, everybody expects the flame wars to erupt, and they always do...
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.
No.. say I want to port Perl to my ToasterOS. I download Perl, compile it on ToasterOS (Presuming ToasterOS has all the prerequisites), and voila.
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.
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.
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..
Java had all this hype about it when it was promoted nearly a decade ago, but it never got anywhere close to the point where you could walk into your local computer store and buy a major software package that could be run on any platform. I recall that Corel was going to attempt to release a WordPerfect that ran using Java, but that's the most I heard of it being adopted by mainsteam software developers. Does anyone think it will ever take?
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.
I hate to say this, but:
your cut is the fact you can use it for free!
A. Coward
That's not interesting, that's cliche. People have been saying that for years. Let's be honest: virtual machines are where business code is going, and business code (enterprise applications, server side stuff, etc) is the primary focus of Java these days. .NET is a clear indication that this trend is a real one, and that that's where the industry is heading.
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 ++.
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
> Its' not the case in Java where it sounds like there's only 1 way to do each thing
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 is just an appserver? Which runs code designed to the standard J2EE API spec? The same as using Tomcat , JBoss or Geronimo or even Hibernate? (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...
Please make your Windows (XP) Java run time environment download available on the FRONT PAGE or at the most 1 click away. Your latest website is very tricky to navigate and very annoying and what's the point of taking a Java class (which I'm currently doing) when the majority of Windows XP users don't even have the fucking run time installed by default (damn Microsoft!). I mean look at this mess. It's 5 clicks to the .exe file! Who is Joe Schmoe going to know what the hell a "run time environment" is when they're NOT EVEN interested in Java, except in the software they want to install! (i.e. Azureus bittorrent client).
Please add a image button (so people see it, make it big and pink or red if you will) that says something like "Windows XP users DOWNLOAD to run your favourite Java applications!"
Thank you.
Yours Truly,
Typical-Family's-Free-College-Long-distance-Tech-S upport.
Yes! Thank you! I've never liked java all that much - not because the coding is difficult, I just don't like the vm interface to things. I can write something up in perl, and run it wherever I like!
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....
The new For loop may seem to be just syntactic sugar, but it isn't. It really does make the code look a lot cleaner isn't that the definition of syntactic sugar?
Right. Those Java checked exceptions are so "confusing".
No folly is more costly than the folly of intolerant idealism. - Winston Churchill
No Hjelfsberg is totally right. The extensions are syntactic sugar. But still they are useful, because, you gain coding efficiency that way. Autoboxing, foreach, generics are all implemented in a way not to break the byte format, but you still need less code for doing jobs like iterating lists fetching elements from data structures and so on. Day to day stuff which you used every 10th line or os.
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.
Here's why:
t ml
.NET that's fine. Unfortunately MS's revenue stream requires that they change your environment on a regular basis. In my opinion that's the worst thing in the world for professional developers. Proficiency comes with experience and if you shift the syntax and grammer around on me every couple of years it's pretty hard to get really good at anything. At least Java is, pretty much, the same now as it's always been for nearly 10 years. Can you say that about VB?
http://www.joelonsoftware.com/articles/APIWar.h
If you like C#, VB and
You can't hate any language as much as some people hate Java until it's really reached critical mass.
.jar libraries required by a "Hello World" app
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.
Want to Know How to Cheat the GPL? Read On!
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
Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
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
Depends on what you define as paradise really... around here we "lovingly" refer to the VS.NET Gui builder as "The Blob Generator". All you anti-patterns folks, you know what I mean.
PageTurner Reader: open-source e-reader for Android with cloudsync. http://pageturner-reader.org
A C# fan accusing Java of copying?
Excellent. Go Sun, Go!
- jon
Ganymede, a GPL'ed metadirectory for UNIX
Java is as far above C as C is above Assembly.
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
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?
My heart is pure, but make no mistake, it's pure evil
Over 50% of the .Net libraries have not been ported to Mono and may never be. Mono is pretty cool but until it is fully ported it will remain years behind Java and .Net. You cant compare them like you cant compare java to perl. Java and .Net are very much competitors and will continue to dominate the industry in their niche. Companies need security (as in a future) for their multimillion projects. It took Java ~6 years to self promote. If Mono severely ramps up their efforts, they MIGHT reach the plateau. Java was first to the punch, which is a huge advantage. I would wager my hunting dog that Mono will not overtake java in the next ten years. If MS is lucky and throws enough money at .Net, it has a decent chance.
.Net. Dont believe me? Go count job postings for programming at Monster in a city near you.
.Net
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.
Are you intolerant of intolerant people?
Uhh...Java of course borrows heavily from C and C++, but the language fixed so many problems with C++ objects and C pointers. The requirement for JIT forces certain simplifications into the language and these turned out to provide a more complete and useful language set than the free-for-all that C provides. I personally enjoy the free-for-all in C as it offers the best chance (aside from assembly) to explain to the compiler exactly what you want to do from a performance perspective while Java makes the creation of user interfaces and simple, non-performance critical applications simple and safe to express.
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.
And not only was it faster to write in the first place, but the chances are your app will run on Windows out of the box without having to add arbitrary WinSock calls around the place. And it will run on BSD without adding extra network headers and libraries to the makefile after discovering half of them are missing from the default. And it will run on OSX without any knowledge of that platform at all. WORA is indeed real until people try to break it with specifically crafted examples. :-)
Karma: It's all a bunch of tree-huggin' hippy crap!
It's a bit annoying, yes, that autoboxing is required to use primitives with collections, but that was going to be a problem irrespective of whether generics were implemented at all.
Why? ML manages generic collections perfectly well without wrapping everything in an object.
Sir, I regret to inform you that you've demonstrated "critical thinking" within a hostile forum. You are no longer allowed to read Slasdot. Move along.
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.
Bah, each new release I try hoping they'll do something about the speed since I like the language better than c/c++.
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.
"Who is the Journal of Quantum Physics going to believe?" --Stephen Hawking
The openGL feature is really cool.
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 a screenshot of my JTurtle application running on accelerated openGL with jdk1.5 and using the new look and feel.
"If they have both, tell them we use Linux. And if they have that, tell them the computers are down." -Dave Chapelle
Fairies have wings, not tails.
No, no! Fairies wear boots!
Move on. There's nothing to see here.
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?
I both do and do not agree with this.
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 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?
There is no such thing as luck. Luck is nothing but an absence of bad luck.
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.
-- Bitchslap aka Echo the Wonder Tube
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.
The key difference between a Programmer and a Senior Programmer is that one of them is Mexican.
"...if you forget to nullify references to objects you no longer use, the garbage collector obviously cannot reclaim that memory.."
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.
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.