Slashdot Mirror


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!"

26 of 859 comments (clear)

  1. Finally! by arhar · · Score: 4, Informative

    I've been waiting for this for a long time! Now waiting for Eclipse to release a working plugin (well, there's this ,but it's not that great.

  2. Release notes by BlurredOne · · Score: 5, Informative

    If any one is interested in reading the release notes, they can be found at http://java.sun.com/j2se/1.5.0/docs/relnotes/featu res.html

  3. The new for loop and type safe collections rock by ShatteredDream · · Score: 5, Informative

    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 when you are iterating over a collection or an array. The type safe collections are also very handy--no more class cast exceptions and stuff like that.

    It would be nice though if Sun would make Groovy or Jython a standard part of their java distribution. That would definitely make it competitive with .NET

  4. Re:Still no operators... by timbloid · · Score: 4, Informative

    > ok, it got faster, but still not as fast as C++ too.
    > I guess this will finally come but when ?

    Errr...

    Java 1.4 was comparable in speed to C++ (except obviously for Trig which got a huge overhaul in 1.4 and slowed down some)

    It really depends how you write you code... Sloppy C++ code can be slow too.. ;-)

  5. Re:Stability/memory leaks by NoOneInParticular · · Score: 3, Informative
    Also, I don't know for sure, 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?

    Yes, Java's GC would notice that nothing is referring to them and remove the objects. This unlike a simple reference counting gc such as python's which would not notice this. Java's GC can even relocate memory on the fly to minimize page misses and avoid memory fragmentation.

  6. Re:How long will the MacOS X release take? by koehn · · Score: 3, Informative

    I downloaded the beta (from where I can't say :-), but it only installs on Tiger (OS X 10.4). Since I don't really want to run a pre-release OS, I took a pass. But JDK 1.5 is coming, it's just several months off.

    But by your post, you had probably already guessed that. At least it's probably less than four years, like it was before Mac folks got JDK 1.2...

  7. Re:hmm. but how does this compare with Mono by MemoryDragon · · Score: 3, Informative

    Sorry, Dude, but the Java VM still is faster than .Net and Mono is significantly slower than .Net (since it is just a basic VM with a basic jit and no runtime optimization)

    Despite the having a slower VM, the .Net programs sometimes can be faster than java programs because they are heavily integrated into windows wheras java has to add abstraction layers for not losing portability.

    But back to Mono it will probably never be able to catchup speedwise with .Net unless they move to another VM which is maintained by a dedicated team (parrot comes to mind) but then they will lose compatibility on binary level to .Net (which is not really there anyway since Microsoft plays cat and mouse with them on a classlibrary level)

  8. Re:J2EE -- 1.3.1 still by koehn · · Score: 3, Informative

    First off, Websphere 4.0 is J2EE 1.2 only. You need Websphere 5.0 to get to J2EE 1.3.1. In Websphere 5.1, you at least get JDK 1.4, and a few J2EE 1.4 tidbits (JSTL 1.1, for example).

    However, your ClassCastExceptions will only get bumped to compile time in JDK 1.5, true. But I must admit that in eight years of Java programming, I've never had this particular problem where it didn't take more than a few seconds to find the source of the bug.

    I really just want the metadata stuff (which was obviously ripped off from C#, but it's a great idea). That, and EJB 3.0, which gets rid of the stupid deployment descriptors.

  9. Re:How long will the MacOS X release take? by angel'o'sphere · · Score: 3, Informative

    ... it is likely to prevent most developers from coding in it
    Not really. CodeGuide, www.omnicore.com, thats an IDE, has a MAc release since years. That allows using Java 1.5 features in coding. And as you can create byte code compatible with JDK 1.4 released software will run on a Mac as well. Tehre are minor issues however e.g. new methods in java.lang.String wich work fine in the IDE (becase the classpath is different) but not in standalone mode. Nevertheless, I'm coding on a Mac, not necessaryly for a Mac, thats why I use java with generics and the later Java 1.5 betas since over 2 years now. (And since about 14 month on a Mac).

    I would expect that Eclispe and other major IDE vendors have a Mac version bundled with JDK 1.5 runtime libraries as well.

    angel'o'sphere

    --
    Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  10. Re:Bytecode Compatibility by Z-MaxX · · Score: 4, Informative

    You need to use the "-target 1.4" option to javac to tell it to produce the older version of class files.

    --
    Dr Superlove 300ml. I use my powers for awesome
  11. Swing on OpenGL by tesmako · · Score: 5, Informative
    One of the new features of Java 1.5 that has not been mentioned much yet is the OpenGL acceleration of Java2D (which underlies Swing and AWT). Adding the flag
    -Dsun.java2d.opengl=true
    (or by setting the system property in the program) makes pretty much all Java2D calls go directly into OpenGL.

    This does indeed work too, I have played around with it and graphically intensive Swing applications really fly with OpenGL activated (given that your graphics card and drivers are sufficiently bug-free and modern). Read about it here

    And yes, it does work under Linux, and Windows and Solaris (and most likely will under OS X, though that is up to Apple to implement).

    Even without OpenGL acceleration the Swing responsiveness improvements are very impressive, coupled with the much better both default theme and theme mimicking in 1.5 I'd say it is time to retire the Swing troll.

  12. Eclipse 3.1 betas by trajano · · Score: 4, Informative

    The Eclipse 3.1 betas support 1.5 constructs. I normally use the integration builds.

    --
    Archie - CIO-for-hire :-)
  13. Re:Stability/memory leaks by smallpaul · · Score: 3, Informative

    Yes, Java's GC would notice that nothing is referring to them and remove the objects. This unlike a simple reference counting gc such as python's which would not notice this.

    Your information about Python is about four years out of date.

  14. Re:How long will the MacOS X release take? by Cederic · · Score: 5, Informative

    >> what is the point in coding in Java if it won't work on the #2 desktop OS?

    Perhaps because it will work on the #1..n server OSes?

  15. No you can't run it anywhere you like! by aug24 · · Score: 3, Informative

    You can only run it on a machine with a perl interpreter on board. Now tell me exactly how that is materially different to Java?

    Justin.

    --
    You're only jealous cos the little penguins are talking to me.
  16. Re:J2EE -- 1.3.1 still by badmonkey · · Score: 3, Informative

    IBM no longer ships standalone JDKs- according to the license with SUN, they only ship JDK included in a product. IBM will definately have a 1.5 JDK, just don't hold your breath.

  17. Performance improved? Not in my experience... by znerd · · Score: 3, Informative
    I did some tests to compare Java 1.4.2_05 with JDK 1.5.0 and I found that 1.4.2_05 is considerably faster when building a project. This mainly involved XSLT processing and Java compilation.

    Test I did: Run 'ant -lib lib checkstyle java' on XINS 0.207)

    Preparation command:
    rm -rf build
    Timed command:
    time ant -lib lib checkstyle java
    I did 3 tests in a row for each Java version. I added the 'user' and 'sys' times and the averaged then. Results on my Gentoo Linux system with 2.6 kernel:
    Java 1.4.2_05 34.5s Java 1.5.0-rc: 42.9s Java 1.5.0: 41.6s
  18. Re:Bytecode Compatibility by angel'o'sphere · · Score: 4, Informative

    (i.e. you can't have "-target 1.4 -source 1.5") . Yes, you can have it!
    But what about your classpath, does it reference the 1.5 JRE? E.g. if the 1.5 java.lang.String gets loaded by an old JVM you might get that errro as well.
    angel'o'sphere

    --
    Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  19. Re:Bytecode Compatibility by julesh · · Score: 4, Informative

    I thought that the compiled Java would remain compatible with the bytecode format used by previous versions.

    The bytecode format is still identical. The version number on the file was incremented because classes that depend on assertions could break badly if used on a JVM that doesn't implement them (which is actually a feature of a few classes in java.lang, not a bytecode interpreter feature). Use the '-target' commands recommended by the other posters whenever producing code that doesn't rely on one of the new features.

  20. Re:Dear Sun by iso · · Score: 4, Informative

    Why don't you try this?

    1) go to java.com
    2) click the big "get it now" button
    3) download the EXE

    Now quit trolling.

  21. Re:Stability/memory leaks by Brian+Quinlan · · Score: 3, Informative

    Yes, Java's GC would notice that nothing is referring to them and remove the objects. This unlike a simple reference counting gc such as python's which would not notice this. Java's GC can even relocate memory on the fly to minimize page misses and avoid memory fragmentation.

    Python actually uses a generational garbage collection system that can break cycles to reclaim unused objects. It also performs certain optimizations to avoid unnecessary memory allocations and deallocations.

    In Python, reference counting is a combination of a historical artifact and a performance optimization.

  22. Re:Passe... by Jon+Pryor · · Score: 5, Informative

    My apologies for the horrible look of the code samples. Slashdot won't let me use nice, short lines, as it results in lines which are too short. Gah! Apparently I need ~40 characters per line (average) to get past the @#$% filter... This has to be the most annoying filter I've ever come across; I've spent more time getting past the filter than responding to your question!

    Iterators are similar to java.util.Iterator. C# iterators are compiler support for implementing the System.Collections.IEnumerator interface. For example, in Java you'd write:

    public class MyIterator implements Iterator {
    private String[] hw = {"hello", "world"};
    private int pos = 0;
    public boolean hasNext () {
    if (pos >= 0 && pos < hw.length) return true;
    return false;
    }
    public Object next () {return hw[pos++];}
    public void remove () {throw new UnsupportedOperationException ();}
    }

    public void UseIterator ()
    { Iterator e = new MyIterator ();
    while (e.hasNext())
    System.out.println (e.next().toString());}

    C# iterators make this much easier:

    public IEnumerable SayHello ()
    { yield return "hello";
    yield return "world";}

    public void UseIterator ()
    { foreach (string s in SayHello())
    Console.WriteLine (s);}

    C# iterators are particularly useful when implementing your own collection objects. Google for them; they're very powerful.

    Anonymous Methods are methods without a name, just like Java anonymous classes are classes without a name. Same basic idea, fewer braces. They also act as full closures; while Java requires that all stack variables referenced from an anonymous class be final, C# doesn't require this.

    int n = 42;
    EventHandler h = delegate {Console.WriteLine ("something happened:" + n);};
    h ();

    The above example is bad, but you can let your imagination run wild. This is very useful for event handlers.

    Partial Types

    allow you to split a single class definition across multiple files. This is useful to prevent > 50 KB source files (yech!), and makes it easier to have part of a class machine generated (by a GUI builder) and part hand-written. Some people hate it, others are ambivalent, but it can be handy:

    // File a1.cs
    partial class Foo {public int a;}

    // File a2.cs
    partial class Foo {public int b;}

    Nullable types are primarily useful for database support in the .NET type system. DB types can be "nullable" -- not present. For reference types, this is easy -- use null. For .NET value types, this isn't possible, as value types can't be null. The solution is to introduce a generic class System.Nullable<T>, which can wrap value types such as int.

    The C# compiler adds syntactic sugar to this, to simplify usage:

    int? nullable_int = GetMyNullableInt ();
    if (nullable_int.HasValue) /* use nullable_int */

    Nullable types are more special purpose, but are useful for those who need them.

    Ignore the rest of this: it's just garbage to get past Slashdot's wonderful "too few characters per line" problem: lk jfjdlkajdsfl;kja sdfl;kja fjklsafjd l;kj lasjd lkjds fl;kja sdflkajsd lkj afs lk jfjdlkajdsfl;kja sdfl;kja fjklsafjd l;kj lasjd lkjds fl;kja sdflkajsd lkj afs lk jfjdlkajdsfl;kja sdfl;kja the quick brown fox jumps over the lazy dog l;kajdsfl;kj;lkj l;kjasdilfj l;kjoiewqruq[op 0-9314u75 lkfjx ;lkajdsfmopiac un0p3u5n1-0329u kl 0a9u 3214o5ilj hello out there in tv land! q 09

  23. Re:STUPID MODS by ElGuapoGolf · · Score: 5, Informative

    Are you aware that the vast majority of games you play on any phone (except Verizon phones) are written in Java?

    Thought not.

  24. Re:Passe... by Baki · · Score: 4, Informative
    In Java5 you would write the C# iterator just about the same.

    For example

    for (Shape tShape : pList) {
    System.out.println("X is " + tShape.getX());
    }

  25. Re:Thanks to our supporters by coopaq · · Score: 3, Informative
    "This release was made possible by our world-wide development community. Oh, yeah, and ridiculously large settlement payments by Microsoft."

    I hate to say this, but: your cut is the fact you can use it for free!

    I hate to say THIS but that money DID come from me over the course ten years of PC systems with buggy operating systems on them.

    Maybe I should just get a linux PC next time and install Windows if I need it.

  26. Re:Stability/memory leaks by LadyLucky · · Score: 3, Informative
    Wow, such flameage.

    However, you are quite correct. It can be quite difficult at times to ensure that all objects are correctly cleaned up after usage. As soon as you introduce items such as HashMaps, etc, you run into potential for these problems.

    We once had this issue when we embedded the mozilla javascript interpreter in our app. The problem was that you have to create a scope object, with all sorts of predefined classes and functions and so forth. This was expensive, so we pooled them. Unfortunately this left a memory leak, as objects declared in scope by the javascript itself would not tidy up at the end of processing.

    Indeed it turns out the library has parent scopes, so we could create a new child scope cheaply each time, but the point remains.

    --
    dominionrd.blogspot.com - Restaurants on