Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Java Programming IT Technology

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!"
This discussion has been archived. No new comments can be posted.

Have a Nice Steaming Cup of Java 5

Comments Filter:
  • Finally! (Score:4, Informative)

    by arhar ( 773548 ) on Thursday September 30, 2004 @08:51AM (#10393178)
    I've been waiting for this for a long time! Now waiting for Eclipse to release a working plugin (well, there's this [genady.net] ,but it's not that great.
  • Release notes (Score:5, Informative)

    by BlurredOne ( 813043 ) on Thursday September 30, 2004 @08:57AM (#10393212)
    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 [sun.com]
  • Comment removed (Score:3, Informative)

    by account_deleted ( 4530225 ) on Thursday September 30, 2004 @09:00AM (#10393229)
    Comment removed based on user account deletion
  • by Anonymous Coward on Thursday September 30, 2004 @09:01AM (#10393232)
    Well there's been a Developer Preview available since June.
  • by GreenCrackBaby ( 203293 ) on Thursday September 30, 2004 @09:02AM (#10393242) Homepage
    >Weeks of coding saves hours of planning.


    What an appropriate sig for your comment. The simple fact is that Java memory leaks are pretty common simply because not enough planning goes into coding. A proper UML diagram of an application can go a long way to highlighting possible memory leak situations.

  • by ShatteredDream ( 636520 ) on Thursday September 30, 2004 @09:02AM (#10393243) Homepage
    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
  • It's out there! (Score:3, Informative)

    by aug24 ( 38229 ) on Thursday September 30, 2004 @09:02AM (#10393248) Homepage
    Check out gcj, part of gcc (Translation: check out the gnu compiler for java, part of the gnu compiler collection).

    I gave it a whirl about a year ago and it was fine, fine for the relatively simple stuff I experimented with.

    J.
  • by robbyjo ( 315601 ) on Thursday September 30, 2004 @09:04AM (#10393267) Homepage
    Are you sure? J2EE is 1.4 [sun.com] already.

  • by Tojo-Mojo ( 707846 ) on Thursday September 30, 2004 @09:06AM (#10393279)
    Java's garbage collection sort of creates a general laziness among some coders who don't clean up because they don't have to. Without effective clean up routines, like destructors, you commonly end up with a chain that can hold a lot of memory out that is being unused. 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.

    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?
  • by timbloid ( 208531 ) on Thursday September 30, 2004 @09:06AM (#10393289)
    > 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++ [idiom.com] (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.. ;-)
  • by NoOneInParticular ( 221808 ) on Thursday September 30, 2004 @09:13AM (#10393341)
    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.

  • by koehn ( 575405 ) * on Thursday September 30, 2004 @09:13AM (#10393343)
    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...
  • by XbainX ( 464073 ) on Thursday September 30, 2004 @09:16AM (#10393378)
    Actually, under certain circumstances the JVM will reclaim non-null references eventually. But you will still experience memory leak type symptoms until either you run out of available memory or the non-null references are cleaned up...

    Java supports various types of references, check here: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ ref/Reference.html [sun.com]
  • by MemoryDragon ( 544441 ) on Thursday September 30, 2004 @09:20AM (#10393408)
    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)
  • by koehn ( 575405 ) * on Thursday September 30, 2004 @09:20AM (#10393413)
    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.
  • ... 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
  • by Z-MaxX ( 712880 ) on Thursday September 30, 2004 @09:21AM (#10393427) Journal
    You need to use the "-target 1.4" option to javac to tell it to produce the older version of class files.
  • by qodfathr ( 255387 ) on Thursday September 30, 2004 @09:24AM (#10393460)
    Well, what about something like Oracle JDeveloper? Here's a very complete and modern GUI IDE, written in Java, which runs unaltered on many operating systems.

    Maybe you can't find it on the shelf at a retail computer store, but it is a for-purchase product. (Free to download and play with, of course.)
  • Swing on OpenGL (Score:5, Informative)

    by tesmako ( 602075 ) on Thursday September 30, 2004 @09:26AM (#10393476) Homepage
    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 [sun.com]

    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.

  • Eclipse 3.1 betas (Score:5, Informative)

    by trajano ( 220061 ) on Thursday September 30, 2004 @09:31AM (#10393518) Homepage Journal
    The Eclipse 3.1 betas support 1.5 constructs. I normally use the integration builds.
  • by smallpaul ( 65919 ) <paul @ p r e s c o d . net> on Thursday September 30, 2004 @09:32AM (#10393535)

    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 [python.org] out of date.

  • by Cederic ( 9623 ) on Thursday September 30, 2004 @09:34AM (#10393564) Journal
    >> 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?

  • by fatphil ( 181876 ) on Thursday September 30, 2004 @09:37AM (#10393585) Homepage
    Your link points to this obvious nonsense:

    """
    Consider what happens when you do a new/malloc: a) the allocator wanders through some lists looking for a slot of the right size, then returns you a pointer. b) This pointer is pointing to some pretty random place.

    With GC, a) the allocator doesn't need to look for memory, it knows where it is, b) the memory it returns is adjacent to the last bit of memory you requested. The wandering around part happens not all the time but only at garbage collection. And then (depending on the GC algorithm) things get moved of course as well.
    """

    The guy knows nothing about _either_ efficient dynamic memory allocators, nor garbage collectors, he has no right to pass comment on them.

    FP.
  • by aug24 ( 38229 ) on Thursday September 30, 2004 @09:43AM (#10393662) Homepage
    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.
  • Re:I wait! (Score:2, Informative)

    by saden1 ( 581102 ) on Thursday September 30, 2004 @09:45AM (#10393701)
    If you have a variable name or package name called "enum" anywhere in your source code you'll have to replace every instance of it with something other than "enum." Apache Axis suffers from this problem and I am sure a lot of other projects do too. Have fun renaming stuff.
  • by badmonkey ( 29600 ) on Thursday September 30, 2004 @09:50AM (#10393758) Journal
    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.
  • Re:I for one . . . (Score:1, Informative)

    by Anonymous Coward on Thursday September 30, 2004 @09:53AM (#10393804)
  • by znerd ( 83191 ) on Thursday September 30, 2004 @09:58AM (#10393864) Homepage
    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 [sf.net] 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
  • Re:Passe... (Score:2, Informative)

    by gh ( 68417 ) on Thursday September 30, 2004 @10:03AM (#10393927)
    Yes, heavy influence from C/C++, but funny thing is that the Java camp has avoided introducing these features until C# made a lot of them popular again.

    New Features in Java 5:
    - Generics (C# 2.0)
    - Enumerated types (C# 1.0)
    - Static import (not available in C#)
    - Formatted output / input (C# 1.0)
    - Varargs (C# 1.0)
    - for loop changes (C# 1.0, equiv foreach)
    - autoboxing (C# 1.0)
    - metadata (C# 1.0)

    In C# 2.0, it will have features that Java 5 does not support:

    - iterators
    - anonymous methods (includes support for closures)
    - nullable types
    - partial classes (good for code generators)

    Not saying C# is the be all end all... in fact, I'm more partial to languages like Ruby. ;)
  • by Jason Hood ( 721277 ) on Thursday September 30, 2004 @10:04AM (#10393929)
    That is why very few shops use websphere. Most use JBoss mostly because its free but partly because they stay current. Its not viewed as a cash cow like websphere.

  • by angel'o'sphere ( 80593 ) <{ed.rotnemoo} {ta} {redienhcs.olegna}> on Thursday September 30, 2004 @10:04AM (#10393934) Journal
    (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
  • by julesh ( 229690 ) on Thursday September 30, 2004 @10:08AM (#10393982)
    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.
  • by Anonymous Coward on Thursday September 30, 2004 @10:16AM (#10394064)
    The list of architectures that have successfully built a Perl VM is much larger than the list of arch's that have a Java VM. Look at the Configure script in the Perl distribution. You'll be surprised at how many different platforms it can run on.
  • by Anonymous Coward on Thursday September 30, 2004 @10:26AM (#10394203)
    Call me crazy, but I prefer to prototype in Perl, and then if necessary (and only if necessary) rewrite in C. And if possibly, only critical parts, using XS or Inline::C. Possibly some assembly too if banging on the hardware.
  • by Anonymous Coward on Thursday September 30, 2004 @10:33AM (#10394304)
    what is the point in coding in Java if it won't work on the #2 desktop OS?


    Java already supports Linux.

  • Why build it? (Score:1, Informative)

    by Anonymous Coward on Thursday September 30, 2004 @10:48AM (#10394507)
    The whole point of Java is that you don't *need* to build Java apps like Eclipse to run them - you just copy the .class files in a directory and start it up.

    With that in mind, I've actually built some parts of it with 1.5 and they were fine.
  • Re:Generics (Score:2, Informative)

    by Tomba ( 176108 ) on Thursday September 30, 2004 @10:49AM (#10394520)
    Java's way of using type erasure is just a compiler "trick", a List<int> is still a list of objects like it was before. A List<int> in CLR is really a list of integers, not objects. There's no boxing involved, nor the extra memory overhead from boxing. Of course this only applies to the basic datatypes. Real objects are stored similarly in both ways, but even then there's one typecheck less in CLR when fetching data from the list.
  • Re:Passe... (Score:1, Informative)

    by Anonymous Coward on Thursday September 30, 2004 @10:51AM (#10394549)

    - Generic Types (AKA templates)


    I know it's somewhat nit-picking, but generics are named differently for a very good reason, template meta-programming (the oh-god-it's-hard-to-get-your-head-around c++) is just not something that java generics, or c#'s upcoming similar feature do.
  • Re:Dear Sun (Score:5, Informative)

    by iso ( 87585 ) <.slash. .at. .warpzero.info.> on Thursday September 30, 2004 @11:02AM (#10394725) Homepage
    Why don't you try this?

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

    Now quit trolling.
  • by Brian Quinlan ( 252202 ) on Thursday September 30, 2004 @11:10AM (#10394836) Homepage

    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.

  • Re:Passe... (Score:5, Informative)

    by Jon Pryor ( 118031 ) on Thursday September 30, 2004 @11:17AM (#10394959) Homepage

    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

  • Re:STUPID MODS (Score:5, Informative)

    by ElGuapoGolf ( 600734 ) on Thursday September 30, 2004 @11:28AM (#10395151) Homepage
    Are you aware that the vast majority of games you play on any phone (except Verizon phones) are written in Java?

    Thought not.
  • Re:I love the hate (Score:3, Informative)

    by moonbender ( 547943 ) <moonbenderNO@SPAMgmail.com> on Thursday September 30, 2004 @11:37AM (#10395293)
    IIRC the Q3 port was the topic of a Slashdot story some weeks ago. ...

    Here [slashdot.org] it is.
  • Re:I wait! (Score:2, Informative)

    by markfive ( 167272 ) <mbonnin@gmail.com> on Thursday September 30, 2004 @11:37AM (#10395301)
    > perl -pi -e "s/enum/myEnum/g" *.java
  • Re:Passe... (Score:3, Informative)

    by iabervon ( 1971 ) on Thursday September 30, 2004 @11:41AM (#10395371) Homepage Journal
    Actually, C/C++ had a lot of good ideas, but it took a while for Java to get them right. The new Generic Types add compile-time typechecking and remove a lot of typecasting without adding a huge amount of complexity to the language like C++ templates do, and without causing multiple copies of the code to be generated. Enums in Java are full-fledged classes of actual objects with methods, unlike in C where they are just markers (they are object constants instead of integer constants; no difference in efficiency for comparison). Static include is actually more like Python's "import", where you can skip the class name for some class statics. Formatted output is much the same, and was just waiting for other features. Varargs has strong checking in Java, unlike C; the called function can limit the type of the extra arguments, can find out at runtime how many it got, and can't run off the end of the set, because it gets them as a Java array.

    Java, unlike C++, has a policy of putting features off to become future extensions any time the language team can't specify them right at the time. C++ is constantly finding that changes they need to make break things that they've been recommending. Java's main mistake so far has been that they didn't have arrays use generic types, so the two don't play quite right together. Of course, that was a matter of historical necessity, because Java wouldn't have gotten to the point where generic types were worked out correctly without supporting arrays.
  • Netbeans 4.0 Beta 2 (Score:3, Informative)

    by fforw ( 116415 ) on Thursday September 30, 2004 @12:44PM (#10395894) Homepage
    Netbeans 4.0 Beta 2 was also released today, giving people who want to try to ride the tiger a matching IDE with full language support:

    Netbeans 4.0 Beta 2. [netbeans.info]

    J2SE 5.0 bundled with Netbeans. [sun.com]

  • Re:Passe... (Score:5, Informative)

    by Baki ( 72515 ) on Thursday September 30, 2004 @01:07PM (#10396233)
    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());
    }

  • Re:I wait! (Score:2, Informative)

    by DChristensen ( 98850 ) on Thursday September 30, 2004 @01:23PM (#10396481) Homepage
    > perl -pi -e "s/\\benum\\b/myEnum/g" *.java

    Don't forget the \b for word breaks, or you might end up with something a little different than you intended.

  • by coopaq ( 601975 ) on Thursday September 30, 2004 @02:27PM (#10397233)
    "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.

  • by miguel ( 7116 ) on Thursday September 30, 2004 @03:35PM (#10397953) Homepage
    Mono is slower than .NET in certain areas, but in
    some others it is a lot faster. The areas that
    get the most testing and use from the team are
    likely to be more tuned than the Microsoft
    counterparts (this is a nice benefit of using
    Mono to develop itself: we actually use it to
    maintain our own compilers, editors, and day-to
    day tools).

    You are mistaken about the JIT nature of Mono,
    Mono has an optimizing JIT engine with pluggable
    optimizations. You can control the level of
    optimizations using the -O flag to the runtime,
    and we support Ahead-of-Time compilation as well
    which means that you can turn on all the obscene
    optimizations (those who might be too expensive
    to do at JIT time, and that historically JITs
    had to implement by doing dynamic recompilation).
    In our case, we turn on all the expensive
    optimizations, and run the code natively, without
    a dynamic translation (like a JIT would do).

    Anyways, Mono has a dedicated staff to support
    and maintain it (16 developers reporting to me,
    plus other contributors from Novell in other
    areas of the VM) in addition to the 250 accounts
    for external contributors that continue to
    improve Mono.

    We are not in a quest to compete with Java, we
    bring something different to the table (and in
    fact, we even support Java in Mono ;-), but your
    statements are incorrect.

    Miguel.
  • by zabuldyga ( 780853 ) on Thursday September 30, 2004 @04:14PM (#10398351)
    I used to work for a company that made a UML modeling tool. The earlier versions of it had been written in C++ and just about 8 years ago a Java version was launched. The decision that was made a year later was rather risky: to discontinue C++ version and switch to Java completely. This allowed to concentrate the development on just one product, which finally brought the success.

    Was Java one of the main reasons for the big success of the product and the company? Quite possibly so.

    Would the company have succeeded had not Java been chosen? Perhaps, with a bit of luck.

    If Java was such a crap as it's often depicted, would this be possible at all? I very much doubt it.
  • by LadyLucky ( 546115 ) on Thursday September 30, 2004 @05:47PM (#10399255) Homepage
    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.

  • by Estanislao Martínez ( 203477 ) on Friday October 01, 2004 @12:45AM (#10401794) Homepage
    Presto, each object in the list references the next, therefore none have a 0 ref count and will be ignored by the garbage collector.

    One algorithm to do GC is to go through every reference in your call stack, follow each of them, mark the object you reach as used, do the same for each reference in those objects, and so on (taking care to check for already-marked objects, so as not to fall into cycles). Then, you go through all the heap, and free all the objects you didn't mark.

    This algorithm will successfully collect the circular list. I don't think Java uses this one algorithm, but the algorithms it does use will collect the cyclic structures just as well.

"If it ain't broke, don't fix it." - Bert Lantz

Working...