Stories
Slash Boxes
Comments
typodupeerror delete not in

Comments: 171 +-   Java's New G1 Collector Not For-Pay After All on Friday June 05 2009, @08:04AM

Posted by kdawson on Friday June 05 2009, @08:04AM
from the trial-balloon-popped dept.
java
programming
An anonymous reader writes "As a follow-up to our previous discussion, Sun appears to have quietly edited the Java 6u14 release notes language to say now: 'G1 is available as early access in this release, please try it and give us feedback. Usage in production settings without a Java SE for Business support contract is not recommended.' So does this mean it was all one huge typo? Or was Oracle/Sun tentatively testing the waters to see the community's reaction? In either case it's nice to see Java's back on the right path."
story

Related Stories

This discussion has been archived. No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More
Loading... please wait.
  • Right path? (Score:5, Funny)

    by DoofusOfDeath (636671) on Friday June 05 2009, @08:10AM (#28221165)

    In either case it's nice to see Java's back on the right path.

    Did kdawson even read the article before writing the summary? I don't see anything in the article about Java becoming more like Haskell!

      • I want to mod that post "+1 funny because it's so -1 insane."

        When will Taco finally implement complex-number mods???

  • But it could be! (Score:5, Insightful)

    by BadAnalogyGuy (945258) <BadAnalogyGuy@gmail.com> on Friday June 05 2009, @08:10AM (#28221171)

    Garbage collection is an amazingly boring field of computer science. It's all about tracking references and trying to keep memory from filling up while also trying to keep the overall impact on the running system down. But as boring as it may be, it's also absolutely critical in today's interpreted languages.

    Where Java really fails is in the inability to trust the finalize method. At least in C++, the destructor of an object is guaranteed to be called as soon as the object is deleted. Java has no such guarantee, so expecting an object to clean itself up once it goes out of scope is a fool's errand. It will get finalized eventually, but the lack of deterministic behavior in this critical part of the object lifecycle means that there is a very big chance that unacceptable delays may occur in practice.

    Give me deterministic behavior over faster GC any day.

    • Re:But it could be! (Score:4, Informative)

      by yacc143 (975862) on Friday June 05 2009, @08:26AM (#28221335)

      Deterministic behaviour => use reference counting. E.g. Python has it.

      But the situation with C++ is not as rosy as you paint it.

      E.g. there are no guarantee that destructors on static object will be called.
      Nor are destructors called on longjmp.

      • Re:But it could be! (Score:5, Informative)

        by tepples (727027) <<moc.thgienip> <ta> <6002hsals>> on Friday June 05 2009, @08:39AM (#28221517) Homepage Journal

        Nor are destructors called on longjmp.

        That's one reason why setjmp was deprecated in favor of try/catch and longjmp in favor of throw.

      • by Late Adopter (1492849) on Friday June 05 2009, @08:53AM (#28221705)

        Nor are destructors called on longjmp.

        For the love of God, man, use exceptions! That's what they're for!

          • Re: (Score:3, Insightful)

            In the normal flow of execution your code goes out of scope and objects inside are destroyed. The purpose of EXCEPTIONS are so that when you have exceptional behavior, all aborted scopes are still properly cleaned up with object destruction. Longjmp doesn't do that. Hence my comment.
      • Re:But it could be! (Score:5, Informative)

        by mpsmps (178373) on Friday June 05 2009, @09:47AM (#28222427)

        there are no guarantee that destructors on static object will be called.

        Actually, Section 3.6.3p1 of the C++ standard [open-std.org] guarantees it. (Wonder why people who can't validate technical language claims feel qualified to mod posts that make them).

        • use reference counting != deterministic behavior

          reference counting + any indirect circular reference == memory leak

          I disagree. The timing of when deletion occurs is still deterministic in such a case. It's just harder for programmers to notice. That causes its own problems, but nondeterminism isn't one of them.

        • Re: (Score:3, Informative)

          by tepples (727027)

          use reference counting != deterministic behavior

          reference counting + any indirect circular reference == memory leak

          hybrid GC with both reference counting and mark and sweep for cycle detection == closer to deterministic than what Java offers in the good case (no circular references) while still correct in the bad case (circular reference becoming detached from main())

              • Re: (Score:3, Informative)

                Is this a matter of your code holding references to your object, or other libraries holding references to your object?

                Other libraries. You may not have a cycle between objects you control, but as soon as you expose any single one of them outside, that one can become a part of a cycle (an external object that is in a cycle holds a reference to yours), and, by extension, all objects it references. At this point, when it will die, it will die on a GC thread, when GC frees the cycle.

                Then what is the right way in Java to automatically write whatever finally blocks need to be written, in the manner of Python's with statement?

                Python's with statement has nothing to do with reference counting at all. It's a much simpler strategy where the programmer explicitly defines the

        • Re: (Score:3, Insightful)

          Reference counters have cycle detection. See Objective-C.
          • Ref-counted Objective-C does not do automatic cycle detection. Garbage collected Objective-C is not based on reference counting.

              • Re: (Score:3, Informative)

                I find on Google mentions that Python which uses ref counting detects cycles.

                It does, though, as I understand, the behavior is the way it is mostly for backwards-compatibility purposes.

                Guido once made a list of things that he considers "implementation details" for Python, and not guarantees of the language spec - meaning that alternative Python implementations could deviate on those points from CPython. Reference counting is on that list, and e.g. Jython and IronPython do not use it at all, relying strictly on tracing GCs provided by their respective VMs.

        • Re: (Score:2, Insightful)

          use reference counting != deterministic behavior

          reference counting + any indirect circular reference == memory leak

          That sounds pretty deterministic to me. Indirect circular reference == memory leak, all the time. You can count on that.

            • Re: (Score:3, Insightful)

              by ThePhilips (752041)

              'exit' is a system call ...

              That was about where I stopped reading the comment.

              The modern "high-level" programmers who do not understand (nor bother to try to) how their own programs actually work, fit with the system and how system is used to implement language features deserve no pity.

              Go back to your Java cave.

    • by siloko (1133863) on Friday June 05 2009, @08:32AM (#28221421) Homepage

      Where Java really fails is in the inability to trust the finalize method. At least in C++, the destructor of an object is guaranteed to be called as soon as the object is deleted.

      Destructor!? Finalize!? Deleted!? You talking like a crazy man, have you never heard of a system REBOOT?

    • Give me deterministic behavior over faster GC any day.

      The thing is, there really is no middle ground. You need to use a mark-and-sweep algorithm to avoid leaking cyclic references, which means you have no way of determining if an object should or should not be destroyed if it leaves scope. The good news is that a modern generational garbage collector is optimized toward collecting younger objects, so it's fairly likely that your resource objects will be collected fairly soon after you're done using them. .NET provides a modicum of determinism with a bunch of s

      • C++ doesn't have heap compaction

        There are ways around this, such as the buddy heap [wikipedia.org] and the Windows XP low-fragmentation heap [microsoft.com], which round sizes up to a power of 2 and keep similarly-sized allocations together.

        • With C++ there is always a way to get (around) a feature. The trick is to let these tricks play nice with the rest of your pogram including the used libraries and different runtime environments.

    • Java doesn't fail (Score:5, Informative)

      by beldraen (94534) <chad.montplaisir@gmai l . com> on Friday June 05 2009, @09:15AM (#28221989)

      The reason why you are confused is because you're used to a compiled environment, where every call is an immediate action. A C/C++ program must be coded to (i.e. explicitly) deletes memory references. If you explicitly delete, you can also tie in other explicit behavior; therefore, it's common "duh this is how you do it" practice to tie "finalize" behavior to the object's deletion. But remember, it is your program's logic that has decided when to get rid of it. In a GC environment, deletion is no longer an explicit event--it is autonomous, automatic; therefore, it is illogical to tie anything to the deletion of the memory reference to anything other than deletion of the memory reference. There is no connection between when the object was dereferenced and when the GC chooses to clean up the reference. Generally, the only events that are tied to the finalize method are sanity checks to make sure non-Java code knows the reference is going away. Put differently: in Java, memory deallocation is not a part of the running logic of your program and so the program must create an explicit method of releasing resources in your program's logic. In other words, do what you were doing before, just don't call it finalize. That's a gripe of mine about Java: It confuses C++ users who are used to using the function finalize because Java gives finalize a specific purpose that cannot act the same way.

      • Re: (Score:3, Insightful)

        If you're coding in lots of explicit memory reference deletes, what you're writing is not C++ but C. A C++ codebase would use RRID and automatic memory management to obviate the need for any explicit memory management. My last C++ project at work contained zero (yes, zero) calls to delete/free() out of around 20000 lines of code and a year of development/testing.

        You're making the same mistake you're accusing C++ developers of making - you're viewing C++ through Java lenses.

    • Amazingly boring? Jeez, there is a lot of ways of doing garbage collection. You can mix GC types, have multiple levels of GC, heap sizes to tweak for these levels etc. Java has got an upper limit to the amount of memory the process uses, but I can think of other schemes that dont. Then you can do a lot of multithreading stuff, but you cannot break code anytime, because in that case the whole VM can die unexpectedly. Then you have to choose when and how long to garbage collect, if you only do so if CPU utili

    • by shis-ka-bob (595298) on Friday June 05 2009, @10:21AM (#28222965)
      If you want to control garbage collection, you should use the real time version of Java. Go to youtube and view Java RTSJ on Wall Street pt1. Here are folks that greatly value deterministic behavior, and they are choosing Java over C++. Why? Because it is predictable and you get access to the tools, developers and tools of the Java World.
      • Re:But it could be! (Score:5, Informative)

        by Ethanol-fueled (1125189) on Friday June 05 2009, @09:18AM (#28222017) Homepage
        What you just said makes no sense. The whole point of Java is that you don't have to mess with memory management. You've just admitted that you want to invest more time and complexity in building "mini-projects" by switching to C++. Good for learning, but otherwise practically silly if you're a noob, and you've implied that you are.

        As far as Java goes, ignore the command line for now. You don't need it to quickly build decent-performing applications.
        • Re: (Score:3, Informative)

          by hibiki_r (649814)

          I write in Java every day, but if my code was running on anything other than an application server that takes care of most of my non-memory resources, I'd be wishing for the equivalent of a destructor every week.

          It's not really about memory management though, but about resource management. Initialize your resources at object construction and release them at destruction is a very simple and elegant solution that is common on many C++ projects. In Java, we can't really do anything like that. We can't really e

            • Re:But it could be! (Score:4, Interesting)

              by shutdown -p now (807394) <int19h@@@gmail...com> on Friday June 05 2009, @12:54PM (#28225347)

              Those hoops are the same hoops you're jumping through with destructors on C++. It only looks more elegant because the complexity has all been pushed into ensuring that all objects are properly destroyed when they need to be.

              It not only "looks more elegant", it is more elegant and concise, because for any given resource type, you write the cleanup code once, and then it is called automatically. With Java, you still write the code once (preferably implementing Closeable), but then you also have to call it manually all the time, resulting in a mess of nested try-finally calls:

              InputStream in = new FileInputStream("foo");
              try {
                OutputStream out = new FileOutputStream("bar");
                try {
              ...
                } finally {
                  out.close();
                }
              } finally {
                in.close();
              }

              At least C# had the decency to provide syntactic sugar for this in form of using:

              using (Stream input = File.Open("foo"))
              using (Stream output = File.Create("bar"))
              {
              ...
              }

              But even that only deals with resources local to a method, not instance fields. And it still isn't automatic.

              Even so, this feature alone would make Java so much easier to deal with. I can't believe they decided not to add it to Java 7, especially when there was a sane proposal already, and the implementation is trivial. It's probably the single most convenient feature C# has over Java (considering how often it's used).

      • Re: (Score:3, Insightful)

        Of course you don't implement finalize in Java. Since it may or may not get called, it's almost completely useless. The reason the non-deterministic behavior is not an issue is that it is assiduously avoided. What is an issue is the lack of a useful analog to finalize.

        However:

        In other words, instead of calling delete, you call close.

        I don't call delete in C++ programs, in general. I let smart pointers take care of all of it. This means that all my resources, including memory, are automatically man

          • Re: (Score:3, Informative)

            Smart pointers, as something you can just use, were introduced in Boost several years ago, and are in the standard now via Technical Report 1. In the mid-90s, they were possible (given template support, which was not universally good at the time), but not widespread.

            Nor do I roll my own. I write the destructors, of course, and then I just use smart_ptr instead of * (okay, a bit more syntax difference than that). By now, it's not custom code.

            So, in about 2000 the Java approach was generally better.

  • Well.... (Score:4, Insightful)

    by samriel (1456543) on Friday June 05 2009, @08:12AM (#28221201)
    I think this means that, if you use the new GC in a production setting and it clobbers some mission-critical piece of data, they would really like you to have some support contract with them, rather than never using G1 or Java again. It is 'early release' after all.
  • Not quietly (Score:5, Informative)

    by RPoet (20693) on Friday June 05 2009, @08:15AM (#28221221) Journal

    Sun didn't "quietly edit" the release notes; they announced it [sun.com] publicly and appologized for having been unclear (which seems like a bit dishonest, but not quiet).

    • Re: (Score:3, Insightful)

      by Joehonkie (665142)
      What you said here. People were so buy foaming at the mouth that they never bothered to read the actual article or the thousands of posts that spelled out pretty clearly how and why the slashdot story got it wrong.
      • by causality (777677) on Friday June 05 2009, @08:54AM (#28221715)

        What you said here. People were so buy foaming at the mouth that they never bothered to read the actual article or the thousands of posts that spelled out pretty clearly how and why the slashdot story got it wrong.

        Never seen that before. No, not ever.

        It's funny when you can cut+paste your comment and drop it into multiple discussions without having to modify it. It is truly one-size-fits-all.

        "Stop. Look. Listen, learn, read, think .. SHUT THE FUCK UP!" - Bill Hicks

      • People were so buy foaming at the mouth that they never bothered to read the actual article

        But but but! Oracle is eviiiiiiiiiiiil! Who cares what the truth was? Did you know that Oracle was eviiiiiiiiiiiiiiiiiiiiiiiil!

    • Re: (Score:3, Insightful)

      Sun didn't "quietly edit" the release notes; they announced it [sun.com] publicly and appologized for having been unclear (which seems like a bit dishonest, but not quiet).

      It was established in the prior slashdot post ranting about it that it was just headline mongering. Nobody commenting had trouble understanding the true meaning.

      But as usual, anything Java is SLOW, EVIL, BAD and out to steal your monies!

  • This is not a change, it was clear in the previous thread that the article was completely misinterpreted. The Slashdot summary made no sense at all once it was pointed out that G1 was GPL+Classpath.

  • by petermgreen (876956) <plugwash.p10link@net> on Friday June 05 2009, @08:20AM (#28221275) Homepage

    I would guess a developer said something vauge like "don't use this in production without a support contract" and it got misunderstood by the person writing the release notes. If they really wanted to forbid it I'd expect them to be competant enough to do that in the license.

  • No Way! (Score:5, Funny)

    by Anonymous Coward on Friday June 05 2009, @08:24AM (#28221313)

    A kdawson article that totally blew something out of proportion? What a shock!

  • by Lemming Mark (849014) on Friday June 05 2009, @08:26AM (#28221341) Homepage

    Argh, so I'm turning into the kind of person who comments without reading *either* article in question but ...

    Last time this came up, plenty of people pointed out that the G1 garbage collector was available to anyone, Open Source but that it was in development and you weren't recommended to use it in production without a support contract. A number of people even pointed out the settings that anybody could change to enable the experimental G1 garbage collector on their own system.

    Perhaps this is case of adjusting their wording to make it easier for Slashdot to not report incorrectly ;-)

  • Stop spreading FUD (Score:5, Insightful)

    by harryandthehenderson (1559721) on Friday June 05 2009, @08:46AM (#28221595)

    So does this mean it was all one huge typo? Or was Oracle/Sun tentatively testing the waters to see the community's reaction? In either case it's nice to see Java's back on the right path."

    No, it means that the original article was a misleading pile of FUD since the G1 garbage collector was released GPL + Classpath exception from the beginning. It's amusing that after being pointed out that the original submission was misleading and wrong that instead of this being a retraction that this article still tries to implicitly claim that Sun or Oracle did something wrong.

  • Popular Java Myths (Score:4, Informative)

    by javacowboy (222023) on Friday June 05 2009, @08:51AM (#28221665) Homepage

    1) Java is slow
    2) Java is not yet open source (or only parts of it are or isn't "really" open source)
    3) Java is not available in any Linux distro's package manager
    4) Java does not meet the needs of the enterprise
    5) Nobody uses Java anymore
    6) "Java is a heavyweight ball and chain"
    7) Sun is charging people to use the new G1 garbage collector.

    Java has some weaknesses and disadvantages, but the above are not among them.

    • by owlstead (636356) on Friday June 05 2009, @09:51AM (#28222491)

      1) Java is slow.

      I'm generally a Java advocate, but you have to take into accounts when Java *is* slow. This is mostly where Java has to get down to the nitty gritty of the bare metal. Examples are cryptography (lots and lots of low level operations on bytes, 32 and 64 bit words) and processor based instructions. In those cases it makes sense to use a well defined C library (avoiding C++ if possible) and interface with that. These are also the places where it makes sense to really optimize the hell out of an application or library.

      But for general business logic this arguement is indeed long gone. I do believe that my Java applications are normally faster than their C++ counterparts for the simple reason that I've got more time to design my classes well. Even if it's slower then it's offset by the much lower maintainance cost. And it's way faster than most specialized languages. Then again, specialized languages can make sense if they are delivering lower maintainance cost. Lets just say that not choosing Java because is it slower *per se* is absolutely wrong.

      • Re: (Score:3, Insightful)

        by againjj (1132651)
        In other words, Java is not one-size-fits-all, and all languages have tradeoffs.
  • Well, the keys are right next to each other...

    By the way, the research paper describing G1 is here [sun.com].

  • Not Oracle/Sun Yet (Score:5, Informative)

    by fm6 (162816) on Friday June 05 2009, @11:04AM (#28223653) Homepage Journal

    Or was Oracle/Sun tentatively testing the waters to see the community's reaction?

    It's a little early to talk about Sun as a part of Oracle. It's probable that the acquisition will clear regulatory approval, but until it does, Oracle can't play anything resembling a decision-making role in something like this.

    I work at Sun, and right now our contacts with Oracle are actually more circumscribed than they'd normally be.

Because I don't need to worry about finances I can ignore Microsoft and take over the (computing) world from the grassroots. -- Linus Torvalds