Java's New G1 Collector Not For-Pay After All 171
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."
Right path? (Score:5, Funny)
Did kdawson even read the article before writing the summary? I don't see anything in the article about Java becoming more like Haskell!
Re: (Score:2)
Did kdawson even read the article before writing the summary?
You must be new here.
Re: (Score:2)
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)
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)
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)
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.
Re:But it could be! (Score:4, Insightful)
Nor are destructors called on longjmp.
For the love of God, man, use exceptions! That's what they're for!
Re: (Score:2)
Best solution is to have all your objects set up befor
Re: (Score:3, Insightful)
Re: (Score:2)
No they aren't. Exceptions are exceptional.
You use longjmp in "normal" situations?
Re:But it could be! (Score:5, Informative)
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).
Re: (Score:2)
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:2)
More than that; the GP is talking about a bug. If your program has a circular reference that you don't know about, it's a bug. That reduces his earlier statement to:
use reference counting + buggy code != deterministic behavior
and further to
buggy code != deterministic behavior
which is a lot less insightful that the GP hoped.
Re: (Score:3, Informative)
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:2)
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())
It still doesn't make sense in practice, because all bets are off. So long as there is any external references to your object, direct or indirect, you do not know whether it is a part of a cycle or not, and therefore cannot know whether its destruction will be deterministic or not. So you can't rely on it being deterministic in general.
So reference counting doesn't really buy you much there. However, it does introduce a significant performance hit [wikipedia.org] (this may sound surprising, but mark & sweep GCs actuall
Re: (Score:2)
So long as there is any external references to your object, direct or indirect, you do not know whether it is a part of a cycle or not
Is this a matter of your code holding references to your object, or other libraries holding references to your object?
So reference counting doesn't really buy you much there. However, it does introduce a significant performance hit
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?
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)
Re: (Score:2)
Ref-counted Objective-C does not do automatic cycle detection. Garbage collected Objective-C is not based on reference counting.
Re: (Score:2)
It it has cycle detection, then it's not "just" a reference counter. Probably it's a hybrid reference count / mark and sweep algorithm. The reference count lets you discard some of the objects quickly, while the mark and sweep lets you discard the circular references a little more slowly.
Even if Objective-C does not use a hybrid reference count / mark and sweep algorithm, it doesn't use a pure reference counting solution. If it did, then it would only have the number of times something was referenced, wh
Re: (Score:2)
"The reference count lets you discard some of the objects quickly, while the mark and sweep lets you discard the circular references a little more slowly."
'quickly' is debatable if you have a linked list. exiting a ref-count bounded function (or some other scope) could take 60+ seconds if you'd slowly accumulated millions of tree or linked-list nodes (I speak from experience in a perl world). In a copying collector GC, exiting a function is always instantaneous, and in fact, the vacuming of massive transi
Re: (Score:2)
I find on Google mentions that Python which uses ref counting detects cycles.
I doubt Apple would bother including GC in Mac OS X 10.5 + Objective C 2.0 if it didn't work properly. More than that, documentation on developer.apple.com says that (manual) reference counting isn't compatible with auto GC, meaning that it's not really ref counting based GC. It is clearly states that ref counting and GC are mutually exclusive. Provided that Core Foundation already provides quite rich set of memory management f
Re: (Score:2)
Parent was talking about ref counting, not GC. Apple bothered including GC in the ObjC runtime exactly because the reference counting they had before that had cycle detection issues (and it was harder to program to). In the commonly used terminology, GC and ref counting are different things.
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:2)
I think the more appropriate response is that a finalizer will eventually get called in any ref-counted system (even those that don't properly handle cycles), but the finalizer WANTED to be called at some scope-exit point, but due to the [possibly unforeseen] cycle, must instead wait for some secondary cleanup code which is non-determistically triggered. In a ref-count + mark+sweep hybrid it likely happens when an allocator says memory is too fragmented and thus does a mark+sweep prior to any sbrk calls, i
Re: (Score:2)
Probably you should RTFM, e.g. man atexit and man exit. Then on Linux compile a small program with static objects and run it under ltrace to see the truth of how it really works.
I did once had the unpleasant experience - debugging monstrous C++ applications, ridden with static objects, which depending on temperature outside of window and direction of wind was sometimes crashing during start-up. And quite reliably crashing during shutdown. (Redundant exception throwing (as modern OO programmer like it) a
Re: (Score:3, Insightful)
'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.
Re: (Score:2)
indeed. _Exit(int) is a system call. exit() is part of the standard library. I quote from ISO/IEC 14882:2003:
A return statement in main has the effect of leaving the main function (destroying any objects with automatic
storage duration) and calling exit with the return value as the argument. If control reaches the end
of main without encountering a return statement, the effect is that of executing
return 0;
Now, exit(int) does not clean up remaining automatics in the current scope (i.e. variables on the stack will not be cleaned up), but otherwise exit(int) and returning from main are identical.
Re:But it could be! (Score:5, Funny)
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?
Re: (Score:2)
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
Buddy heap (Score:2)
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.
Re: (Score:2)
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.
Re: (Score:2)
The trick is to let these tricks play nice with the rest of your [program] including the used libraries and different runtime environments.
That's an issue with any std::malloc replacement, but this page [stackoverflow.com] claims that Firefox manages to work around it.
Java doesn't fail (Score:5, Informative)
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:2)
But in C++, many programs don't really deal with resource deallocation directly: That's what reference counting pointers are for. The resources get wiped the moment nothing references them anymore, and we can release both memory and connections at the exact moment they are not used anymore. In Java, just as you said, we end up doing it explicitly, doing a lot more work by hand, and risking destroying a resource that someone still has a reference to.
Sure, the code can still work, but it's a lot harder to get
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.
Re: (Score:2)
This means that a resource, other than memory, can't be tied completely to an object. Anything using the object has to handle the resource manually, like basic C++ memory management, breaking the abstraction.
For example, I might want to tie, say, a database to an object. I create the object which opens/creates a database. I then use the object normally, and it makes transactions with the database as needed, but since finalize() is not reliable I have to explicitly call a close() method before I let the obje
Re: (Score:2)
Now, you might say that this is not an issue, since the GC will reclaim all memory anyway. But what you
Re: (Score:2)
Yeah, I remember reading up on finalization before I even knew Java's syntax. I decided to create a method in every class - "deleteMe", which nulls everything out when called.
I'm sure the garbage collector cleans it up soon after. Good enough. Has worked fine ever since.
Re: (Score:2)
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
So use real-time Java (Score:4, Informative)
Re: (Score:2)
all that "UB" means is that the standard doesn't care. and it always describes something that you're not supposed to do.
No problem with predictability there.
Re: (Score:2)
Garbage collection is an amazingly boring field of computer science.
And so is , unless it isn't. Any time some one says, "X is boring," or, "X is interesting," that really means, "X is boring TO ME," or, "X is interesting TO ME." "Boring" or "interesting" is opinion. Personally, I find GC rather interesting, in particular the latest advances in real-time GC. I did compiler/programming languages work for my M.S., and I believe that most people would think that it is boring as well, but it is not to me.
It's all about tracking references
There is a lot more than that.
Re: (Score:2)
"Where Java really fails..."
I add to my 'what-evar!' list, consider the rant it in my app design and continue programming my [insert ANY app here] in Netbeans (likelt the app that pays my mortgage).
Thanks for the [usual academic] opinion.
On the flip side, Java says, separate implementation representation (i.e. low-level, on the metal, specific to vendor, dependencies, etc...) from logical representation (move robot arm 10 degrees). That forc
Re: (Score:2)
I think you're looking at deterministic in a different way than I. I know that when there are no longer any references to an Object, that object is completely out of scope from my application. I don't care how the system I'm on cleans it up, the same way that 99% of the time, you don't care about what a free/delete/close really does behind the scenes. What does matter is that:
1. The process of cleaning up this memory doesn't negatively impact the application's runtime performance
Re: (Score:2)
So? I switched from C/C++ to Java over 10 years ago, and have not once needed to even consider implementing finalize. The only thing this "lack of deterministic behavior" really means in practice is that you have to explicitly close input/output streams, rather than let objects go out
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:
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:2)
They do seem cool and a better solution for this problem. But it seems you are still stuck with implementing them yourself, in which case you are in [almost] the same situation as in Java. I.e. in C++ you have to write custom code (e.g. smart pointers) to do the resource freeing automatically; but in Java you can do the same thing b
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.
Re: (Score:2)
Smart pointers are an essentially reference counting solution, with all its pitfalls. I don't doubt it works in 90% of scenarios, but when things get really complicated, things can get hairy.
Re: (Score:2)
I don't find it boring, but then I am geeky.
Re: (Score:2)
Wow, I've done a lot of Java development and have never had a need for a finalizer. So while you may have a niche need in your C++/Java work, you certainly don't represent a majority of use-cases, and thus I can disregard your claim of Java's failure. There are many many other programming paradigms for resource cleanups. try-catch-finally (or better yet, pass a runnable to try-catch-finally processor to guarantee consistent resource-management). One particularly elegant form is Thread-Local Transactions
Re:But it could be! (Score:5, Informative)
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)
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: (Score:2)
In C++ the pattern is fairly simple, every object must be cleaned up. For objects on the stack that is done automatically. For objects on the heap the programmer can either do it manually, have a single reference responsible for the lifetime of the object (auto_ptr) or use reference counting (shared_ptr).
In java the pattern is a mess, you have to check the docs for every object to see if it needs to be disposed or not and if so you have to manage that disposal manually and of course if you change an object
Re:But it could be! (Score:4, Interesting)
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:
At least C# had the decency to provide syntactic sugar for this in form of using:
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:2)
Some people discover that you can request a garbage collection cycle from within the main program. Basically it flags the GC thread to do another collection and the GC honors the request whenever it will.
Nearly 99.999% of the time, the person who put such a call together is a ex-C++ programmer who's under the impression that this will help the garbage collector in some way. They are just so used to garbage collection being deterministically halting their program, that they think the "lazy" thread of the g
Re: (Score:2)
Re: (Score:2)
I know that you're anonymous, but you're brilliant.
This "feature" of the language extends even more deeply than you know. If I call
int age = Users.getByName("Bob").getAge();
I don't need to worry about the implementation of "getByName()" in Java, where in C++ I would need to know a lot to use the class. Java might be returning a modifiable "User" object which is referenced by the whole application, or it might be returning a copy of a "User" object where modification would only allow the block of code to
Re: (Score:2)
Generally, that should be obvious based on what it's returning; If it's returning a copy, it should return a static User object, if it's returning a the original it will be a pointer to it. That's also what the documentation is for, in the event that it is returning a reference to a copy it needs to make clear that it's the caller's job to destroy the object. In Java, you refer to that as an "implementation detail"; In C++, you generally realize that /you are the implementer/ and need to pay attention to de
Well.... (Score:4, Insightful)
Re: (Score:2)
Contracts for garbage collection eh? I knew Sun was in cahoots with the mafia. Just ask these guys [reuters.com] if they don't wish they had stuck with the old Java...
Re: (Score:2)
Next thing you know, they'll be asking for memory protection money.
Not quietly (Score:5, Informative)
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)
Re:Not quietly (Score:5, Funny)
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.
.. SHUT THE FUCK UP!" - Bill Hicks
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
Re: (Score:2)
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!
Slashdot editors don't read slashdot? (Score:5, Informative)
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.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Or a reader. I wonder how this correlation relates to causation.
Probablly just a misunderstanding (Score:5, Insightful)
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.
Re: (Score:2)
I tend to agree. If they really wanted a pay-to-use-this garbage collector, then they would have made the garbage collector a upgrade or add-on to the existing JVM and not distributed it in it's fully functional form for free.
Fully functional software tends to get used, and Oracle is not such a newbie to think that a piece of paper (or an electronic equivalent of that) will block use of a revenue generating item all by itself. Nor are they interested in auditing and suing everyone who might have a product
No Way! (Score:5, Funny)
A kdawson article that totally blew something out of proportion? What a shock!
Re:No Way! (Score:4, Informative)
Was this ever an issue? (Score:5, Insightful)
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)
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)
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.
Re:Popular Java Myths (Score:4, Insightful)
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)
Re: (Score:2)
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.
It's surprising. Why would operations on bytes (or machine words) in Java be any slower than in C? After all, the JIT will compile them to the same stuff as a C compiler would do, and Java HotSpot is widely recognized as the most sophisticated JIT in production out there.
So far as I know, most of Java slowness doesn't actually come from bit twiddling being slow. It's because of things like all calls being virtual by default, and all objects being allocated on heap and not stack by default (yes, I know Java
Re: (Score:2)
As far as I can tell neither the compiler nor the JIT do even the most rudimentary of optimizations, like CSE elimination, dead code elmination, loop unrolling, inlining, etc.
Java compiler doesn't do it because JIT should do it. And how can you tell if JIT does it or not?
Just write 1 function that spins in a loop doing something like:
for(i=0; i 100000; ++i) { a = 5; }
Yes, and then what? How did you test if it did any optimizations when JITting?
I must admit I do not know the nitty gritty of Java JIT, but I've seen what .NET JIT can do, and it certainly does all optimizations you've listed - I observed dead code elimination, loop unrolling and inlining firsthand. With .NET it's easy because Visual Studio debugger lets you switch to disassembly mode even when debugging .NET app
Re: (Score:2)
If you time the execution of the whole "java Foo.class", then you're actually timing the startup time of JVM, class loading, and JITting. You'll need to raise the number of iterations much higher to see the difference. Or just use a long counter, and do Long.MAX_VALUE iterations - it'll hang if the loop is not optimized out, but won't if it is.
Also, if you want to time how long the loop itself takes, you'll have to do the measurements from within the running Java program:
Re: (Score:2)
for(i=0; i 100000; ++i) { a = 5; }
It handles that fine. (with the < added)
I did it to a million, and stuck it in another loop to a million, inside another loop to a million.
It finished in 0 milliseconds, according to the horrible precision timer.
Maybe something is wrong with your configuration. I've found Java to be far smarter than C++ compilers when it comes to optimizations when the -server flag is enabled.
Re: (Score:2)
Things like Cryptography and Compression which are process intensive are already implemented in native hooks in the base JVM. For instance, if you're using a GZIPOutputStream to GnuZip compress your data, the actually compression is done in a native block. Just because -a part- of your code requires high thoughtput, it doesn't mean that the entire piece of code needs to be developed in said language. Think of it like the distinction between C and ASM. You'd never write your entire code in assembly anymore,
Re: (Score:2)
1) Java is slow
Semi-true, java is what you get when you take a language that is slow by design and optimise the hell out of it. Overall perforamnce is reasonable but not brilliant (shootout.alioth.debian.org places it at arround 1.5 to 2 times slower than C). Predictability of performance can be a problem though because instanciating a new class can mess with the inheritance tree and hence the performance of seemingly unrelated code.
2) Java is not yet open source (or only parts of it are or isn't "really" o
Re: (Score:2)
I would hardly call Java slow by design. TCL or Bourne shell would be slow by design. It seems like C programmers, and C-like language programmers think everything except C and its ilk to be "slow by design".
One huge typo? (Score:2)
Well, the keys are right next to each other...
By the way, the research paper describing G1 is here [sun.com].
Little Early to Bring Up Oracle (Score:2)
Until the deal closes Oracle has nothing to do with Sun's Day to Day operations. Once Oracle takes over take bets on what happens to MySql and Glassfish. Until then, they don't have squat to do with it.
I still worry... (Score:2)
Re: (Score:2)
Uh. Sure. This will be a problem when Microsoft makes .Net run well on Linux. Until then they'll just be that really obnoxious loud truck rumbling in the next lane over.
I have no idea what you mean by SQL Server being ahead of Oracle, but SQL Server also only runs on Microsoft OSes and is thus only useful for people who run Microsoft OSes.
Re: (Score:2)
Re: (Score:2)
basically letting Microsoft get ahead with SQL Server in many respects
True. This [xkcd.com] only works in SQL Server, not Oracle.
It's not because you aren't paranoid that java.... (Score:2)
Or was Oracle/Sun tentatively testing the waters to see the community's reaction?
It'd be great if my fellow slashdotters stop giving in the PROFIT conspiration theory, just one time.
Not Oracle/Sun Yet (Score:5, Informative)
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.
Re: (Score:2)
That's a laugh. At the operational level, Oracle will not interfere much until the acquisition is approved.
But at the strategic level? You can bet your bottom dollar that Sun isn't blowing its nose without checking with Oracle to see if it's OK first.
Re: (Score:2)
And you know this to be true because...
How is Sun any different from Red Hat? (Score:2)
I think the intent was simple.
Until the code is stable, if you use the new, beta quality garbage collector in production, don't go crying to Sun for help unless you're willing to pay for a support contract.
How is that any different from most open source companies such as Red Hat?