Slashdot Mirror


Java Gets New Garbage Collector, But Only If You Buy Support

An anonymous reader writes "The monetization of Java has begun. Sun released the Java 1.6.0_14 JDK and JRE today which include a cool new garbage collector called G1. There is just one catch. Even though it is included in the distribution, the release notes state 'Although G1 is available for use in this release, note that production use of G1 is only permitted where a Java support contract has been purchased.' So the Oracle touch is already taking effect. Will OpenJDK be doomed to a feature-castrated backwater while all the good stuff goes into the new Java SE for Business commercial version?"

587 comments

  1. Seriously Java? by jlechem · · Score: 5, Insightful

    You used to be cool.

    --
    Hold up, wait a minute, let me put some pimpin in it
    1. Re:Seriously Java? by Anonymous Coward · · Score: 2, Insightful

      Too cool for its customers.

    2. Re:Seriously Java? by Lord+Ender · · Score: 4, Insightful

      So long as they publish the spec, we can't accuse them of being proprietary. So long as the free version is superior to other similar free technologies, they will still be the market leader. Sounds like they know what they're doing.

      --
      A slashdotter who didn't build his own computer is like a Jedi who didn't build his own lightsaber.
    3. Re:Seriously Java? by __aaclcg7560 · · Score: 5, Funny

      Garbage in, garbage out.

    4. Re:Seriously Java? by Anonymous Coward · · Score: 0

      Pay for it? Can't someone else do it?

    5. Re:Seriously Java? by JonTurner · · Score: 5, Funny

      Write once. Pay everywhere.

    6. Re:Seriously Java? by Anonymous Coward · · Score: 0, Troll

      It gets better. (Or worse, depending on your point of view.)

      This version also adds a blacklist to the JRE, so Oracle can ban people from running various applications.

      Just what I want to do, give Oracle the power to randomly stop applications I use from running. I wonder how long it will take for Eclipse to "accidentally" make it onto the blacklist?

    7. Re:Seriously Java? by Luyseyal · · Score: 0, Redundant

      That is brilliant and widely applicable. I love it!

      -l

      --
      Help cure AIDS, cancer, and more. Donate your unused computer time to worldcommunitygrid.org. Join Team Slashdot!
    8. Re:Seriously Java? by linzeal · · Score: 1

      Does any industry that deals beyond a niche user base really think they can pay more programmers, writers or artists to compete with a billion people online? What is going to end up happening is that companies that cannot make money off hardware, support services or the like on donation or ad-based platforms while supporting open content will perish trying to desperately sell something that no one considers worth buying. Do they really think this is going to bring in more more money than pissing off an entire generation of people who have grown up programming under Java when it was free? How long do you think it is going to take for these features popping up in a forked version, days or weeks?

    9. Re:Seriously Java? by patro · · Score: 2

      You used to be cool.

      Really? When?

    10. Re:Seriously Java? by bnenning · · Score: 3, Funny

      Very briefly around 10 years ago, when it was a clear improvement over C++ and hadn't yet been infested by architecture astronauts.

      --
      How to solve most of our problems: 1.Lots of nuclear plants. 2.Cure aging.
    11. Re:Seriously Java? by theeddie55 · · Score: 4, Interesting

      java was cool when it was a great idea, then it was implemented. it has never really been all that cool since then.

    12. Re:Seriously Java? by clarkkent09 · · Score: 5, Interesting

      As per release notes, this is an experimental feature. It may be that Sun intends to provide it only to paid customers or it may be that they want to make sure you don't use it in "production" environment until it's ready and then whine that Java is buggy if it doesn't work 100%.

      I don't know which is true but the second possibility seems far more likely to me, making this story completely pointless and unfair - but hey this is slashdot.

      Btw, off topic but is it just me or the subjects in replies are showing up as white text on white bg in Firefox but look ok in IE. I even tried in on another pc and same thing.

      --
      Negative moral value of force outweighs the positive value of good intentions.
    13. Re:Seriously Java? by Anonymous Coward · · Score: 0

      I would pay for something that works. Hope Oracle take JavaEE out of the crap it is right now.

    14. Re:Seriously Java? by Anonymous Coward · · Score: 0

      Yeah, when it was lacking all the useless features it has been added since, such as ENUM... It has gone all downhill for the last 10 years!

    15. Re:Seriously Java? by Anonymous Coward · · Score: 1, Funny

      Java is as fast as C/C++ and used prominently within the banking industry!

    16. Re:Seriously Java? by jd · · Score: 2, Funny

      That was back when it was called Oak, right?

      --
      It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    17. Re:Seriously Java? by binarylarry · · Score: 2, Insightful

      Right, Java wasn't ever cool, which is why every major software company seems to be scrambling to make their own Java style platform (.NET, the new Flash stuff, etc).

      --
      Mod me down, my New Earth Global Warmingist friends!
    18. Re:Seriously Java? by Anonymous Coward · · Score: 0

      It isn't Oracle yet...

    19. Re:Seriously Java? by Anonymous Coward · · Score: 0

      It's not bullshit, it's true. Java makes up the majority of the programming market along with C#, and not just within the banking industry.

    20. Re:Seriously Java? by maxume · · Score: 5, Informative

      Java and Javascript are only nearly identical in that they both contain Java in their names.

      Javascript is much closer to Ruby than it is Java (but the built in objects aren't generally as rich, and people scream and whine about the prototype based object system).

      --
      Nerd rage is the funniest rage.
    21. Re:Seriously Java? by Anonymous Coward · · Score: 0

      Does any industry that deals beyond a niche user base really think they can pay more programmers, writers or artists to compete with a billion people online?

      Please provide me one example of a free/OSS platform implementation of a commercial product that is inarguable BETTER than the original proprietary version. OpenJDK > Sun (Sun wins). DirectX > OpenGL (MS wins). .Net > Mono.

    22. Re:Seriously Java? by 1729 · · Score: 4, Insightful

      You could also dispense with having to maintain two nearly-identical languages (Java and Javascript)

      Huh? How are Java and Javascript nearly identical?

    23. Re:Seriously Java? by Anonymous Coward · · Score: 0

      Architecture is not crime. Your mindset and skills are out of date.

    24. Re:Seriously Java? by Anonymous Coward · · Score: 5, Funny

      Huh? How are Java and Javascript nearly identical?

      They were both slow when they came out, they're both slow now, and they both have a bunch of people saying "oh, but it's faster now!"

    25. Re:Seriously Java? by Anonymous Coward · · Score: 0

      The subjects in replies look fine to me...

      Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)

    26. Re:Seriously Java? by K.+S.+Kyosuke · · Score: 1

      Yeah, let's not concentrate on removing weaknesses that make additional features appear necessary, let's add those features instead...

      --
      Ezekiel 23:20
    27. Re:Seriously Java? by turgid · · Score: 3, Informative

      Please provide me one example of a free/OSS platform implementation of a commercial product that is inarguable BETTER than the original proprietary version

      Linux > Unix.

    28. Re:Seriously Java? by Kuxman · · Score: 1

      I just noticed the same issue on my FF browser.

      --
      http://www.asti-usa.com
    29. Re:Seriously Java? by Anonymous Coward · · Score: 0

      It's just you... don't forget to squeegee your monitor.

    30. Re:Seriously Java? by Pulzar · · Score: 1

      Yup, same problem with Firefox here. I had to fire up IE to read Slashdot... awful, just awful.

      --
      Never underestimate the bandwidth of a 747 filled with CD-ROMs.
    31. Re:Seriously Java? by Anonymous Coward · · Score: 0

      I think OpenGL came before DirectX, so technically not an implementation of DirectX. Besides it would Direct3D that would be closer to OpenGL.

    32. Re:Seriously Java? by binarylarry · · Score: 0

      In Soviet Java, beta testing costs YOU!

      --
      Mod me down, my New Earth Global Warmingist friends!
    33. Re:Seriously Java? by Anonymous Coward · · Score: 2, Informative

      It gets better. (Or worse, depending on your point of view.)

      This version also adds a blacklist to the JRE, so Oracle can ban people from running various applications.

      Just what I want to do, give Oracle the power to randomly stop applications I use from running. I wonder how long it will take for Eclipse to "accidentally" make it onto the blacklist?

      Oh stop.

      Support for blacklisting signed jar files has been added to 6u14. A blacklist is a list of signed jars that contain serious security vulnerabilities that can be exploited by untrusted applets or applications. A system-wide blacklist will be distributed with each JRE release. Java Plugin and Web Start will consult this blacklist and refuse to load any class or resource contained in a jar file that's on the blacklist. By default, blacklist checking is enabled. The deployment.security.blacklist.check deployment configuration property can be used to toggle this behavior. .

      You guessed it - the blacklist applies to applications you can launch from untrusted sources. Go back to thy cave, troll.

    34. Re:Seriously Java? by elfprince13 · · Score: 0

      You can't really compare OGL and DX.....

    35. Re:Seriously Java? by shutdown+-p+now · · Score: 5, Insightful

      So long as they publish the spec, we can't accuse them of being proprietary.

      Yeah, just like .NET, right?

    36. Re:Seriously Java? by joelgrimes · · Score: 4, Funny

      Huh? How are Java and Javascript nearly identical?

      In the same way lightning is nearly identical to lightning bugs.

    37. Re:Seriously Java? by shutdown+-p+now · · Score: 3, Informative

      This version also adds a blacklist to the JRE, so Oracle can ban people from running various applications.

      It's not nearly as sinister as it sounds, at least judging by release notes:

      "Support for blacklisting signed jar files has been added to 6u14. A blacklist is a list of signed jars that contain serious security vulnerabilities that can be exploited by untrusted applets or applications. A system-wide blacklist will be distributed with each JRE release. Java Plugin and Web Start will consult this blacklist and refuse to load any class or resource contained in a jar file that's on the blacklist. By default, blacklist checking is enabled. The deployment.security.blacklist.check deployment configuration property can be used to toggle this behavior."

      So it's opt-out, but configurable. You're still free to run whatever you want.

    38. Re:Seriously Java? by Zardoz44 · · Score: 2, Insightful

      Please provide me one example of a free/OSS platform implementation of a commercial product that is inarguable BETTER than the original proprietary version

      Linux > Unix.

      Git > Sourcesafe.

    39. Re:Seriously Java? by Anonymous Coward · · Score: 0, Flamebait

      So it's opt-out, but configurable. You're still free to run whatever you want.

      OK, smart guy, tell me how to enable the "deployment.security.blacklist.check deployment configuration property" because I am a Java developer and I had to look that up. Turns out it's a special .properties file hidden in "%APPDATA%\Sun\Java\Deployment\deployment.properties". Yeah, I really see a normal user finding and then figuring out how to edit that. (%APPDATA% generally expands to something like "C:\Documents and Settings\%USERNAME%\Application Data" - which is by default hidden, meaning you can't find it in Explorer without changing the default settings.)

      Going through the Java control panel I find nothing that allows you to set these "deployment configuration" properties.

      So once Oracle decides to blacklist your JAR as a "security hazard" there's no way in hell a normal user is going to figure out how to edit that properties file, let alone find it in the first place.

      Making it technically opt-out if you're a developer. But no normal user will figure out that they need to disable it in the first place, let alone how to disable it.

    40. Re:Seriously Java? by mmkkbb · · Score: 1

      I've reported this bug as well. If you click on the name of the article just above the threshold settings it shows up fine. It's only the SEO friendly URL that is broken.

      --
      -mkb
    41. Re:Seriously Java? by libkarl2 · · Score: 1

      As per release notes, this is an experimental feature. It may be that Sun intends to provide it only to paid customers or it may be that they want to make sure you don't use it in "production" environment until it's ready and then whine that Java is buggy if it doesn't work 100%.

      The timing. Companies are getting desperate to generate new revenue streams, and preserve old ones. Certainly doesn't mean you are wrong, it just means that crummy economies help reinforce paranoia.

      I don't know which is true but the second possibility seems far more likely to me, making this story completely pointless and unfair - but hey this is slashdot.

      On slashdot, paranoia takes on a tawdry escapist quality.

      Btw, off topic but is it just me or the subjects in replies are showing up as white text on white bg in Firefox but look ok in IE. I even tried in on another pc and same thing.

      I'm not having that issue with FF v3.0.10.

      --
      You are where you are at the time you are there.
    42. Re:Seriously Java? by Verdatum · · Score: 1

      COBOL is as fast as C/C++ and used prominently within the banking industry!

      Fixed That For Ya....still I'd never wanna write in it.

    43. Re:Seriously Java? by Anonymous Coward · · Score: 1, Informative
      did you think of

      -Ddeployment.security.blacklist.check=false

    44. Re:Seriously Java? by moonbender · · Score: 4, Insightful

      Great, Ruby will fit right in.

      --
      Switch back to Slashdot's D1 system.
    45. Re:Seriously Java? by stephanruby · · Score: 1

      Also, I think calling their Garbage Collector G1 is a not so subtle message to Google.

    46. Re:Seriously Java? by wed128 · · Score: 3, Informative

      It's all a fad.

      Soon we'll be back to paper tape and punchcards. damn whipper-snappers with your fancy garbage collection.

    47. Re:Seriously Java? by Jurily · · Score: 1

      Let's solve this the Open Source way. When's the first GPL'd fork coming out?

    48. Re:Seriously Java? by shutdown+-p+now · · Score: 2, Insightful

      Making it technically opt-out if you're a developer. But no normal user will figure out that they need to disable it in the first place, let alone how to disable it.

      A "normal user" rarely starts a Java application by double-clicking a .jar - instead, he'll usually use the developer-provided .exe wrapper which will start up the JVM properly configured (and to which the installer for the application will create a shortcut in Start Menu and/or on the desktop). That wrapper can set properties the way developer wants, including this particular one.

      On a Unix system, the wrapper will most likely be a shell script instead, in which case - as another AC has posted already - it'd just use -D, as with any other property:

      java -Ddeployment.security.blacklist.check=false -jar foo.jar

    49. Re:Seriously Java? by flydpnkrtn · · Score: 3, Informative

      This is a very common misconception (at least in my humble experience...)

      Javascript was born at Netscape at a time when the buzzword Java was cool and hip... it really should be called EMACSscript but that's not cool and hip enough

      From the Wikipedia article:
      'JavaScript, despite the name, is essentially unrelated to the Java programming language even though the two do have superficial similarities. Both languages use syntaxes influenced by that of C syntax, and JavaScript copies many Java names and naming conventions. The language's name is the result of a co-marketing deal between Netscape and Sun, in exchange for Netscape bundling Sun's Java runtime with their then-dominant browser. The key design principles within JavaScript are inherited from the Self and Scheme programming languages.

      "JavaScript" is a trademark of Sun Microsystems. It was used under license for technology invented and implemented by Netscape Communications and current entities such as the Mozilla Foundation."'

    50. Re:Seriously Java? by HeronBlademaster · · Score: 1

      It would be very odd indeed for Sun to just barely finish (or come close to finishing, I forget which) open-sourcing Java, only to add more proprietary things into it. I concur that your second possibility is more likely.

      And regarding the reply issue, for me the text looks fine but the title bar (which should be green) is missing entirely. (Using FF 3.0.10)

    51. Re:Seriously Java? by flydpnkrtn · · Score: 2, Insightful

      Hah whoops please `sed s/EMACS/ECMA/` in that last post... everyone knows EMACS has its own scripting language (it is an operating system, after all)

    52. Re:Seriously Java? by thetoadwarrior · · Score: 1

      Java and Javascript are about as similar as Star Trek and the Jello.

    53. Re:Seriously Java? by Anonymous Coward · · Score: 0

      From http://scienceblogs.com/goodmath/2006/11/the_c_is_efficient_language_fa.php :

      "I didn't know what language to use for this project, so I decided to do an experiment. I wrote the LCS algorithm in a bunch of different languages, to compare how complex the code was, and how fast it ran. I wrote the comp bio algorithm in C, C++, OCaml, Java, and Python, and recorded the results. What I got timing-wise for running the programs on arrays of 2000 elements each was:

              * C: 0.8 seconds.
              * C++: 2.3 seconds.
              * OCaml: 0.6 seconds interpreted, 0.3 seconds fully compiled.
              * Java: 1 minute 20 seconds.
              * Python: over 5 minutes.

      About a year later, testing a new JIT for Java, the Java time was down to 0.7 seconds to run the code, plus about 1 second for the JVM to start up. (The startup times for C, C++, and Ocaml weren't really measurable - they were smaller than the margin of error for the measurements.)"

      http://shootout.alioth.debian.org/ has more.

    54. Re:Seriously Java? by louiswins · · Score: 1

      gcc > most other c compilers?

    55. Re:Seriously Java? by Bootarn · · Score: 1

      OpenTTD > Transport Tycoon Deluxe ;)

    56. Re:Seriously Java? by masmullin · · Score: 0

      They both contain a J, 2as, and 1v.

    57. Re:Seriously Java? by thetoadwarrior · · Score: 1

      Unfortunately for C++ Java does dominate the web for serious applications and PHP for the small timers. Java is quite excellent which is why Google uses it for a lot of their stuff.

      The only people sticking with C++ are those who think it makes them hardcore or they're too thick to learn more than one language.

    58. Re:Seriously Java? by fishbowl · · Score: 1

      >I'm thinking there's going to be a greater push towards getting another language into browsers.

      Why do you think of "browsers" and not "business enterprise software" when Java comes up?

      --
      -fb Everything not expressly forbidden is now mandatory.
    59. Re:Seriously Java? by johannesg · · Score: 1

      Please provide me one example of a free/OSS platform implementation of a commercial product that is inarguable BETTER than the original proprietary version. OpenJDK > Sun (Sun wins). DirectX > OpenGL (MS wins). .Net > Mono.

      OpenGL is not an open source product. But I'd argue that gcc is miles better than whatever crappy C compiler it originally replaced.

    60. Re:Seriously Java? by Anonymous Coward · · Score: 1, Funny

      did you think of

      -Ddeployment.security.blacklist.check=false

      No, of course not.

      He is, after all, a "Java developer".

      Not to mention a pompous ass.

    61. Re:Seriously Java? by Anonymous Coward · · Score: 3, Insightful

      Java "stopped being cool" when your average C/C++ alleged hotshot realised other developers who were not as good at fancy pointer tricks but better at CS could get 10 times the performance within the same deadline by focusing on algorithms instead of fixing memory leaks.

    62. Re:Seriously Java? by AuMatar · · Score: 1

      And embedded software, mobile software, video games, anything not running on the web (still a hell of a lot of programs). Oh and major web companies like Amazon (about a 50/50 mix of Java and C++). C++ has a long productive life ahead of it. If either of the two languages is in trouble it's Java, it's peaked and is no longer the buzzword du jour. Although its penetration assures that it will be in use for decades.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    63. Re:Seriously Java? by BlackSnake112 · · Score: 1

      I remember when all the talk was about java. At the time I thought wow, these people are really into their coffee. Since the people talking it up the most were not programmers but marketing group.

    64. Re:Seriously Java? by ahabswhale · · Score: 2, Interesting

      Wrong. And unlike you, I can actually backup my statement.

      Write once, run anywhere = very cool. Always backwards compatible = very cool. Much cleaner than C and C++ code that it was competing with = very cool. It does all of this while offering performance superior to most languages.

      There are newer nifty-neato languages out there but Java is a workhorse language that is still extremely valuable to corporations around the world. Sun actually has a pretty remarkable achievement on their hands, and I can assure you that I have no problems criticizing Sun.

      --
      Are agnostics skeptical of unicorns too?
    65. Re:Seriously Java? by Anonymous Coward · · Score: 0

      Enough of this nonsense; Java is not slow and hasn't been for some time. Find another (original) way to try to get modded up on /.

    66. Re:Seriously Java? by Anonymous Coward · · Score: 0, Flamebait

      Oh, fuck off. Javascript is a crap toy language. Comparing it to Ruby (which is more on par with Python) is simply delusional.

    67. Re:Seriously Java? by amRadioHed · · Score: 4, Insightful

      Linux is better than some Unix's in some circumstances. It is not however an inarguable matter of fact. ZFS is just one possible example where an argument could be made that Solaris is better.

      --
      We hope your rules and wisdom choke you / Now we are one in everlasting peace
    68. Re:Seriously Java? by dedazo · · Score: 5, Interesting

      I don't know about Java, but I've been playing with Google's V8 and that sucker is fast, at least on Windows.

      --
      Web2.0: I love when people Flickr my cuil and digg my boingboing until my google is reddit and I start to yahoo
    69. Re:Seriously Java? by MikaelC · · Score: 2, Insightful

      Firefox > Internet Explorer

    70. Re:Seriously Java? by Anonymous Coward · · Score: 0

      and Python...

    71. Re:Seriously Java? by Intron · · Score: 1

      One problem with toy benchmarks is that the working set for compiled code is so small it fits in processor cache. It doesn't give you any idea about how real world large applications perform. Processors are so fast that computation is essentially free and the limits are set by memory accesses and disk I/O.

      --
      Intron: the portion of DNA which expresses nothing useful.
    72. Re:Seriously Java? by nanoflower · · Score: 4, Insightful

      Could you please provide me with examples of why Linux is better than Unix? Keep in mind that there are many varieties of Unix ranging from the paid kind to the free kind and that most of what people like to think of as Linux isn't really part of the OS but just open sourced programs that will run on many systems including those based on Unix. I'm not saying that Linux is bad, just that it seems difficult to really say one is better than the other since they are so intertwined.

    73. Re:Seriously Java? by nanoflower · · Score: 1

      I'm seeing the same thing on Firefox under Windows XP. Not sure why it's happening but it is kind of annoying to not see the titles.

    74. Re:Seriously Java? by Anonymous Coward · · Score: 0

      TTDPatch > OpenTTD ;) ;)

    75. Re:Seriously Java? by jtranter · · Score: 1

      Since 99.99% of people interested in technological topics are male, I guess no one noticed that the phrase "feature-castrated backwater" is sexist: specifically, masculinist. "Feature-spayed", anyone?

    76. Re:Seriously Java? by Anonymous Coward · · Score: 0

      Right, Java wasn't ever cool, which is why every major software company seems to be scrambling to make their own Java style platform (.NET, the new Flash stuff, etc).

      What big companies do and what's cool are rarely the same thing.

    77. Re:Seriously Java? by tyrione · · Score: 1

      You used to be cool.

      And you guys [Java Devs] whine about Apple's version not being current?

    78. Re:Seriously Java? by Anonymous Coward · · Score: 0

      That's not fair. Star Trek is very similar to Jello -- both have green jigglies.

    79. Re:Seriously Java? by Threni · · Score: 1

      Slashdot's gone to shit, lately. It's like someone's plaything. I kept getting taken to an XML/RSS feed page, no matter what. Turns out you get that if you have a few `minimal view` options selected. That's 30 mins I'm never going to get back.

    80. Re:Seriously Java? by Jesus_666 · · Score: 0, Troll

      Yeah, but C/ASM/a custom ASIC is still faster for $SPECIFIC_THING so it's slow.

      --
      USE HOT GRITS WITH STATUE OF NATALIE PORTMAN (NAKED AND PETRIFIED)
    81. Re:Seriously Java? by Anonymous Coward · · Score: 0

      Hi Zed!

    82. Re:Seriously Java? by Jesus_666 · · Score: 1

      Apparently the Tech stylesheet is broken somewhere - changing the subdomain to "yro" makes everything work.

      --
      USE HOT GRITS WITH STATUE OF NATALIE PORTMAN (NAKED AND PETRIFIED)
    83. Re:Seriously Java? by GigsVT · · Score: 2, Insightful

      Yeah, in some fantasy world where Java programs just work.

      More realistic is that you get some mess of stuff with nothing obviously executable, and then once you figure out what thing you are supposed to run, it complains about something called a CLASSPATH and refuses to run.

      --
      I've had enough abrasive sigs. Kittens are cute and fuzzy.
    84. Re:Seriously Java? by blueskies · · Score: 1

      Apache HTTPd vs IIS?

    85. Re:Seriously Java? by wideBlueSkies · · Score: 3, Funny

      Emacs > vi

      --
      Huh?
    86. Re:Seriously Java? by BlackSabbath · · Score: 1

      > gcc is miles better than whatever crappy C compiler it originally replaced

      That would be...gcc.

      http://gcc.gnu.org/wiki/History

    87. Re:Seriously Java? by SplashMyBandit · · Score: 5, Informative

      You're a funny guy but obviously have zero idea about what you are talking about. It's a bit aggravating that ignorant folk still come out with the same old 'slow' mantra and unfortunately even more ignorant folk buy into it. That keeps people writing crappy software on C++ or C when quite often Java would be a good fit for them and the performance is mostly a non-issue these days (unless you write very inefficient programs).

      I used to eschew Java for the speed of C++ but now I've completely switched to Java for most development tasks (apart from some C glue-code [JNI] when I need to integrate some scientific instrument or another). I'm doing instrument control, image processing and analysis and I need both reasonable latency, multithreading support, and every performance cycle I can get, and yet Java is plenty fast enough for me (and even embedded devices these days have relatively large amounts of RAM this is far less of an issue than it used to be).

      Seriously Java is very fast these days. Graphics2D is all done in Direct3D or OpenGL shaders, the VM is very optimised and quite often approaches FORTRAN (which is faster than C). Don't believe me? check out the links below.

      So please, next time stop with the FUD (that used to be marginally true 5 years ago) and start with an open mind.

      • From http://en.wikipedia.org/wiki/Java_performance#Use_for_High_Performance_Computing
        "However, High Performance Computing applications written in Java have recently won benchmark competitions. In 2008, Apache Hadoop, an open source High Performance Computing project written in Java was able to sort a terabyte of integers the fastest.[46]"
      • INRIA (French scientifc Institution) report on High Performance Computing with Java [Summary: Java approaching FORTRAN for speed, although some network intensive speed bumps still remaining]
        http://hal.inria.fr/inria-00312039/en
      • From http://blogs.sun.com/jag/entry/current_state_of_java_for
        Current State of Java for HPC

        At the last JavaOne I did a walk-on talk during the AMD keynote where I talked about how incredible HotSpot's performance had become - beating the best C compilers. I ended my talk with a joking comment that "the next target is Fortran". Afterwards, Denis Caromel of Inria came up to me and said "you're already there". He and some colleges had been working on some comparisons between Java and Fortran for HPC. Their final report Current State of Java for HPC has been made available as a Tech Report and makes pretty interesting reading. There are a lot of HPC micro benchmarks in it which look great. Thanks! Permalink Comments [3]
    88. Re:Seriously Java? by shutdown+-p+now · · Score: 1

      Yeah, in some fantasy world where Java programs just work.

      I don't know what world you live in, but in mine, all Java apps that I've used work as I described in my previous post - an .exe starter that Just Works. This goes for Eclipse, NetBeans, Azureus (back when I used it, anyway), among other things.

      In practice, it's not really Java's fault - it's up to the developer to package it properly, and it isn't hard to do that, especially as stock packaging solutions are available and plentiful.

    89. Re:Seriously Java? by TheRaven64 · · Score: 1

      Depends on what you mean by 'better'. GCC is certainly more portable than any other compiler, but most commercial UNIX systems ship with a compiler that produces better (i.e. faster or smaller) code.

      --
      I am TheRaven on Soylent News
    90. Re:Seriously Java? by itlurksbeneath · · Score: 1

      Probably the same way that Java and Perl are nearly identical - they both use curly braces to enclose code blocks.

      --
      Have you ever considered piracy? You'd make a wonderful Dread Pirate Roberts.
    91. Re:Seriously Java? by severoon · · Score: 1

      Java & Javascript are nearly identical? What's it like to know so little about so much?

      --
      but have you considered the following argument: shut up.
    92. Re:Seriously Java? by jlarocco · · Score: 4, Insightful

      I don't buy it.

      The first clue is that the speed of the C++ version doesn't match the C version. Of course there's a difference between "good C++" and "good C", but if your goal is speed then you're not typically concerned about those differences.

      Second, reading through the scienceblog.com article, the author calls the (unavailable) code "carefully optimized," yet he claims the C code is slower than the others because of pointer aliasing. However, any modern C compiler has pragmas and compiler optimization flags that tell it to assume no aliasing occurs. How carefully could he have optimized the code if he didn't even bother turning on compiler optimizations?

      I don't think the scienceblogs guy really knows enough about C and C++ to back up his claim.

    93. Re:Seriously Java? by Magic5Ball · · Score: 1

      Yes, but the fact that one language can't fit even the toy benchmark into a small space, while another can, is also telling.

      --
      There are 1.1... kinds of people.
    94. Re:Seriously Java? by Mr2001 · · Score: 1

      Javascript was born at Netscape at a time when the buzzword Java was cool and hip... it really should be called EMACSscript but that's not cool and hip enough

      As I recall, it was originally called "LiveScript" but then quickly changed to "JavaScript" when Java became the new buzzword.

      --
      Visual IRC: Fast. Powerful. Free.
    95. Re:Seriously Java? by shutdown+-p+now · · Score: 1

      So, what Java weaknesses are those that made enums, and particularly generics, appear necessary?

    96. Re:Seriously Java? by Anonymous Coward · · Score: 1, Insightful

      "write once, run anywhere"

      Bwahahaha! Biggest Java lie ever.

      "Always backwards compatible"

      HAHAHA! Again more java lies.

    97. Re:Seriously Java? by Anonymous Coward · · Score: 1, Insightful

          How is Linux better than Solaris or AIX at the workloads they are typically assigned ?
          More ubiquitous but demonstratively better at what? Large, heavyweight workloads?

    98. Re:Seriously Java? by larry+bagina · · Score: 1

      If he's looping directly over the array in C but using std::vector::at and std::iterator to access it in c++, then c++ would be significantly slower.

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    99. Re:Seriously Java? by Anonymous Coward · · Score: 0

      Yeah, remember when I said I had to look it up?

      It's because deployment properties ARE NOT system properties.

      You have to set them in special files.

      If it were a system property, the release notes would have SAID system property.

      But it's not, it's a "deployment property" and these are special properties that are configured using magic files. Sort of like how you can't configure Java logging through system properties, only through a properties file. You can tell it which properties file to use via a system property, but you can't set any logging properties using "-D" directly. Same deal here.

    100. Re:Seriously Java? by Anonymous Coward · · Score: 0

      Sweet!
      I'm a garbage collector professionally, but would like to get into the high-paying world of IT;
      since the hardest part is getting relevant job experience, maybe I can crowbar this into my resumé now.
      tee hee...

    101. Re:Seriously Java? by alexj33 · · Score: 1

      No! It's your code!

      Just kidding, that's what Java enthusiasts always say to me whenever I point out stuff like that.

    102. Re:Seriously Java? by Anonymous Coward · · Score: 0

      Java and Javascript, nearly identical? You've obviously never used both of them and have ABSOLUTELY NO IDEA what you are talking about.

    103. Re:Seriously Java? by Goldberg's+Pants · · Score: 1

      Then clearly you people who broken your browsers as it's working fine on both Firefox v2 and v3 for me.

    104. Re:Seriously Java? by Samah · · Score: 1

      Mod parent informative please. I wasted my points on +1 Funnies in other threads.
      <3 Java.

      --
      Homonyms are fun!
      You're driving your car, but they're riding their bikes there.
    105. Re:Seriously Java? by Unoti · · Score: 1

      An excellent way to state the architecture astronaut point of view. Now, if you could just spice it up a little, put it through a few iterations that make it more obscure and difficult for us plebs to understand...

    106. Re:Seriously Java? by Unoti · · Score: 1

      You sound like a frustrated developer, perhaps disappointed that your cross-platform development experience didn't go smooth as glass. Sorry to hear that! I wonder: if you weren't using Java for this frustrating experience, how much worse would your frustration have been? using cross-platform C++ or C, perhaps, it would have been better? .NET? The life of a developer isn't always a cake walk. Sometimes it's hard. Perhaps you could suggest what alternative technology would end your frustration?

    107. Re:Seriously Java? by ppanon · · Score: 1

      That's got to make a lot of physicists and quantum chemists very happy.

      --
      Laissez lire, et laissez danser; ces deux amusements ne feront jamais de mal au monde. - Voltaire
    108. Re:Seriously Java? by JorgeFierro · · Score: 1

      OpenGL > DirectX err...

    109. Re:Seriously Java? by rakslice · · Score: 1

      It's all a fad.

      Soon we'll be back to single-celled life.

    110. Re:Seriously Java? by ppanon · · Score: 1

      Please provide me one example of a free/OSS platform implementation of a commercial product that is inarguably BETTER than the original proprietary version

      GTK | KDE/QT > Motif | CDE ?

      --
      Laissez lire, et laissez danser; ces deux amusements ne feront jamais de mal au monde. - Voltaire
    111. Re:Seriously Java? by Anonymous Coward · · Score: 0

      Strong typing? :-)

    112. Re:Seriously Java? by ppanon · · Score: 1

      While Joel's got a point that it's possible to over-abstract something, it's interesting to note that Napster is now gone, and it has been replaced by ITunes (which also serves video), multiple other less popular proprietary music/video services, and... generic Bittorrent tracker/search engines. But I think the whole over-abstraction/architecture astronaut is just a special case of the second system effect described in Fred Brooks' Mythical Man-Month. Worth repeating of course, but not an amazing new insight.

      --
      Laissez lire, et laissez danser; ces deux amusements ne feront jamais de mal au monde. - Voltaire
    113. Re:Seriously Java? by ta+bu+shi+da+yu · · Score: 1

      It's like you typed in a lisp.

      --
      XML is like violence. If it doesn't solve the problem, use more.
    114. Re:Seriously Java? by Anonymous Coward · · Score: 0

      Wormux > Worms

    115. Re:Seriously Java? by tyrione · · Score: 1

      If Java Hotspot is outperforming the "best" C Compilers it's due to those compiler companies spending very few, if any, cycles on getting more performance out of their compiler.

    116. Re:Seriously Java? by rubycodez · · Score: 1

      stepping back and taking a broader than just technical view, does zfs even have a future with Oracle takeover? answer is, who knows?

    117. Re:Seriously Java? by rubycodez · · Score: 2, Interesting

      device support? at least the free Unix (known as the BSD) are really catching up well to Linux with that.

    118. Re:Seriously Java? by jlarocco · · Score: 1

      Oh, I know - and I can think of a dozen similar ways to make the C++ version slower than the C version. But nobody with any sense would do that if they were trying to speed up the code as much as possible. The scienceblog page even went so far as to say the code was "carefully optimized". I was calling into question how "carefully optimized" it could be, given that swapping it out with the C version would be trivial and would likely cut the time in half.

    119. Re:Seriously Java? by dvice_null · · Score: 1

      Do toy benchmark for databases. I'm fairly sure SQLite would beat PostgreSQL easily. Does that mean that SQLite is better in large applications also?

    120. Re:Seriously Java? by mark-t · · Score: 1

      Java also isn't really that great for game programming. Sure, it can be done, but it's not as useful as C or C++ in that regard.

    121. Re:Seriously Java? by ToasterMonkey · · Score: 2

      Yah, Solaris is totally behind Linux. Oh wait, it isn't.

    122. Re:Seriously Java? by ToasterMonkey · · Score: 1

      stepping back and taking a broader than just technical view, does zfs even have a future with Oracle takeover? answer is, who knows?

      Is that a fucking joke?

      This is like "Ford buys GM, is the Corvette doomed?"

    123. Re:Seriously Java? by Tranzistors · · Score: 2, Interesting

      [Open]Solaris in some aspects might be better, but it is OSS anyway.

    124. Re:Seriously Java? by Anonymous Coward · · Score: 0

      Most, like not including Intel's X86 compiler, or Sun's SPARC compiler? You guys are really stretching for this 'better OSS than proprietary' game.

    125. Re:Seriously Java? by jgrahn · · Score: 3, Insightful
      Grandparent: "using std::vector::at and std::iterator to access it in c++, then c++ would be significantly slower"

      Oh, I know - and I can think of a dozen similar ways to make the C++ version slower than the C version. But nobody with any sense would do that if they were trying to speed up the code as much as possible.

      If you're thinking of vector::at() you're possibly right. But a vector::iterator doesn't have to be slower than a pointer, and avoiding it for fear of speed issues would be stupid. I can imagine some C++-y things being slower (std::copy compared to memcpy, in some situations) but not simple iterators.

      In fact, when I ran the code below across a 200,000 element array/vector, the std::vector version was 10% faster. (Note that I didn't benchmark array indexing; I am so used to iterators that [begin, end) is the style which feels natural to me even when I use raw pointers.)

      int bencharray(int * const a, int * const b)
      {
      int val;
      for(int i = 0; i < 50000; ++i) {
      int * p = a;
      val = random();
      while(p!=b) {
      *p++ = val++;
      }
      }
      return val;
      }

      int bench(std::vector<int>& v)
      {
      const std::vector<int>::iterator a = v.begin();
      const std::vector<int>::iterator b = v.end();

      int val;
      for(int i = 0; i < 50000; ++i) {
      val = random();
      std::vector<int>::iterator p = a;
      while(p!=b) {
      *p++ = val++;
      }
      }
      return val;
      }

      So I still don't understand how that benchmarking guy (who knew C++ well!) managed to make it three times slower than C. We should probably ignore his results altogether, since his source code is lost.

    126. Re:Seriously Java? by master_p · · Score: 1

      The overall Java performance is lower than the performance of the same C++ program though, due to the following reasons:

      1) excessive run-time casting. C++ templates are a great win over Java generics.
      2) calling a method on an interface is an order of magnitude slower than vtable calls.
      3) Java consumes way more memory (the simplest widget, for example, consumes over 1K).

    127. Re:Seriously Java? by julesh · · Score: 2, Interesting

      That keeps people writing crappy software on C++ or C when quite often Java would be a good fit for them and the performance is mostly a non-issue these days (unless you write very inefficient programs).

      Or programs that need floating point. Several of the commonly used functions in java.lang.Math are implemented by processor specific instructions, e.g. Math.exp(), yet Java refuses to use them, instead preferring an integer-based approach that's 5-10 times slower, but maybe a bit or two more accurate. Despite repeated requests, no option is as yet available to use them anyway in applications where that accuracy is not required. This makes many high-performance computing systems (particularly neural nets) substantially slower on Java than other systems.

    128. Re:Seriously Java? by julesh · · Score: 1

      Hah whoops please `sed s/EMACS/ECMA/`

      Presumably you mean "M-x replace-string EMACS ECMA", right?

    129. Re:Seriously Java? by amRadioHed · · Score: 1

      You're right, that's a possibility. I haven't played with OpenSolaris much though, so I can't really say.

      From what I know though wouldn't it be more of an example of a proprietary Unix that was open sourced instead of a community built OS? I'm not sure how much of the code base actually comes from contributors outside of Sun.

      --
      We hope your rules and wisdom choke you / Now we are one in everlasting peace
    130. Re:Seriously Java? by johannesg · · Score: 1

      Portability is nice, but I was referring to the fact that it is actually a standards-compliant, full-featured compiler. I have struggled with too many compilers that may produce great code, but *only* if you speak their local dialect. Which is a major pain if you try to produce portable code.

      Example: ACC on HPUX. Don't get me wrong, I love it, and its error messages are in a class all on their own. But the standard clearly allows comma's in places where ACC throws an error. Sure, it's just a minor thing, but still...

      Another example would be PostgreSQL, by the way.

    131. Re:Seriously Java? by jimfrost · · Score: 1
      Ok, I really like Java in general, and I'm not particularly a fan of C++ for all kinds of reasons that make me want to whack Stroustrup up side the head repeatedly. I've used both pretty much since their inceptions, including writing stupid amounts of code over the years.

      Given care in writing the code, C++ pretty easily beats Java in both performance and memory footprint. Java has come a long way in terms of raw performance but it's still the case that in general you're not going to beat equivalent code written in C++. Memory footprint -- well, Java just sucks in terms of memory footprint. (I do realize there are some pretty tight implementations but that just eases the pain a bit, it doesn't get rid of it.)

      Having said that I have found that Java developers are, on average, about three times as productive as C++, which means you can improve the application algorithmically three times as fast, and that pays big dividends over time. (It's hard to overstate how much I dislike the compile and link performance of C++, although I don't think this is the primary reason why Java is superior in this respect.) Java's garbage collector is likewise a big win in eliminating those annoying heap corruption problems that suck the life out of C++ development, and it's hard to overstate how good mandatory exception handling is at making applications robust in the face of failure. For example, the first commercial Java product I worked on never went down completely; this was a problem for the beta cycle because people often wouldn't consider "this button didn't do anything" to be serious enough to report, versus "the whole thing crashed" as is typical in C++.

      So, I prefer Java when I can use it, or C# which is vastly superior for GUI development and fixes a number of really stupid Java design decisions (it's like he said in the prologue of Princess Bride, the book -- they kept "the good stuff"). But if memory is tight or if you really need high performance -- such as in gaming, real-time systems, or large-scale computation -- Java is pretty much a non-starter.

      --
      jim frost
      jimf@frostbytes.com
    132. Re:Seriously Java? by Anonymous Coward · · Score: 0

      Ironically enough, it's likely because Java has gotten so much faster than you're seeing V8 be able to make JavaScript that much faster. V8 goes to a lot of pains to apply hidden classes to objects to allow established techniques for optimizing strongly-typed languages to be used for JavaScript. Many of those techniques came from Java.

    133. Re:Seriously Java? by Nazlfrag · · Score: 1

      Fine then, OpenSolaris > Unix. GP's point still stands.

    134. Re:Seriously Java? by Malc · · Score: 1

      Wasn't it called LiveConnect? IIRC correctly, JavaScript could create and use Java objects, and interface with Java applets.

    135. Re:Seriously Java? by Lennie · · Score: 1

      But why do we need a whole industry and a lot of research to patch a language to make it fast ? Instead of using something that is already fast in it's own right ?

      --
      New things are always on the horizon
    136. Re:Seriously Java? by Anonymous Coward · · Score: 0

      It wasn't even cool back then, Java is just a big enterprise-BASIC. Use Python.

    137. Re:Seriously Java? by szundi · · Score: 1

      java is cool. period. :)

    138. Re:Seriously Java? by IamTheRealMike · · Score: 1

      Have you ever actually written a Java program? It's got the name "write once, debug everywhere" for a reason. And always backwards compatible? Huh? Is that why real Java apps usually come with a complete, private copy of the JVM?

    139. Re:Seriously Java? by Anonymous Coward · · Score: 0

      Java would be a good fit for them and the performance is mostly a non-issue these days

      Assuming the Java app will even launch.

    140. Re:Seriously Java? by Anonymous Coward · · Score: 0

      This is magnificently, astonishingly incorrect.

      Even the most brain-dead optimising compiler would inline all the std::vector etc calls and you would end up with something at least as fast as C. Possibly even faster.

      And you're an idiot for not knowing this. Please go away and learn stl.

      You can come back when you can figure things like this out for yourself.

    141. Re:Seriously Java? by that+this+is+not+und · · Score: 1

      There are a lot of people who make money out of marketing-driven redundancy based on hype and hand-waving.

    142. Re:Seriously Java? by that+this+is+not+und · · Score: 1

      That depends on what is meant by 'device support.'

      Linux runs a distant second to Windows in terms of keeping 'caught up' on support for the latest shiney consumer doo-dads people buy in big box stores. Unix (BSD) barely competes in that sphere. But it isn't because BSD couldn't compete if the BSD developers considered it important.

    143. Re:Seriously Java? by that+this+is+not+und · · Score: 1

      That's true, but 'most other c compilers' are undergrad assignments that get abandoned after senior year.

      GCC is resoundingly NOT superior to commercial compilers where there is a competent professional team in charge, i.e. those from Sun and Intel.

    144. Re:Seriously Java? by BotnetZombie · · Score: 1

      1999 called and wants it CLASSPATH joke back.

      If you deliver an app that doesn't work, then you're just incompetent. Doesn't matter what name the programming language has.

    145. Re:Seriously Java? by rubycodez · · Score: 1

      well, the question was in what way is Linux better than Unix, if you want to consider Windows then let's take the big picture, I would point out my HP9000 B2000 and UltraSparc 170e and eMac don't have their devices supported by Windows very well (not at all), but Linux will run on them.

    146. Re:Seriously Java? by thetoadwarrior · · Score: 1

      True. I was being slightly sarcastic. I think both have their places. Though admittedly Java gets a lot of grief, some of which is unwarranted, imo.

      Java, imo, had a really bad start. More so because of all the god awful applets that were created and it definitely still has more room for improvement.

      I don't think it'll necessarily in trouble. The idea of Java is excellent and some real effort goes into it as a result of it being open sourced then I don't think it has to worry about going away.

      I think it's done quite well considering both MS and Apple seem keen to keep it off their systems.

    147. Re:Seriously Java? by Mr2001 · · Score: 1

      From Wikipedia:

      JavaScript was originally developed by Brendan Eich of Netscape under the name Mocha, which was later renamed to LiveScript, and finally to JavaScript.[5] The change of name from LiveScript to JavaScript roughly coincided with Netscape adding support for Java technology in its Netscape Navigator web browser. JavaScript was first introduced and deployed in the Netscape browser version 2.0B3 in December 1995. The naming has caused confusion, giving the impression that the language is a spin-off of Java, and it has been characterized by many as a marketing ploy by Netscape to give JavaScript the cachet of what was then the hot new web-programming language.

      LiveConnect is "a feature of Web browsers that allows Java and JavaScript software to intercommunicate within a Web page", apparently introduced in Netscape 4.

      --
      Visual IRC: Fast. Powerful. Free.
    148. Re:Seriously Java? by Xest · · Score: 1

      The problem with pretty much all Java is faster than C/C++ benchmarks are that they're not fair.

      Effectively, C/C++ do exactly what you tell them to do, no more, no less. Java and the JVM however does more than you tell it to (due to garbage collection etc.), some of the things it does in the background greatly improve performance.

      The problem we have then, is that comparisons of C/C++ vs. Java performance compare how specific lines of code perform ignoring that C/C++ is doing what it's told but Java is doing more than that to optimize things hence on big operations the optimization pays off.

      I am not however disputing your underlying point, that it's silly to write off Java as slow. Although technically I disagree with suggestions that Java is faster than C++ because it's disingenious, I feel there's little point writing more code in C/C++ (i.e. the optimizations Java performance) to get a real albeit negligible speed increase when you can get nearly equivalent performance in far less code with Java and enjoy benefits of portability, generally greater security, and generally less error prone software.

      It's a question of balance as always and the reality is the amount of development time required to squeeze the performance of a C/C++ application to levels only negligibly beyond that of a Java application by manually writing the required performance optimizations on top of the code required to be run itself is almost certainly never worth it.

      So is C/C++ dead? Well no, ignoring the argument about legacy applications that still need it, there are still a few areas where Java doesn't optimize quite as well as it should and in those cases it may well be worth writing your code in C/C++ and doing the optimization yourself. There's also an argument for in some cases knowing what optimizations are in fact being done, but as the JVM is open source now this argument is fading too. Of course, memory usage is also a different question to performance - if you have limitations here then Java struggles a little more against C/C++ and such.

    149. Re:Seriously Java? by ahabswhale · · Score: 1

      I've worked on Java for 8 years now. I've worked on MANY java projects in that time. Sorry but for the last 6 years I've never had a problem with write once, run anywhere. In fact, ever corp I've worked at in recent years works based on that very assumption. 90% of the places I work at the developers will develop on Windows, produce the executable, and make it available to WebSphere or Weblogic admins who simply have to deploy it. Every server-side Java developer I know of works in similar fashion. So I'm by no means a rare exception.

      That would not be possible without write once, run anywhere. The only times I've heard problems with this arrangement is when people write bad Java code and do things that make assumptions about the operating system and of course if you use JNI then all bets are off.

      --
      Are agnostics skeptical of unicorns too?
    150. Re:Seriously Java? by jsebrech · · Score: 1

      I remember using that feature back in the netscape 4 days to write a web-based annotation tool. Some of the heavy lifting in the UI had to be done by java applets, and these were driven from javascript. Thinking back, it's amazing how much potential there was in the browser tech of the day, and how little of it was realized until the great browser hibernation forced web developers to look at what browsers already did that could let them build better apps.

    151. Re:Seriously Java? by twoHats · · Score: 1

      ... and I used to use Java instead of Python.

      - From a former Sun Java instructor -

    152. Re:Seriously Java? by X0563511 · · Score: 1

      Stop thinking Sun. Java is now under the yoke of Oracle.

      That (should) change your thinking on this matter a little.

      --
      For large sets, this will be our guide even unto death, for the LORD will work for each type of data it is applied to...
    153. Re:Seriously Java? by Anonymous Coward · · Score: 0

      Seriously Java is very fast these days. Graphics2D is all done in Direct3D or OpenGL shaders

      Actually... no. OpenGL is turned off by default, and using it is explicitly unsupported. Direct3D may be enabled by default, but that's a proprietary Windows-only technology, so of little interest to many Slashdotters.

      As for general performance -- um, no again. Java is fast enough for many purposes, and it's faster than scripting languages like Perl, Python, or the truly molasses-tastic Ruby, but anyone who thinks Java is "very fast" is deluding themselves.

      Yes, it's possible to write fast microbenchmarks. That's true of most languages, particularly if you happen to control the reference implementation and can therefore tweak the runtime to improve your microbenchmarks. It is meaningless when evaluating real-world performance, since real-world code is generally structured very differently from microbenchmarks. In the real world, Java's performance is strictly middle-of-the-road, and C++ is noticably faster for nearly any purpose.

    154. Re:Seriously Java? by Anonymous Coward · · Score: 0

      the performance is mostly a non-issue these days

      Translation: Java is still as slow as always, but computers are a lot faster these days so it doesn't matter as much.

    155. Re:Seriously Java? by SplashMyBandit · · Score: 1

      But why do we need a whole industry and a lot of research to patch a language to make it fast ? Instead of using something that is already fast in it's own right ?

      Good question. I would answer that it is because the development time (that is, cost of developing a large system) of C++ outweighs its benefits. Many (commercial) software projects succeed or fail at the proposal stage based on development time and estimated cost. With C++ the benefits are often not compelling enough. For you own little programs either C++ or Java are viable options, but Java is arguably easier to get going and get working correctly for developers starting the craft. Plus, Java has several advantages over Standard C++: more support for multithreaded programming, a larger set of standard libraries, better source code portability between platforms and different compilers, etc.

    156. Re:Seriously Java? by SplashMyBandit · · Score: 1

      The overall Java performance is lower than the performance of the same C++ program though, due to the following reasons:

      1) excessive run-time casting. C++ templates are a great win over Java generics.

      You may be right. I need to cast very rarely in my programs by choosing my types judiciously. The performance bottlenecks in my programs are never casting, instead they are doing matrix and image processing operations.

      2) calling a method on an interface is an order of magnitude slower than vtable calls. Incorrect. The Hotspot compiler can inline many calls including interface calls, since the runtime can determine how the call is *actually* used rather than how the method *might* be used. Here runtime compilation beats compile-time optimisation. 3) Java consumes way more memory (the simplest widget, for example, consumes over 1K).

      True with the Sun runtime, not really true if you use gcj. Memory usage in Java is definitely an issue for memory constrained devices. However almost all desktops and servers these days have multi-gigabyte RAM. The in-memory size of the Java runtime library is insignificant to the user's data structures in large programs and generally insignificant to the amount of RAM available on most user's systems (and the memory footprint of a single Java program is pretty small compared to the memory consumed by XP or Vista itself).

    157. Re:Seriously Java? by SplashMyBandit · · Score: 1

      If Java Hotspot is outperforming the "best" C Compilers it's due to those compiler companies spending very few, if any, cycles on getting more performance out of their compiler.

      That could be true but I find it hard to believe. The point is moot though, what matters is which program runs faster for a particular application and how much effort is required to develop the application (time/cost is often prohibitive for many projects).

    158. Re:Seriously Java? by SplashMyBandit · · Score: 1

      That's got to make a lot of physicists and quantum chemists very happy.

      If only that were true. Unfortunately there is a lot of out-of-date information being given to these guys, which is why they still labour developing with less-productive languages.

      FYI, I'm an IT consultant to government using Java, C++, and C, have a PhD in Astrophysics and still write image analysis and hardware interface code (C++ and Java JNI) for my old research project. So I feel somewhat qualified in my statements.

    159. Re:Seriously Java? by SplashMyBandit · · Score: 1
      What version of the JDK are you using? Java 6 has improved speed considerably.

      Here is are interesting benchmarks comparing floating point performance:

      1) http://www.fourmilab.ch/fourmilog/archives/2005-08/000567.html

      Java is 12% slower than C and Visual Basic.NET is 13% faster. This is based on the usage of an optical design ray tracing programme.

      2) http://kano.net/javabench/

      Note: If you are raising numbers to an integer power you will almost certainly get better performance doing y = x*x*x than y = pow(x, 3.0) in any language.

    160. Re:Seriously Java? by julesh · · Score: 1

      What version of the JDK are you using? Java 6 has improved speed considerably.

      I'm on 1.6 and have been since beta releases of it, as it added some features I desperately needed. It improves the situation for some floating point algorithms, as I believe it uses processor intrinsic implementations of sin and cos, but not exp.

      Here is are interesting benchmarks comparing floating point performance:

      1) http://www.fourmilab.ch/fourmilog/archives/2005-08/000567.html

      Java is 12% slower than C and Visual Basic.NET is 13% faster. This is based on the usage of an optical design ray tracing programme.

      Again, this is using only raw floating point and trig. Sun's Java VM supports processor-based trig functions, but not other transcendental functions.

      2) http://kano.net/javabench/

      None of these are floating point benchmarks. I agree entirely that there is little reason to avoid using Java for integer number crunching.

      Note: If you are raising numbers to an integer power you will almost certainly get better performance doing y = x*x*x than y = pow(x, 3.0) in any language

      Agreed. My problem is very specifically calculating 1 / (1 + e^{-x}), which is somewhat slower in Java than in (e.g.) C, and can't be helped with any such transformation.

    161. Re:Seriously Java? by SplashMyBandit · · Score: 1
      So you have a value between 0.5 and 1 (assuming non-negative integers).

      How many times do you compute this in your program and what accuracy do you need?

      You might receive a large speed boost using the tried and tested look-up table if you only need 6 digits of precision rather than 15. You could compute your function for a million values of x for example and do a look up at runtime. Games do these kinds of look-up all the time to get good performance (even in C).

      If speed of this function is *really* important you could do the computation in your GPU (I used Java JoGL with a shader to do fast single-precision floating point).

    162. Re:Seriously Java? by cowdung · · Score: 1

      Guys: Java is generally used for web apps.

      So from a performance perspective, Java is very good because:

      1. There are tons of sophisticated tools for building web apps
      2. I manages memory very efficiently
      3. People build HUGE servers w/it no problem.. others build distributed apps that run on hundreds of servers
      4. The database is usually the bottleneck in this sort of app

      C/C++ are not generally used for web apps.. so the comparison is really apples and oranges.

      Among the web languages, Java is among the fastest.. and most scalable and has the most tools.

      That is what mostly matters.

    163. Re:Seriously Java? by NNKK · · Score: 1

      I'm going to make a radical statement about Java applications. It's not about Java itself, and it's not based on benchmarks, but from 10+ years of using Java applications. Here it is:

      Java apps are slow.

      This is invariable. Every "end-user" (that is, not server-side) Java application I have ever used just _crawls_. (I don't much care about server-side; within certain bounds, I subscribe to "hardware is cheap" in that area, so I'm more concerned with scalability.)

      Now, there are three likely causes to the phenomenon of universal turtle-ness in applications written in a given language:

      1) The language is fundamentally flawed.

      2) The implementations are flawed.

      3) People don't know how to write fast code in that language.

      When I talk to Java partisans, option #3 is by far the most common, and option #2 is also frequently used. Then there's blabbering about how widely used Java is.

      What none of them seem to understand is that it's been fifteen years. If #2 and #3 were going to be fixed, one would think it would have happened by now.

      There are two possible conclusions to take from this:

      1) The language is so fundamentally flawed that producing fast code is prohibitively difficult, even if it's theoretically possible.

      2) The language's community, and its stewards, don't care about producing fast code.

      Neither is particularly flattering, to Java, and either way, it's going to continue to be ridiculed as "slow" until the average Java app's performance begins to approach the average C++ app's performance. So far, I've seen no evidence of that occurring.

    164. Re:Seriously Java? by imgod2u · · Score: 1

      You could calculate e^(-x) with sin and cos...

      You can even do it with bit-shifting using a CORDIC algorithm.

    165. Re:Seriously Java? by SplashMyBandit · · Score: 1

      Do you write code in Java? I would suggest you write something yourself and then see if it is slow. There's never been a performance problem I haven't been able to get around - the problem was always my code not the JVM.

  2. Let the man answer please... by SurfMan · · Score: 3, Insightful

    With the JavaOne starting this week, it might be a nice opening question on day one... "What the hell are you thinking, mister Schwartz??"

    1. Re:Let the man answer please... by AKAImBatman · · Score: 3, Funny

      "What the hell are you thinking, mister Schwartz??"

      I'm thinking he turned to Ellison and said... "Let the Schwartz be with you!"

    2. Re:Let the man answer please... by laffer1 · · Score: 1

      Just as long as Ellison doesn't have liquid Schwartz in his glove compartment!

  3. aha! I knew all along by gbjbaanb · · Score: 0

    ... that the old Garbage collector was rubbish - we've been saying it for years, Java uses too much memory, is too slow, is just all about vendor lock-in....

    And now, its proven - they've brought out a new GC that's so much better, it might actually fix all the problems with Java! Proof that the old one was pants.

    Surely.

    Of course.

    The old one was unusable, wasn't it?

    We were unable to make anything work properly using Java in the past, yes?

    maybe? ... :)

    1. Re:aha! I knew all along by Verdatum · · Score: 2, Informative
      No, the old, old garbage collector was rubbish. Java has been taking crap for it ever since, even though it changed garbage collecting mechanisms ages ago.

      From en.wikipedia.org/wiki/Java performance:

      "The 1.0 and 1.1 Virtual Machines used a mark-sweep collector, which could fragment the heap after a garbage collection. Starting with Java 1.2, the Virtual Machines switched to a generational collector, which has a much better defragmentation behaviour. [2] Modern Virtual Machines use a variety of techniques that have further improved the garbage collection performance.[10]"

  4. Maybe by Anonymous Coward · · Score: 1, Interesting

    Someone can add this to OpenJDK or a fork of OpenJDK?

    1. Re:Maybe by mmkkbb · · Score: 1
      --
      -mkb
    2. Re:Maybe by Verdatum · · Score: 1

      I can see it now: The RLYOpenJDK(4SRSLYTHSTEIM) Project

  5. Garbage collector? by smooth+wombat · · Score: 4, Interesting

    As a non-programmer, can someone give a brief explanation of what a garbage collector is as it pertains to programming.

    --
    We will bankrupt ourselves in the vain search for absolute security. -- Dwight D. Eisenhower
    1. Re:Garbage collector? by gubers33 · · Score: 5, Informative

      Garbage collection is the process freeing objects that are no longer referenced by the program.

      --
      Just because you are wrong and I called you out on it doesn't mean I am a Troll.
    2. Re:Garbage collector? by MarkvW · · Score: 1, Informative

      I think garbage is allocated memory that is no longer needed.

    3. Re:Garbage collector? by whiledo · · Score: 2, Funny
      --
      Moderators: Before moderating a comment Insightful/Informative, check to see if a child post has already refuted it.
    4. Re:Garbage collector? by HBI · · Score: 5, Informative

      Java hides the details of memory allocation from the programmer. Objects, strings, etc use memory. When they are first used, Java makes sure that the appropriate amounts of memory are allocated for the item in question. When these items are no longer in use, the garbage collector finds them and frees the memory so that it can be used for other parts of the application.

      VB is another place where a garbage collector would be found. Ditto .NET.

      --
      HBI's Law: Frequency of calling others Nazis is directly correlated with the likelihood of the accuser being Communist.
    5. Re:Garbage collector? by Anonymous Coward · · Score: 0

      I'm sure that Wikipedia can supply a nice, concise answer complete with references.

      In brief, garbage collection is what allows programmers to be freed up from having to manage memory on their own. The VM keeps track of how memory is being used, and if it thinks that some memory can be freed up, it will release that memory.

    6. Re:Garbage collector? by pak9rabid · · Score: 1

      As a non-programmer, can someone give a brief explanation of what a garbage collector is as it pertains to programming.

      In Java, the garbage collector runs periodically to free up memory associated with objects that are no longer needed. It' a built-in memory management system that frees the programmer from having to worry about managing dynamic memory manually. In theory, it makes it impossible for your applications to contain memory leaks, but comes at the cost of performance (historically at least, this may change that).

    7. Re:Garbage collector? by MyLongNickName · · Score: 1

      Essentially the reclaiming of memory. Traditionally when you created complex objects in code, you would have to explicitly release the resources. Otherwise, you had the notorious "memory leaks" that caused your computer to slow down or even crash if memory continually got used and not freed up. garbage collection is an asynchronous process that goes and looks for objects that are no longer referenced and frees up space.

      And having programmed back in the days of Borland C, I see why it is needed. I also see that a lot of programmers are just lazy and don't think about their code.

      --
      See my journal for slashdot ID's by year. Mine created in 2005. http://slashdot.org/journal/289875/slashdot-ids-by-year
    8. Re:Garbage collector? by immakiku · · Score: 1

      They are a part of memory management. When a program allocates memory, it has to free it. In most programming languages, the programmer will manually decide when memory is freed. This is usually when the memory that was allocated is no longer needed - say you loaded a file to memory to run some calculations and you just finished, so now you free that file from memory because you don't need to access it anymore. That freed area of memory can now be used for other purposes. Java has a built in "garbage collector" that will take care of freeing memory for you. In general, a garbage collector will keep track of each piece of allocated memory; it is responsible for knowing when your program is no longer using the memory and initiate the freeing of that area of memory.

    9. Re:Garbage collector? by morgan_greywolf · · Score: 2, Informative

      Okay, here's a better description: garbage collection is a means of freeing memory by cleaning out old objects (variables, buffers, data structures, code, etc.) the program doesn't need anymore.

      Example: I open a file in an application and work with it. While working with it, the programs allocates buffers (temporary holding places) and data structures and so forth in memory. When I'm done, I close the file. The application needs no longer needs all this data associated with the file, so it calls garbage collection routines to free them up.

    10. Re:Garbage collector? by forkazoo · · Score: 3, Informative

      As a non-programmer, can someone give a brief explanation of what a garbage collector is as it pertains to programming.

      C++ has two important keywords: "new" and "delete." You use new when creating an object, and when you are done with it, you use delete to free up the memory it was using. (And, depending on the object, it may do some special stuff while being deleted, like close network sockets, or write a log entry about how sad being deleted is.)

      Java has a concept of "new," but it doesn't have a "delete." (Well, the concept exists behind the cutain, but programmers never delete things themselves when using Java.) Java assumes that you are more interested in creating stuff, and don't want to be bothered with the minutia of getting rid of it when you no longer care about it. So, the Java run time goes around deleting stuff that seems like it is no longer being used. (Reference count indicates it can no longer be used.) This is called garbage collection. It's a surprisingly tricky, and nuanced process to figure out when stuff should be deleted. You want to be pretty prompt in deleting stuff that is no longer used so it doesn't sit around using memory for no reason. But, you don't want your garbage collector to be so manic about cleaning things up that the actual program doesn't get enough CPU time to get anything done. You also want a garbage collector to be fairly predictable. It's great if it usually has a low overhead, but terribly if it occasionally goes insane and locks everything up for three minutes under some use cases.

      This new garbage collector is a little more sane, a little quicker and a little less manic. For many well written programs, the difference won't be that huge because they shouldn't creating and abandoning enough stuff for garbage collector to really matter. At least, that's my assumption. If I ever actually meet a well written program, I'll be able to verify that. :)

    11. Re:Garbage collector? by Anonymous Coward · · Score: 0

      When you instantiate an object (or a variable in other languages), some memory is reserved for this object. In C/C++ for instance, If you don't pay attention to free this assigned memory once you don't use this object/variable anymore, memory can run out quickly leading to a slow machine at best and a crash at worst, and you have to free that memory explicitly. In Java it is automatically detected by the Virtual Machine and freed. However, this VM memory management (garbage collection is a type of memory management) is not perfect and certainly needs improvements.

    12. Re:Garbage collector? by KeithIrwin · · Score: 4, Informative

      When computer programs need to keep track of information, they store it in the computer's memory. The information they store is generally arranged into structures. In object-oriented languages like Java, these structures are called objects. Every object has to have its own place in memory, called an address. Two different objects cannot use the same space in memory at the same time. When a program has a new object that it needs to create, it has to know where to put it. To do this, it uses a system which allocates some memory for it. When the program is done with the object, it should be deallocated so that the same memory can later be used for a different object. If objects are not deallocated when they are done being used, then the program will grow to take up more and more memory over time until the computer runs out of memory. This is called a memory leak.

      There are two main scheme for deallocating an object's memory once the program is done with it. Older programming languages use explicit memory deallocation, meaning that when the program is done with an object, it says so. This can unfortunately be somewhat problematic. If a program forgets to say that it's done with an object, then that object never gets deallocated and the program leaks memory. If the program says that it's done with an object when some other part of the program is still using the object, then a new object of a different type might be written over the old object but because the other part of the program doesn't know this has happened, all sorts of odd problems can occur.

      To solve this many newer languages including Java use a technique called garbage collection. In a garbage collecting language, the program does not explicitly say when it is done with an object. Instead the garbage collection system examines the cross-references between different objects to determine whether or not it is still possible for the program to use a particular object. If using it is impossible, then the system will deallocate it. In most systems, the garbage collection doesn't run continually swooping up every new bit of space the moment it becomes available, but instead just runs periodically clearing out anything which has become unusable since the last time it ran.

    13. Re:Garbage collector? by Anonymous Coward · · Score: 0

      I'm unhappy with the other explanations people are giving you, so here's a different one.

      Imagine that a computer's available memory is like a big empty lot that you (the programmer) can build a bunch of houses on. Every time your program needs to remember a number or a piece of text, you have to put it in a house. If you run out of places to build houses, you'd better be able to take down the ones you no longer need, because otherwise the program has to stop running.

      A garbage collector is an automatic program-within-a-program. It keeps a close eye on whatever you're doing, and whenever it notices that you no longer need a house you've built, it takes it down automatically, so you can build a new house there.

      Obviously, the garbage collector needs to be very smart. If it takes down too few houses on each pass, your program will run very slowly, or stop working. If it takes down too many, your program will try to use resources that no longer exist, and then it will certainly crash. Garbage collectors are hard to write, and people get paid huge piles of money to figure out how to make them as smart as possible.

      The G1 collector is a newer, better, smarter type of garbage collector that will probably make Java programs run faster and use less memory. This is something that everyone wants, so Sun/Oracle can get away with charging money for it, because people will pay.

    14. Re:Garbage collector? by Anonymous Coward · · Score: 0

      As a non-programmer, can someone give a brief explanation of what a garbage collector is as it pertains to programming.

      As a non-programmer, why do you care?

    15. Re:Garbage collector? by bjourne · · Score: 2, Informative

      A gc (garbage collector) is what programmers use instead of manually handling memory. In non-gc languages such as C programmers have to spend a lot of time being careful not to inadvertently create memory leaks. So programming in languages with gc is generally faster than in those without.

      The drawback is that memory is often handled less efficiently by the gc than by the programmer so the program becomes slower and uses more memory. However that depends on the quality of the gc. It is quite easy to write a gc, but that one probably will have awful performance. Writing a good is harder and takes more time. Writing one with performance that handles memory as good as a skilled programmer handling manual allocation is exceptionally hard and requires man-years in effort.

      It's like a chess engine, most programmers can write one but if you want one that can match a human or even Big Blue then you need to spend some time on it. So from Oracles perspective, it very much makes sense to try and monetize their high performance gc even if it's a shitty move overall. Most chess players has no use for a chess engine stronger than grandmaster level. But there are professional players out there who has a genuine need for a more challenging chess engine and would pay good money for it. In a similar vein most Java programmers can live with the default gc, but some big enterprises will feel they need a better one and pay lotsa $$$ for it even if the performance gain is only 5-10%.

    16. Re:Garbage collector? by Anonymous Coward · · Score: 1, Funny

      Hey, all of you sitting above my post. Yes, all of you who replied to that moron! Thanks for wasting all that screen real estate so you can feel smart explaining to the layman something he could have JustFuckingGoogled!

      Troll'd. All 'o' ya!

    17. Re:Garbage collector? by drinkypoo · · Score: 4, Funny

      So, which pay-for-answers site do you plan to post the responses on? Or are you feeding a plagiarism detector?

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
    18. Re:Garbage collector? by mikael · · Score: 2, Informative

      When you create objects to represent information consisting of things like character strings, arrays, lists and hierarchical trees, you make a system call to create a new list of data objects.

      In languages like 'C', this would be like 'malloc( number of bytes) ' or 'calloc( number of bytes)'. You would then have to match every such call with an equivalent 'free( pointer)' to ensure the memory was freed. Failure to do so leads to 'memory leaks' where the memory space is allocated but incorrectly freed (caused by uninitialised pointer variables, missing calls or faulty decision making).

      C++ tried to fix this by having 'new' and 'delete' operators which were intended to be called through the constructor (a function automatically called with the object is created) and the destructor (a function automatically called when the object is destroyed). However, there were times when these functions also needed to be called throughout the lifetime of the object, so memory leak problem crept in again.

      JAVA attempts to fix C++ by eliminating the need for the 'delete' operator. Since every function always belongs to a class, and consequently a data object, data always belongs to a data object. Memory is allocated as before, but when a data object ceases to be in use (return of a function call), it is placed in the garbage area. At periodic intervals, the garbage collector is called and all the allocated memory blocks are collected and freed. The disadvantage is that an application could build up a large amount of "garbage memory" and could freeze for several seconds while this process occurred.

      --
      Vintage computer adverts: http://www.vintageadbrowser.com/computers-and-software-ads
    19. Re:Garbage collector? by ultrabot · · Score: 1

      Hey, all of you sitting above my post. Yes, all of you who replied to that moron! Thanks for wasting all that screen real estate so you can feel smart explaining to the layman something he could have JustFuckingGoogled!

      Indeed. Seeing explanations for trivial driver like this is even more annoying than people asking about it. Please at least *attempt* to keep slashdot as "news for nerds"...

      --
      Save your wrists today - switch to Dvorak
    20. Re:Garbage collector? by eh2o · · Score: 1

      Garbage collection is notoriously problematic for programs that are doing something that requires temporal predictability or a fast response time, because the GC has to interrupt the running program to clean up, and the interruptions can be quite long in duration (tens of milliseconds or worse).

      This new G1 collector has a soft real-time bound so its a nice middle ground between hard RT Java (which is proprietary, I'm pretty sure, and probably also not so great with performance as is often the case with hard real-time), and the standard but temporally unpredictable throughput-oriented concurrent-mark-sweep GC.

      By the way, using malloc() is potentially just as bad for time-critical code, since if there is a page fault, this can invoke a very expensive system call that effectively freezes your code until it returns.

      Most benchmarks, e.g., as found in various programming language shoot-outs, only measure throughput, so the subtleties of timing-related behavior and related performance problems are not well known.

    21. Re:Garbage collector? by nog_lorp · · Score: 5, Insightful

      Substitute "objects" with "memory" and "referenced" with "used", and you might actually reach the intended audience (people who aren't programmers).

    22. Re:Garbage collector? by Anonymous Coward · · Score: 0

      It's the alternative to memory management for people like yourself.

    23. Re:Garbage collector? by scubamage · · Score: 1

      It de-allocates the refuse of the program so your computer can use it for other stuff.

    24. Re:Garbage collector? by BikeHelmet · · Score: 1

      (Reference count indicates it can no longer be used.)

      Modern garbage collectors don't use reference counting.

      JIT Compilers are neat (especially Hotspot). Java actually sometimes generates more optimized code than C; but you still have the extra memory overhead, and garbage collection slows it down by anywhere from 10-15% (possibly more in server environments, as memory usage approaches capacity)

      So in a theoretical computer with unlimited memory, Java would be faster because of the dynamic optimizing nature, but such a system doesn't exist. :P

    25. Re:Garbage collector? by Anonymous Coward · · Score: 0

      LISP has garbage collection. LISP is older than C.

      Just because newer languages have GC and C does not does not mean that lack of GC is a feature of older languages.

    26. Re:Garbage collector? by skeeto · · Score: 1

      Look at all these redundant, detailed responses you got! People around here (myself included) really like hearing themselves talk, huh? :-D

    27. Re:Garbage collector? by shutdown+-p+now · · Score: 1

      So, the Java run time goes around deleting stuff that seems like it is no longer being used. (Reference count indicates it can no longer be used.)

      Java doesn't use reference counting for GC. It traces the object graph instead (which is why it can handle cyclic structures, which a pure refcounting GC cannot do).

    28. Re:Garbage collector? by Anonymous Coward · · Score: 0

      It's "drivel," you cock-gargling retard.

    29. Re:Garbage collector? by Anonymous Coward · · Score: 0

      It's "drivel," you cock-gargling retard.

      It takes a nitwit to confuse a typo with actual brainfart...

    30. Re:Garbage collector? by jeremyp · · Score: 5, Informative

      As a beer drinker, I drink lots of beer. When I was a C++ programmer, I had to make sure I threw away my empty beer cans after drinking the beer. Unfortunately, occasionally, I forgot to do that and pretty soon my room would fill up with empty beer cans so that I couldn't get to the fridge to get more beer out of it.

      However, now I am a Java programmer and I have a servant (a beer can collector) who comes around and clears up the beer cans for me every now and again. I no longer have to worry about throwing them away myself.

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
    31. Re:Garbage collector? by EMG+at+MU · · Score: 1

      Java has a concept of "new," but it doesn't have a "delete." (Well, the concept exists behind the cutain, but programmers never delete things themselves when using Java.)

      finalize() is what the GC called to destroy an object. Every object inherits it from the Object class (duh), so if you want to do some memory management yourself, go ahead and give finalize() a call.

    32. Re:Garbage collector? by Darinbob · · Score: 1

      A Garbage Collector is that really really smart guy who occasionally gives advice to Dilbert while picking up his garbage.

    33. Re:Garbage collector? by Anonymous Coward · · Score: 0

      As a non-programmer, can someone give a brief explanation of what a garbage collector is as it pertains to programming.

      C++ has two important keywords: "new" and "delete." You use new when creating an object, and when you are done with it, you use delete to free up the memory it was using.

      That may be a nice conceptual way to compare C++ to Java but, in general, "new" and "delete" are not how objects (memory) is allocated in C++.

      The general memory allocation model in C++ involves the concept of "scope". A program is almost always broken into block of code (sub-routines). Within these blocks of code there are variables (memory) that are only used within that block of code.

      When you write a block of code in C++, you tell the compiler which variables (chunks of memory) that block will be using and the compiler arranges to make the memory available ("allocate" the memory) when the program reaches that block of code and to then deallocate the memory once the program leaves that block of code.

      In my experience, it's actually fairly rare to use "new" and "delete" explicitly in a C++ program. Every time you call "new" you have to remember to call "delete" later. On the other hand, if you can rely on "scope", all the memory gets deallocated on exit from the block.

    34. Re:Garbage collector? by KeithIrwin · · Score: 1

      You're the one who brought up C, not me. I'm not sure why you thought I said "all languages as old as or older than C lack garbage collection" because I didn't say that. I was making general statements about languages based on age, and I think that should be obvious. Any time one talks about "older languages" or "newer languages" one is generalizing. It was intentional that I didn't use words like "all" and "every".

      If you look at languages over 40 years old, you'll find that the clear majority of them do not have garbage collection. The majority of the oldest languages were special purpose languages written for particular machines which were one step above coding in assembly. Even later when we got more standardized languages most of those didn't have garbage collection either. COBOL, Fortran, Algol, SNOBOL, Pascal, BASIC, and a huge myriad of low-level machine specific languages have no garbage collection.

      Only about 40 years ago did garbage collection start appearing with any non-trivial frequency as languages like Smalltalk and Prolog popped up. Most languages created in the last 20 years have garbage collection. As such, I stand by my generalization.

    35. Re:Garbage collector? by gbjbaanb · · Score: 4, Informative

      good analogy - except you forgot some important bits:

      1. you have to ensure you drink all the beer, and not leave any in the can, or the servant will give it a little shake, and think "masters not finished with this one yet, I'd best leave it".

      2. You are never surrounded by a clean room, there are always empty beer cans lying around waiting for the servant to collect them.

      Now, as a C++ drinker, I have a mechanism that help out, every time I go to the fridge to get a beer, I pour it into the glass object and throw the can away immediately - thus never having empty cans lying around, when the glass is empty, I refill and find the empty can problem is a non-issue. (that's such a convoluted analogy for RAII!)

    36. Re:Garbage collector? by Thomasje · · Score: 1
      finalize() doesn't deallocate objects. The GC calls finalize() on an object when it discovers that the object is no longer reachable; it deallocates the object sometime after finalize() returns.
      Note that it is possible for finalize() to make an object reachable again, e.g. by adding itself to a still-reachable ArrayList. The GC will not deallocate the object in that case; it will wait until the object becomes unreachable again before doing so. It won't call finalize() again, though.
      The idea behind finalize() is to give objects a chance to free non-memory resources, e.g. native windows or file descriptors, before being freed themselves. The problem with this is that you might run out of those resources *before* running out of memory, and then you'd be stuck until the GC runs again. This is why standard Java classes that use native non-memory resources, like JFrame or FileInputStream, have methods to explicitly release such resources (dispose() and close(), respectively). Relying on finalize() is almost always a bad idea.

      See the Object.finalize() javadoc.

    37. Re:Garbage collector? by ActionJesus · · Score: 1

      Right, lets say your playing space invaders. (Programmers may take issue with this, but its as simple an explanation I can muster offhand.)

      You start the game, and you create a "player" and 40 "invaders", each takes 10kb of memory, so you are using 410kb.

      The player shoots 5 invaders. The invaders are removed from the games.

      Garbage collection happens, and the memory allocated to those invaders is freed up. You are now using 360kb of memory.

      Continue until all invaders are dead, and then respawn a new wave of invaders (putting you back at 410kb).

      In the real world it'd probably be more efficient to simply toggle "on" and "off" switches rather than creating and destroying invaders every round, but you (hopefully) get the general idea.

    38. Re:Garbage collector? by Anonymous Coward · · Score: 0

      Except you have to stay still until the servant has finished. I thought about a similar analogy when I was debugging a java mobile game suffering from random pauses caused by the garbage collector. It made me think that no matter how sophisticated the GC algorithm is (and there are extremely sophisticated, especially the optimized ones.) it cannot beat a classic malloc/free allocator in terms of performance.

      I guess the difference is more about the philosophy of the language. One of the basis of the C philosophy is to trust the programmer. Java philosophy is more about sophistication and elegance.

    39. Re:Garbage collector? by TheRaven64 · · Score: 1

      Modern garbage collectors don't use reference counting.

      Someone hasn't been paying attention to recent GC papers. Modern garbage collection does use reference counting, combined with a cycle detector. This gives very low overall latency and good interaction with swapping and NUMA architectures. With a GC designed in this way you only need to run the cycle detector when an object has its reference count reduced but is not deallocated. If you defer this a bit, the object will often be deallocated before you get around to running the cycle detector (and so you don't need to run it). Garbage cycles in real programs tend to be quite small and a cycle detector with a refcounting GC typically needs to traverse a much smaller part of the object graph to find and break a cycle than a tracing GC. This means that the traversal is less likely to cause swapping and less likely to involve objects in other address spaces.

      --
      I am TheRaven on Soylent News
    40. Re:Garbage collector? by shutdown+-p+now · · Score: 1

      In non-gc languages such as C

      It should be noted, however, that there are mark & sweep garbage collectors available for C/C++. By far the most popular one is Boehm-Demers-Weiser GC.

    41. Re:Garbage collector? by Waccoon · · Score: 1

      What confuses me about your summary of Garbage Collection is the phrase, "in use".

      Having only glanced at Java, I was under the impression that the only way something would be marked for cleanup is if you assign NULL to the object. So, what happens if you forget to do that? Java won't clean it up, right? So, if something doesn't get cleaned up unless you "free" it, how is a GC model better at managing mistakes and handling memory leaks than a non-GC model? Does it really just boil down to the convenience of not having to free the memory and the pointers separately?

    42. Re:Garbage collector? by HBI · · Score: 1

      There is also the "you can't use a null pointer for anything" advantage. It's mostly just to act as a prophylactic over programmer error. Doing your own allocation would be better if you could assure zero mistakes. I can't assure that when the size of the application grows beyond X amount. Your value of X will vary, i'm sure.

      --
      HBI's Law: Frequency of calling others Nazis is directly correlated with the likelihood of the accuser being Communist.
    43. Re:Garbage collector? by six11 · · Score: 1

      Garbage collection is the process freeing objects that are no longer referenced by the program.

      I think some of the other responses still might be a bit too technical. I'll give some code.

      Most languages these days have a concept of 'scope', which limits the visibility and viability of a variable. Say you want to implement the mathematical function f(x) = x^2 + 3x + 4. One way you might do this is to calculate each individual term, store it in a temporary variable, and add up all the temp variables at the end to get the result you really want. Every time you want to store a value in a variable, you have to first allocate space for it, and use up even more space remembering where you put it. After calling 'f', the temp variables are still there in the 'f' function's scope, but they're not accessible any longer. If that memory isn't freed, it means you will eventually run out of RAM and start paging to disk. In pseudo-code (fake code to illustrate the point) this might look like:


      define f(x)
          first_term = x^2 // temp var - turns into garbage
          second_term = 3x // temp var
          third_term = 4 // temp var
          result = first_term + second_term + third term
          return result
      done

      a = f(5) // calculate f(x) where x = 5
      b = f(6) // and so on...

      A garbage collector is a language/interpreter tool that can automatically identify the variables that are no longer in scope and are just wasting space that you might need in the future. Building a good GC is tricky, because it takes up processing power and memory of its own, and if it runs at an unfortunate time, it might cause latency in your program.

    44. Re:Garbage collector? by typidemon · · Score: 1

      Everything that is in a program is stored in memory. Some bits of information must be allocated and stored for a long time. One common error is that programmers forget to free that memory when they no longer need it. The outcome of this is called a memory leak. Garbage collection is basically a process where the demigods of java inspect every group of memory that it can find and checks to see if anything needs it. If nothing is looking at that block of memory it frees that memory for other purposes.

      The bonus for programmers is that it simplifies the use of memory dramatically. However, it does this at the cost of speed because some part of Java is going through and checking this memory. A common response is "why don't programmers just clean up there own memory?", well we would, but it's just not that easy to catch all of the memory. Almost all applications that you use today use an event model (e.g. you click the mouse and it fires a mouse event), so it's hard to understand when who what part of the program is responsible for freeing memory. Even worse, many applications have multiple processes running simultaneously with each process responsible for different aspects of the program.

    45. Re:Garbage collector? by imgod2u · · Score: 1

      Of course, after about 500 glasses of C++, you're pretty much shit faced and can't even pour straight let alone remember to throw the beer can away immediately. This is when having a beer-can Roomba would come in handy.

    46. Re:Garbage collector? by jeremyp · · Score: 1

      Point 2 is not really a problem as I am a slob and I don't care how many beer cans are lying about as long as I can get to the fridge. Point 1 is not a problem because once I have let go of a beer can, it is deemed to be finished by the beer can collector. Of course I do sometimes forget to let go of beer cans leading to a bit of a pile up.

      However, when I was a C++ programmer, sometimes I used to accidentally throw away the cans while I was still drinking them which was messy and at other times I'd try to drink from beer cans I'd already thrown away which was embarrassing.

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
  6. In this day and age of "green" businesses... by thomasdz · · Score: 5, Funny

    Shouldn't we have "recycling collection" instead of "garbage collection"?
    C'mon guys all those big 1MB and 4MB malloc()s are being shipped over to third world countries to be disassembled into bits and bytes. We should be recycling things HERE.... not throwing them away for Java to come and pick up.

    --
    Karma: Excellent. 15 moderator points expire sometime.
    1. Re:In this day and age of "green" businesses... by AKAImBatman · · Score: 3, Interesting

      Shouldn't we have "recycling collection" instead of "garbage collection"?

      Despite the humor, you make an interesting point. Had garbage collectors been invented in the 21st century, they might have been called "memory recyclers" rather than "garbage collectors". Primarily because the GC is actually reclaiming memory for reuse. Yet when the term "garbage collection" was coined, the concept of recycling hadn't yet entered common thinking. Ergo, it was identified with "taking out the trash" rather than "recycling something useful".

    2. Re:In this day and age of "green" businesses... by nahdude812 · · Score: 1

      Your point itself raises an interesting question. If it really was called memory recycling, I wonder if there would have been any temptation to reuse such objects instead of freeing them up for use as some different type of object. For example, maybe it's cheaper to reuse an int than to throw away the old one and create a new one. If you clustered similar objects together in memory you could use such a technique to try to avoid memory fragmentation.

      I wonder how much the nomenclature we choose affects the approach we take.

    3. Re:In this day and age of "green" businesses... by Wrath0fb0b · · Score: 1

      For example, maybe it's cheaper to reuse an int than to throw away the old one and create a new one. If you clustered similar objects together in memory you could use such a technique to try to avoid memory fragmentation.

      Not *trying* to rag on your idea, but this just isn't true in x86. Not by an order of magnitude actually, since an int on the stack can be operated on for free while one on the heap has an extra indirection operator required before it can be operated on. In many contexts, it's cheaper to actually make a local copy of an int stored in some object elsewhere and update it when you are down.

      Moreover, locality of reference means putting together data that will be accessed together, not data of the same basic type. If "Customer" is defined by ulong _id, float _balance, enum_t (int) type, all those should be contiguous in memory (the C++ style) instead of having an array of floats for the balances, an array of ulongs for the ids (the Fortran style) so that they can fit in a cache line.

    4. Re:In this day and age of "green" businesses... by Anonymous Coward · · Score: 0

      Your point itself raises an interesting question. If it really was called memory recycling, I wonder if there would have been any temptation to reuse such objects instead of freeing them up for use as some different type of object. For example, maybe it's cheaper to reuse an int than to throw away the old one and create a new one.

      Maybe I am way off base, but something like this maybe ? notice lack of any call to free(), at least in this file. looks to me like a doubly-linked list of "recycled objects".

      /* $Header: object.c,v 7.0 86/10/08 15:12:55 lwall Exp $ */ /* $Log: object.c,v $
        * Revision 7.0 86/10/08 15:12:55 lwall
        * Split into separate files. Added amoebas and pirates.
        *
        */

      #include "EXTERN.h"
      #include "warp.h"
      #include "INTERN.h"
      #include "object.h"

      void
      object_init()
      {
              ;
      }

      OBJECT *
      make_object(typ, img, py, px, vy, vx, energ, mas, where)
      char typ;
      char img;
      int px, py, vx, vy;
      long energ, mas;
      OBJECT *where;
      {
              Reg1 OBJECT *obj;

              if (free_root.next == &free_root)
      #ifndef lint
                    obj = (OBJECT *) malloc(sizeof root);
      #else
                    obj = Null(OBJECT*);
      #endif
              else {
                    obj = free_root.next;
                    free_root.next = obj->next;
                    obj->next->prev = &free_root;
              }
              obj->type = typ;
              obj->image = img;
              obj->next = where;
              obj->prev = where->prev;
              where->prev = obj;
              obj->prev->next = obj;
              obj->velx = vx;
              obj->vely = vy;
              obj->contend = 0;
              obj->strategy = 0;
              obj->flags = 0;
              obj->posx = px;
              obj->posy = py;
              if (typ != Torp && typ != Web) {
                    occupant[py][px] = obj;
              }
              obj->energy = energ;
              obj->mass = mas;
              return(obj);
      }

      void
      unmake_object(curobj)
      Reg1 OBJECT *curobj;
      {
              curobj->prev->next = curobj->next;
              curobj->next->prev = curobj->prev;
              if (curobj == movers) {
                    movers = curobj->next;
              }
              free_object(curobj);
      }

      void
      free_object(curobj)
      Reg1 OBJECT *curobj;
      {
              curobj->next = free_root.next;
              curobj->prev = &free_root;
              free_root.next->prev = curobj;
              free_root.next = curobj;
      }

  7. We buy... by Anonymous Coward · · Score: 1, Insightful

    We buy garbage, instead of the real product these days? :)

  8. Troll? by iamhigh · · Score: 5, Funny

    If you post a troll comment to an article tagged troll, do you get insightful mods?

    In Soviet Russia, article trolls you!

    --
    No comprende? Let me type that a little slower for you...
    1. Re:Troll? by keithjr · · Score: 2, Informative

      Only if the article actually is a sensationalist piece of trolling. Sun is releasing an experimental feature to a subset of customers rather than the entire world. And Oracle does not own Sun yet, since the deal has not even been finalized, and therefore is not making decisions about Java.

      Slashdot, you disappoint me. Again.

    2. Re:Troll? by amicusNYCL · · Score: 0

      And Oracle does not own Sun yet, since the deal has not even been finalized, and therefore is not making decisions about Java.

      Really? You think that Sun is going to jeopardize its deal with Oracle by doing things with Java that Oracle doesn't want it to do? You better believe that Sun is looking for approval from Oracle before it does anything major. Because, like you said, the deal hasn't been finalized.

      --
      "Our two-party system is like a bowl of shit looking at itself in a mirror." - Lewis Black
    3. Re:Troll? by julesh · · Score: 1

      Slashdot, you disappoint me. Again.

      You should probably learn this: never have high hopes for slashdot.

      I stopped being disappointed with slashdot some time around 1999.

  9. This was BEA's model with JRockit by MarkEst1973 · · Score: 4, Interesting

    JRockit has all kinds of monitoring features, memory profilers, and other useful metrics built into the JRE, but you need a license key to unlock them. Core Java was always free. You pay for the value-added stuff.

    1. Re:This was BEA's model with JRockit by nurb432 · · Score: 1

      i would consider garbage collection a core feature of a language.

      --
      ---- Booth was a patriot ----
    2. Re:This was BEA's model with JRockit by owlstead · · Score: 1

      OK, so your post has already been taken over by the point that this experimental feature is not actually locked (and is in the OpenJDK as well).

      I've never seen too many people pay Sun for "value-added stuff" unless they actually had to do something for it. Actually, you could even go as far as marking Sun too nice, as they are making few bucks on Java itself. Hopefully Oracle will think Java is too important to take chances with - I would consider this likely since they are pretty big players in the Java camp and are likely to loose an important foothold when Java fails.

    3. Re:This was BEA's model with JRockit by ardle · · Score: 1

      As long as there's an open (fixable) gc out there, we have nothing to stress about.
      It's a win-win for Sun and their (few) paying clients: even if paid and free versions are identical, customer gets support contract.
      It may be in Sun's (Oracle's) best interests to keep the versions identical (closed, customer-specific extensions excepted): the open version will try to solve its own problems, giving staff more time for contract work/research...

  10. Perhaps by alexborges · · Score: 5, Interesting

    "Will OpenJDK be doomed to a feature-castrated backwater while all the good stuff goes into the new Java SE for Business commercial version?""

    Perhaps. But now that its GPL, maybe IBM, RH and the rest of Java's stakeholders will get onto making openjdk better than oracle's. Ill sure contribute: this is a strategic need for the foss movement.

    --
    NO SIG
    1. Re:Perhaps by slack_justyb · · Score: 1

      I agree. Look at all the different implementations for Java EE standards. For example TopLink essentials vs. the actual product from Oracle, or all of the different JSF implementations out there.

      This isn't anything new and in fact I consider it one of the great points of Java. You can pick and choose which JVM flavor best meets your needs / taste and implement it in your total stack. You can have different Application Servers (Glassfish, JBoss...), different persistence layers (Hibernate, TopLink ...), different database back ends (MySQL, Derby, Oracle...), different GUI tool sets (Swing, AWT, SWT), different presentation layers (JSF, Struts...), and so on.

      I know a few .NET programmers (I've got nothing but love for you guys) who find this all very confusing and find it hard to understand how any of this can be healthy when they just have the MS runtime, ADO.NET, ASP.NET and third party add-ons for those first three items. (IANA.NP, I am not a .NET programmer, or at least professionally)

    2. Re:Perhaps by iztaru · · Score: 1

      You are right! I do not know all the fine print regarding the JDK, but I have always think of the garbage collector as an internal feature. If they continue to publish the JSR's and they are good specifications (not like the OOXML) any open source project can implement them as they see fit and people will use the best open source solution or will pay for the Oracle implementation if they want. You can see the example in J EE. You have JBoss, Jonas, WebSphere, WebLogic, etc.

  11. It's "experimental" by ensignyu · · Score: 5, Insightful

    To try G1, specify these command line options:

    -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC

    I don't see anything obvious preventing you from using it (no license/support keys?), it's just not recommended since it's experimental. If you're crazy enough to use it on a production server, you better have a support contract so Sun/Oracle can fix any problems that come along. That seems reasonable.

    Although it'd be better if they just said "don't use it for production, period."

    1. Re:It's "experimental" by fatp · · Score: 3, Informative

      It is the tradition of Oracle to distribute software with all functionality (including those separately licensed expensively) and let the user to make sure they don't use unlicensed features.

    2. Re:It's "experimental" by Seakip18 · · Score: 1

      Or better, don't even distribute it in the FREAKIN' JDK OR JRE.

      You want to release it? Sell it as a stand alone patch or jar. Don't sneak it it into the jdk or jre and start making us ask "Is Java evil now?" Well, unless it comes to memory allocation....

      --
      import system.cool.Sig;
    3. Re:It's "experimental" by deraj123 · · Score: 4, Insightful

      I don't know...the release notes specifically say:

      Although G1 is available for use in this release, note that production use of G1 is only permitted where a Java support contract has been purchased.

      On the other hand, I was unable to find any specific mention of G1 anywhere in the licensing agreement. However, I did find this:

      Sun grants you a non-exclusive, non-transferable, limited license without license fees to reproduce and use internally Software complete and unmodified for the sole purpose of running Programs.

      If anyone is able to point out in the actual licensing where the quote from the release notes is backed up, I'd be interested. (text near the second quote there did allow for "exceptions" and "supplemental terms" - but I wasn't able to find any pertaining to G1)

    4. Re:It's "experimental" by Anonymous Coward · · Score: 3, Interesting
      For those who need this spelled out:

      1. Distribute working but unlicensed software
      2. Encourage developers to use the software
      3. Audit companies using said software
      4. Profit!

      We've gone through more than one episode that starts with: "shite -- we have to rip out this proprietary Oracle crap or pay another X (usually 6+ figures) per year in licensing fees.

      The more devious method Oracle also uses is:

      1. Package licensed software components into specific products
      2. Change products, moving commonly used components into rarely licensed products
      3. Notify customers right before negotiating new license
      4. Profit!

    5. Re:It's "experimental" by Anonymous Coward · · Score: 0

      It's also tough as nails to get Oracle to pick up the damn phone. I tried 3 different contact numbers, left numerous messages, but never got called back. I work at a higher education institute that drops over $30 mil a year in contracts with Oracle and I can't get someone on the horn to get a damn invoice copy for the auto billing.

    6. Re:It's "experimental" by drerwk · · Score: 1

      http://www.sun.com/software/javaseforbusiness/faq.jsp#c2q1
      Internal/In-house use: The Java SE platform binaries (JDK and JRE) are licensed under Sun's Binary Code License (BCL) with supplemental terms. For most developers and end-users, the binary JDK and binary JRE are all that's needed to experience the world of Java technology. USE: The binary JDK and JRE are available at no fee from Sun (per terms of the BCL) for use with desktop personal computers. JDK or JRE use for embedded devices and other computing environments may require a license fee from Sun.

    7. Re:It's "experimental" by Anonymous Coward · · Score: 0

      To try G1, specify these command line options:

      -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC

      I don't see anything obvious preventing you from using it (no license/support keys?), it's just not recommended since it's experimental. If you're crazy enough to use it on a production server, you better have a support contract so Sun/Oracle can fix any problems that come along. That seems reasonable.

      Although it'd be better if they just said "don't use it for production, period."

      One wonders if the experimental nature/ support contract issue is Oracle's way of generating consulting revenue from customers. I am a cynic though.

  12. Oh you Smelly Software Socialists! by Dystopian+Rebel · · Score: 4, Funny

    I just know you're going to make a lengthy complaint thread of this.

    If you would simply put down your Silver Surfer comics, comb the crumbs and insects out of your beards, cut your straggly hair, have a bath and a good scrub, and eagerly learn all the new technologies as our Marketing department invents them (and disposes of the old technologies), we could see the dawn of a New Age of incredibly rich CEOs and VPs who live in mansions, collect cars, race boats and planes, and in general protect the freedoms that your betters fought so hard to establish.

    The meek shall inherit my EULA.

    --
    Rich And Stupid is not so bad as Working For Rich And Stupid.
    1. Re:Oh you Smelly Software Socialists! by Anonymous Coward · · Score: 1, Funny

      Cool, an object-oriented EULA!

  13. Pull your head out of your ass by Anonymous Coward · · Score: 5, Informative

    The G1 collector is still a "work in progress" so they are suggesting that you use it *in production* only if you have a support contract with Sun (Oracle?). This is not a big deal. You can still use it, just enable it with "-XX:+UnlockExperimentalVMOptions -XX:+UseG1GC" on the command line...

    1. Re:Pull your head out of your ass by Thomasje · · Score: 1

      The G1 collector is still a "work in progress" so they are suggesting that you use it *in production* only if you have a support contract with Sun (Oracle?).

      No. The release notes say:

      Although G1 is available for use in this release, note that production use of G1 is only permitted where a Java support contract has been purchased.

      So it's "not permitted" if you don't have a support contract. That's not the same as "suggesting" you not use it.

    2. Re:Pull your head out of your ass by Anonymous Coward · · Score: 0

      as per the release notes:

      "Although G1 is available for use in this release, note that production use of G1 is only permitted where a Java support contract has been purchased. G1 is supported thru Sun's Java Platform Standard Edition for Business program."

      The exact word was 'permitted' not 'suggested' as per the previous post. It IS a big deal.

    3. Re:Pull your head out of your ass by GravityStar · · Score: 1

      It's not a suggestion. It's a potential license violation. And the only way to know for sure you are not violating the license is
      a) audit all commandline parameters of java processes on production machines. (There could be many of those, hundreds, thousands?) or
      b) uninstall Sun JRE or
      c) pay for a support contract

      It's simply a audit nightmare waiting to happen. There will be companies purchasing those support contracts just in case. Others will perhaps look to get away from having the Sun JRE binaries available on machines to avoid any employee violating the license.

      This is just a attempted money grab from Oracle. Expect license conditions to get more confusing soon.

    4. Re:Pull your head out of your ass by teknopurge · · Score: 2

      The G1 collector is still a "work in progress" so they are suggesting that you use it *in production* only if you have a support contract with Sun (Oracle?). This is not a big deal. You can still use it, just enable it with "-XX:+UnlockExperimentalVMOptions -XX:+UseG1GC" on the command line...

      Your pragmatism and obvious correctness has no place on this site. Good day, Sir.

    5. Re:Pull your head out of your ass by Anonymous Coward · · Score: 0

      Um, no. Although you technically can enable the G1 collector without a support contract, it is a violation of the terms of use. The release notes clearly say "production use of G1 is only permitted where a Java support contract has been purchased." There is nothing in there that suggests you are allowed to use it without a support contract.

    6. Re:Pull your head out of your ass by Anonymous Coward · · Score: 0

      You can still use it, just enable it with "-XX:+UnlockExperimentalVMOptions -XX:+UseG1GC" on the command line...

      You forgot: -XX:+HotCoffee

    7. Re:Pull your head out of your ass by Anonymous Coward · · Score: 0

      Apparently this was a big misunderstanding. The Release Notes document linked in the original posting has now (as of June 04, 2009) been rephrased to read:
      "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."

  14. No malloc( )s by professorguy · · Score: 1

    Java doesn't have malloc( ). That's why it needs an integrated garbage collector. It keeps track of the references to objects that have been instantiated. When the counter reaches zero, the object is automagically removed from memory without explicit programming required. No malloc( ) or free( ) necessary.

    1. Re:No malloc( )s by Anonymous Coward · · Score: 1, Insightful

      WHOOOOSH

    2. Re:No malloc( )s by gbjbaanb · · Score: 3, Funny
      whooooosh.

      * <- joke

      o
      -|- <- you.
      / \

    3. Re:No malloc( )s by infamous_blah · · Score: 1

      It keeps track of the references to objects that have been instantiated. When the counter reaches zero, the object is automagically removed from memory without explicit programming required.

      Garbage collection in Java does NOT use reference counting. Although there are various GC implementations, they are all tracing collectors. When the collector runs, it traces objects reachable from the rootset. Anything not reachable is garbage and eligible for collection.

    4. Re:No malloc( )s by kailoran · · Score: 2, Informative

      Not only did you not get the joke, you also have some misconceptions about how the Java GC works. There is no counter, instead the program state is analysed for unreachable objects. Also, memory is not freed immediately, but some unspecified time later (i.e. during the next GC cycle)

    5. Re:No malloc( )s by Anonymous Coward · · Score: 1, Funny

      Welcome to the Slashdot Comment Games on CBC! Coming up: the 800 metres first post, Goatse hurdling, HURD herding and the 500 metres anti-Microsoft rant.

      But now we have coverage of the first joke misunderstanding event, where it seems Britain's professorguy has just made a new world record! He truly has captivated the audience here in LOLzistan Stadium, by completely misunderstanding a joke about Java garbage collection. He has received no less than five *WHOOOOOOSH* posts in response. Let's go to Pete Winkyfiddler who's down in the stadium floor, with professorguy.

      Thank you Shandra, looking forward to banging you in the stationary cupboard later, oh, did I say that out loud? Anyway, this has been an incredible performance by professorguy, receiving five *WHOOOOOOSH* posts; the closest anyone has come to this was Marcus Shuttlecock in 1983. Simply breathtaking. Let's watch the replay:

      WHOOOOSH
      WHOOOOOooo.....oooOOOOOOSH!
      whooooosh.

      * - joke

      o
      -|- - you.
      / \

      WHOOOOSH

      We're seeing several types of *WHOOOOOOSH* here, from the straight-forward, all capitals, right through a fade-in fade-out *WHOOOOOOSH* and even the fairly recent addition by atheletes in this event: the little stick-man illustration.

      professorguy: what an outstanding result, you must be very pleased with the outcome of your post. Can you walk us through, y'know, just how you managed to misunderstand the joke enough to get a new world record?

    6. Re:No malloc( )s by nog_lorp · · Score: 1

      +1 underrated

    7. Re:No malloc( )s by TimeTraveler1884 · · Score: 5, Funny

      Holy crap! That joke cut his head off!

    8. Re:No malloc( )s by jeremyp · · Score: 1

      Java does have malloc - or at least an equivalent to it. I'm petty sure that when I create a new object in Java, some memory is allocated to it.

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
    9. Re:No malloc( )s by Anonymous Coward · · Score: 0

      respecting the happend-before relationship

    10. Re:No malloc( )s by TheRaven64 · · Score: 1

      I can point to at least two JVMs from IBM's TJ Watson centre that use reference counting and cycle detection, not tracing. Last benchmarks I saw, they were faster than the tracing implementations too.

      --
      I am TheRaven on Soylent News
    11. Re:No malloc( )s by Anonymous Coward · · Score: 0

      When the counter reaches zero, the object is automagically removed from memory without explicit programming required.

      Java doesn't do reference counting.

  15. Prediction by system1111 · · Score: 2, Insightful

    Put a fork() in her she's done!

  16. Tony Soprano in charge by Alzheimers · · Score: 5, Funny

    Meet Vinny and Guido, my business associates in the waste management business.

    You see, it's like this. I gotta eat. My kids gotta eat. Vinny and Guido's families have to eat.

    We know where you live. It's a nice place, big houses, fancy cars. You can afford to eat, very well.

    You wouldn't your neighboorhood to fall victim to all sorts of garbage dumpers, would you? How about a recycling plant, right next to where you work?

    No? Well, I'm sure you'll understand when I say that it is in your best interest to respect our business model. Or else, Vinny and Guido might have to go hungry for a bit. And I assure you, they get very unfriendly when they get hungry.

    Capiche?

    1. Re:Tony Soprano in charge by frank_adrian314159 · · Score: 5, Funny

      That's a real nice production server you got here. It'd be a shame to see something unfortunate happen to it. I mean a server room's a dangerous place, ain' it? You got cables and electricity around and, well... accidents happen, if you know what I mean.

      Especially with garbage lyin' around all over your memory. Pipes could get clogged, tables could fill up, processes could meet an untimely demise... you know what I'm talking about.

      Now for a very reasonable fee, we can see that your garbage is collected regularly. It's a very small fee, once you think about what could happen if you didn't have folks like us around to help you. We'll see that this very nice production server continues to run in tip-top shape. Yes, our small garbage collection fee could help you avoid all sorts of unpleasantness...

      --
      That is all.
    2. Re:Tony Soprano in charge by Anonymous Coward · · Score: 0

      Capiche?

      Is this something like Captcha ?

  17. It's still experimental by MrEricSir · · Score: 5, Interesting

    Methinks they just want to make damn sure nobody uses this feature in a production environment. This is more of a sneak peek for paying customers who are contractually bound against using this in a production environment.

    If this was included in the standard distribution, then people would use it no matter what the documentation said. And then Sun would be saddled with bug reports and whining.

    --
    There's no -1 for "I don't get it."
    1. Re:It's still experimental by Nimey · · Score: 1

      +1 for properly spelling "sneak peek".

      --
      Hail Eris, full of mischief...

      E pluribus sanguinem
  18. Get 'r done takes money by dazedNconfuzed · · Score: 2, Insightful

    The ongoing problem with FOSS is that hard, un-cool, gritty, vital work ultimately takes money to do right. Cool gets projects only so far; money is needed for viable completion.

    --
    Can we get a "-1 Wrong" moderation option?
    1. Re:Get 'r done takes money by drinkypoo · · Score: 1

      That's still not a problem. Numerous companies have demonstrated a willingness to pony up for directed development when necessary.

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
    2. Re:Get 'r done takes money by raddan · · Score: 1

      Which is why I'd take Visual Studio over gcc, Microsoft DNS over BIND, and Exchange over Postfix any day.

      Not.

  19. Sun products are not as "free" as on might think.. by Anonymous Coward · · Score: 0

    ...if you for example take a look at the proprietary-only MySQL workbench or their OpenSolaris distribution which is hyped as a developer OS but requires you to buy a support contract if you want to get basic security updates e.g. for Firefox or OpenSSL.

  20. Oracle::Java == MS::VB6 by __aagujc9792 · · Score: 0

    This is your notice that Oracle will control the future Java trajectory for the benefit of Oracle. It's only going to get worse. There will be poison candy like this GC, strategic API and ABI changes, and just a world of hurt. I survived IBM, DEC, and MS hegemonies, and I've been paying attention. It's gonna happen.

    However, as a nakedly proprietary platform, it's possible the academic world will back off from its embrace of Java in favor of unowned platforms. One can hope.
    --
    olderphart

  21. Almost by professorguy · · Score: 1, Interesting

    You can still construct a program with a memory leak in Java.

    1. From your Main object, create an object A.
    2. Have object A create an object B. Have it pass itself as an argument to the ctor.
    3. Have object B keep the reference to object A.

    At this point you have 2 references to object A (one from the Main object and one from object B) and 1 reference to object B (from object A).

    Now just set object A to null to destroy the reference from Main to A. The reference counter to A drops from 2 to 1 (and object B still has 1). Both objects continue to exist in memory but they cannot be referenced by your program.

    Voila! Memory leak in Java.

    1. Re:Almost by Anonymous Coward · · Score: 0

      So essentially, you have two objects referencing each other, right? The GC will collect both since the main thread has no access to either one of them. Java garbage collector do not rely on reference counting anymore.

    2. Re:Almost by 3p1ph4ny · · Score: 3, Informative

      That works as long as the only strategy used is reference counting. There are others, and I think Java uses a fancy version of mark and sweep.

    3. Re:Almost by Anonymous Coward · · Score: 0

      Even the most basic garbage collectors deal with this already...sheesh

    4. Re:Almost by Anonymous Coward · · Score: 0

      I think in Java it is the same as in .net, where Garbage collector is not using reference counting to find unused objects but algorithm for finding strongly connected components and deletes unreachable ones.

    5. Re:Almost by TheRaven64 · · Score: 4, Informative

      To clarify, it only works if the strategy is pure reference counting. Mark-and-sweep and reference counting with cycle detection are both special cases of the same generalised algorithm (see the IBM TJ Watson papers for more info). Generally, ref counting + cycle detection plays nicer with virtual memory and non-uniform memory architectures than mark-and-sweep, although this is less true in an aggressively generational system like G1.

      --
      I am TheRaven on Soylent News
    6. Re:Almost by Erie+Ed · · Score: 1

      So that's the method Microsoft uses when they write a new operating system.

    7. Re:Almost by Yaztromo · · Score: 1

      You can still construct a program with a memory leak in Java.

      Not in the way you propose.

      Java currently uses a Concurrent Mark-and-Sweep garbage collector, whereby it can (conceptually) traverse the object tree from one or more root objects (in your example, Main), with any objects that are reachable being marked for preservation. In your example, both A and B would be left unmarked, as you can't get to them from Main any longer.

      Once the marking phase is completed, the set of unmarked objects is garbage collected. In your example, both A and B would be collected.

      This is a serious over-simplification of how the entire system works; for further information I'd suggest reading Memory Management in the Java HotSpot Virtual Machine.

      There are ways to leak memory in Java, but what you described isn't one of them.

      Yaz.

    8. Re:Almost by skeeto · · Score: 1

      Circular references won't leak with garbage collectors, as in Java, but they will with reference counting interpreters, such as perl.

    9. Re:Almost by dkleinsc · · Score: 1

      Or in the brilliant words recorded by ESR:

      One day a student came to Moon and said:
          "I understand how to make a better garbage collector. We must keep a reference count of the pointers to each cons."
          Moon patiently told the student the following story:
                "One day a student came to Moon and said: 'I understand how to make a better garbage collector...'

      --
      I am officially gone from /. Long live http://www.soylentnews.com/
    10. Re:Almost by pak9rabid · · Score: 1

      Hence why I said 'in theory' ;). I know from experience that in practice it's certainly possible to run into a situation where references to objects can accumulate while never going out of scope, thus creating a memory leak. Be that as it may, it's the result of a design flaw of the particular algorithm in question and not necessarily an issue with forgetting to explicitly deallocate dynamic memory (as is the cause of memory leaks in non-garbage collected languages such as C and C++).

  22. Use restrictions by Adrian+Lopez · · Score: 1

    This wouldn't bug me as much if the new garbage collector were only included as part of a paid-for distribution, but the fact that they're charging for the way it's used rather than for the right to obtain a copy of it makes me worry about additional restrictions on use being added in the future. I hope there's enough people making backups of all of Sun's open source software.

    --
    "In prison you just have to shut your eyes and take it. Here you have to shut your eyes and give it."
  23. Forgive my ignorance WAS:re: Garbage collector? by Brett+Buck · · Score: 2, Interesting

    I know I am profoundly ignorant and as thus should be modded into oblivion, but I don't do any programming where the memory allocation is variable. Is there a good reason are people really relying on hidden mechanisms to manage it? I would think it would be a lot more robust to keep track of allocation and deallocation explicitly, add when you need, and delete when you don't need, and not count on some generic mechanism. I know it happens, I see the memory leaks, but it would seem eminently avoidable.

            Brett

    1. Re:Forgive my ignorance WAS:re: Garbage collector? by publiclurker · · Score: 5, Informative

      While in theory, avoiding memory leaks is easy, in practice, it is rather difficult for anything but the most trivial programs. that's one of the reasons why garbage collection was created in the first place.

    2. Re:Forgive my ignorance WAS:re: Garbage collector? by rdavidson3 · · Score: 2, Informative

      Programming in C gives you more control over managing memory, but the price comes if the programmer is not careful about collecting the garbage up afterwards and you'll end up with the application taking more and more memory and your computer will eventually starting slowing down and could start complaining about not enough memory.

    3. Re:Forgive my ignorance WAS:re: Garbage collector? by Junta · · Score: 1

      It requires a great deal of programming discipline, which frankly humanity tends to lack. Absolutely, you can be more resource efficient if you are perfect about manual manipulation, but in practice developer time is sometimes best spent doing other things when the situation isn't one where resource usage efficiency is not a huge factor.

      --
      XML is like violence. If it doesn't solve the problem, use more.
    4. Re:Forgive my ignorance WAS:re: Garbage collector? by Ethanol-fueled · · Score: 1

      It's better because you can prototype and build stuff much, much quicker without (usually) having to custom-compile on every architecture. Java and C++ are a lot alike, and Java gave a nod to legacy C code with its own printf().

      To use a car analogy, stick-shift vs. automatic.

    5. Re:Forgive my ignorance WAS:re: Garbage collector? by geekboy642 · · Score: 4, Insightful

      It would not be more robust.
      The more things you have to pay attention to at the nuts-and-bolts level, the fewer things you are able to pay attention to at the business logic level. The key difference between managed languages like Java and non-managed languages like C, is that the uninteresting grunt work is done for you by the compiler. A vast majority of security flaws are related to programmers thinking exactly like you do. Even if the programmer is very highly skilled, memory management is tedious and difficult, and it is impossible to never make a mistake. Mistakes in memory management lead to segfaults or remote exploits.
      Non-managed languages should be used only when the performance benefits outweigh the dangers.

      --
      Just another "DOJ fascist authoritarian totalitarian bootlicker" -- Zeio
    6. Re:Forgive my ignorance WAS:re: Garbage collector? by hibiki_r · · Score: 5, Informative

      Even in modern C++, memory allocation and destruction is commonly done behind the scenes using reference counting pointers.

      Whenever you are dealing with anything that resembles a complex data structure, making sure that the programmer has to think very little about memory allocation is a huge boon. Programmer productivity across the alst 50 years hasn't changed much, if we look at statements written per month. The main difference is that 50 years ago, our statements did a lot less than they do now. A programmer that doesn't have to think of memory requirements can spend more time thinking about the actual business requirements, and improving the core algorithms.

      Leaving the memory management to a library is also a good way of minimizing the damage that a careless programmer can make. I remember the cost of a bad programmer in a team coding in C: It'd take longer to track his memory leaks, pointer overlaps buffer overruns than it would have taken the more reliable programmers to write the code from scratch. In languages like Java and C#, one has to really be working hard to be a true liability. There's just a lower barrier of entry. In a world that's not filled with uberprogrammers, but barely competent ones, this is a huge boon.

      And that's why few shops making business software would even dare to start a new project in a language without garbage collection: Unless you have quite a special team, a great QA process and are memory constrained, you'll be more productive in a language that is further away from the metal.

    7. Re:Forgive my ignorance WAS:re: Garbage collector? by Thomasje · · Score: 5, Insightful
      The reason why Java has garbage collection has nothing to do with programmer convenience; it is needed in order to make Java's security model work. Without garbage collection, a thread could allocate a chunk of memory and then free it, while hanging on to the pointer -- and then periodically take a look at what shows up in the memory area where the previously freed block used to be. Any Java process running in the same VM would be at risk. This kind of deliberate use of "dangling pointers" is easy to prevent if using garbage collectors, very difficult to prevent otherwise.

      Protecting processes running in the same VM from each other may not seem terribly useful now, but Java was originally designed to be used in embedded controllers, where the JVM would *be* the operating system, and where processes had to be protected from each other without the help of a hardware memory management unit.

      FWIW, I also beg to differ about the difficulty of manual memory management. In C++ it is usually very easy, as long as you're consistent about doing deallocations in destructors. I once had to write a 40,000+ line C++ program, with lots of dynamic memory management going on; once development was complete, I ran a complete test suite under Purify, and found 5, yes, five, memory leaks. Considering that most leaks are the result of mis-handled object ownership, which is an issue that garbage collection does not eliminate in general, you should be careful about your design, *and* use memory analyzers like OptimizeIt, even when developing in a GC environment.

    8. Re:Forgive my ignorance WAS:re: Garbage collector? by Brett+Buck · · Score: 1

      Thanks, I'm just a dumb scientific simulation and real-time/embedded processor guy.

              But just thinking about how it might be done as a general case, it looks like it would be very prone to circular logic or unintentional recursion. Clearly you have to have a list of the memory in use somewhere, but then you have to clean up that list, too, and it's not clear where it would end. I can think of explicit structures that partition it so when you leave a process it kills everything, but not an obvious general way.

              Brett

    9. Re:Forgive my ignorance WAS:re: Garbage collector? by vux984 · · Score: 4, Insightful

      would think it would be a lot more robust to keep track of allocation and deallocation explicitly, add when you need, and delete when you don't need, and not count on some generic mechanism.

      Ok... so I allocate object A. Then I allocate object B, C, and D that all reference A but aren't aware of eachother. Then I release D, and don't know whether to release A, so now A needs to have some sort of reference counting mechanism, and I have to remember to use it each time I create or copy or pass a reference to A.

      Or... I can use a language that implements the reference counting stuff for me and implicitly calls it when I allocate new objects, create, copy, or pass references, and expire them as they go out of scope, without me having to write explicit destructors.

      Basically, if you do any sort of remotely complicated object allocation where you are going to need to implement reference counting to keep track of them, you might as well use a garbage collector. That's what it does, it comes thoroughly debugged, and you don't have to waste time implementing and debugging your own.

      So, a garbage collector language is MORE robust (assuming robust means 'more reliable').

      That's not to say unmanaged code doesn't have its place, but in my experience managed code tends to get developed faster and cheaper than equivalent unmanaged code, so it only makes sense to use unmanaged code where you really need the performance or nuts&bolts control. Your typical productivity or business logic application don't. Drivers, real-time systems, etc do.

      As always, use the best tool for the job. C is not always the best tool.

    10. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      While in theory, avoiding memory leaks is easy, in practice, it is rather difficult for anything but the most trivial programs. that's one of the reasons why garbage collection was created in the first place.

      I've been programming in non-garbage-collected languages for 20+ years, written decidedly non-trivial programs, and I've never once had a memory leak. It's just a matter of programming style. Some people use programming styles that require heroic attention to detail to avoid memory leaks: cleary that won't work. There are other styles, however.

      C++ made it quite easy to avoid memory leaks (it's always a bit risky in C, though not ridiculously hard) with the right style. It's actually easier IMO to avoid file handle leaks, resource lock "leaks", and leaks of everything except memory in C++ than in languages like Java and C#.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    11. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 1, Insightful

      The price is also that it is far less agile. Want to make a change? Make sure someone goes over it with a fine toothed comb. While that might sound appealing to the "experts" a lot of people just want to get the job done and move on to more exciting tasks.

    12. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      Is there no way to copy the bitwise contents of a pointer into an int in Java, then later copy it back? I find it unrealistic to think that you could prevent deliberate "dangling pointers". That kind of security is what hardware-level memory management is about.

      Also, if you do deallocations (or close file handles, or free locks or other resources) in destructors of man classes, you eventually screw up, and get a memeory leak every few thousand lines of code. That's not terrible, but there are better ways.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    13. Re:Forgive my ignorance WAS:re: Garbage collector? by BikeHelmet · · Score: 1

      From speaking with genius software engineers, I've concluded that maybe 4-5% of C programmers should actually be coding in C. The rest should be coding in a language like Java or C#, which holds their hands.

      If ~95% of C programmers moved to these languages, we'd get less buggy faster running software. (because few of us know how to optimize C properly, or bother to do it, so more often then not a JVM or JIT compiler does it better)

    14. Re:Forgive my ignorance WAS:re: Garbage collector? by Red+Flayer · · Score: 5, Funny

      I ran a complete test suite under Purify, and found 5, yes, five, memory leaks

      Five memory leaks!
      Ah-ah-ah.

      One... two... three... four... five memory leaks!

      Ah-ah-ah.

      Sorry. I have a toddler at home. I couldn't help counting out loud in a silly voice when you mentioned the number 'five' twice.
      br.Now my coworkers are eyeing me even more strangely than usual.

      --
      "Trolls they were, but filled with the evil will of their master: a fell race..." -- J.R.R. Tolkien on Olog-hai
    15. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      In C++ you can avoid memory leaks without a "great deal of programming discipline". You merely need the correct programming style (and pert of a good syle is the ability to catch junior programmer's mistakes with simple textual searches run every so often). Or to put it the other way round: if your programming style requires a great deal of discipline to avoid leaks, you're doing it wrong.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    16. Re:Forgive my ignorance WAS:re: Garbage collector? by samweber · · Score: 1

      A lot of other people have replied to the parent post, saying quite correctly that avoiding memory leaks is hard in practice. However, there are also other reasons as well:

      • If you do allocation manually, you also have to worry about freeing something twice. The result of that is usually rather nasty, including creating ways for attackers to break into the system.
      • Garbage collection is usually faster than manual allocation -- see Urban Performance Legends, Revisited
      • Garbage collection allows objects to be compacted in memory, which increases locality and hence performance greatly.
    17. Re:Forgive my ignorance WAS:re: Garbage collector? by mario_grgic · · Score: 3, Insightful

      Nice, now try couple of million lines of code, maintained by 50 or so developers of various levels of experience and see how many memory leaks there are then.

      --
      As the island of our knowledge grows, so does the shore of our ignorance.
    18. Re:Forgive my ignorance WAS:re: Garbage collector? by Thomasje · · Score: 2, Informative

      Is there no way to copy the bitwise contents of a pointer into an int in Java, then later copy it back?

      No.

      I find it unrealistic to think that you could prevent deliberate "dangling pointers". That kind of security is what hardware-level memory management is about.

      ...and the Java security just does what it takes to provide that kind of security on devices where hardware memory management is not available.

      Also, if you do deallocations (or close file handles, or free locks or other resources) in destructors of man classes, you eventually screw up, and get a memeory leak every few thousand lines of code.

      True, but Java is not immune from that kind of problem, either. A common case is adding an object to a map, and forgetting to remove it when it's no longer needed. Ta-dah, memory leak... Which is why using a memory analyzer is a good idea *even* in GC environments.

    19. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1, Troll

      The more things you have to pay attention to at the nuts-and-bolts level, the fewer things you are able to pay attention to at the business logic level. The key difference between managed languages like Java and non-managed languages like C, is that the uninteresting grunt work is done for you by the compiler

      Unless, of course, you're solving a technical, rather than business, problem. At that point the product that you're selling is doing the "uninteresting grunt work" for someone else. For example, writing a compiler. To a geek, that's far mor fun than implementing a payroll database for the one billionth time.

      Even if the programmer is very highly skilled, memory management is tedious and difficult, and it is impossible to never make a mistake.

      This is simply false. I've never made such a mistake, not in 20 years of coding. When I'm the technical lead or architect for a project, there are no memory leaks in the project (or at leats none where I have authority). It's a matter of programming style (and using C++, not C). I have, however, had to fix others' memory leaks in garbage-collected languages. You have to try pretty hard to leak memory in C#, but it's not perfect.

      Non-managed languages should be used only when the performance benefits outweigh the dangers.

      Naturally, every tool should be chosen such that the benifits outweigh the dangers. But it's not just performance: garbage collect languages only manage memory for you, not file handles, locks, or other resources. A generation of programmers with no resource allocation discipline *at all* has led to some pretty bad leaks of resoruces other than memory.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    20. Re:Forgive my ignorance WAS:re: Garbage collector? by Captain+Spam · · Score: 1

      You generally don't have a direct list of memory in use; you usually have a list of variables in use (which in turn is a list of memory in use, indirectly) and how many references to each variable still exist "in the wild" (recursed; if something isn't accessible to the rest of the program, any references it holds are considered to be dead). THAT list is handled by the VM, and at that point, yes, programmers in that area just trust that the VM knows what it's doing in terms of GC.

      Of course, that's just for a simplistic, maybe somewhat primitive GC. There's probably all sorts of whatchamahoozit algorithms and whatever else out there nowadays. I don't develop GCs, I just have a peripheral knowledge of how they work.

      From a real-time/embedded standpoint, no, you wouldn't find it very useful at all. In fact, you'd find it horribly counter-productive, as you lose control of how memory is allocated in an environment where memory can be at a premium and the clock cycles needed for automatic garbage collection need to be rock-solid. But for general day-to-day programming on machines with cheap RAM and non-real-time kernels and processes, it removes a major source of unnecessary headaches from many programmers' heads.

      --
      Demanding constant attention will only lead to attention.
    21. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      Two solutions to this scenario:
      1. Don't spread references around everywhere. Use a copy constructor, memcpy where possible, etc. Garbage-collected languages like to obscure the difference between references and deep copies (I guess pointer logic is too hard for people that start their CS education with Java). I'm assuming that you're using C or C++, which give you either option.
      2. Let your worker functions share the reference, but only clean A up in the block/function/object that created it in the first place. Sure, it will add some overhead, but it won't be as much as Garbage Collection.

    22. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      In C++, there are better ways to prevent memory leaks than carefully freeing everything in your destructors (which doesn't work anyhow if your constructor throws an an awkward moment).

      I don't use Java, but I hear you can marshal Java data for use by C libraries and vice versa. I'd expect a hole there where you could get the contents of a pointer. Clearly Java debuggers can get the contents of pointers - I bet there's a hole there as well. Of course, both thouse approaches attack the border between Java and other worlds, but such borders exist.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    23. Re:Forgive my ignorance WAS:re: Garbage collector? by shutdown+-p+now · · Score: 1

      Is there no way to copy the bitwise contents of a pointer into an int in Java, then later copy it back?

      There isn't. Note that this is on JVM bytecode level as well as Java language level. It simply doesn't have any instructions that allow you to treat an opaque object reference as a raw pointer.

      I find it unrealistic to think that you could prevent deliberate "dangling pointers".

      Which is strange, because languages that do so have been around for ages, and certainly much earlier than Java (e.g. Smalltalk is one). Strictly speaking, one doesn't need a GC for that - for example, one alternative is to provide explicit memory release, but null out all references to object as it is deleted (IIRC UnrealScript does it that way). Of course, you still need to track references that way, so you might as well just do a GC - so most do that.

      Also, if you do deallocations (or close file handles, or free locks or other resources) in destructors of man classes, you eventually screw up

      Why?

      Of course, idiomatic C++ is not to close file handles in destructor of every class that needs one, but to write a class encapsulating a file handle (which does close it in its destructor), and then use it in all other classes that need to own a file handle.

    24. Re:Forgive my ignorance WAS:re: Garbage collector? by AmaDaden · · Score: 1

      Clearly you have to have a list of the memory in use somewhere, but then you have to clean up that list, too

      Stick a layer on top of that with a thread that would wake up every 5 minutes to check if any of those chucks of memory are still in use and you would have a simple garbage collector.

      This is why more modern languages have it built in garbage collectors instead of forcing the programmer to do it. Every program needs a way to do it and it's a complex mess in large programs so it makes more sense for the language to handle it behind the scenes in one frame work written by a small group of experts then to force every programmer who would like to write an app to worry about it. Yes, in theory a skilled programmer can do a better job at it but more often then not the reality of human error blows that advantage out of the water both by missing collecting something and by not collecting things as soon as they could.

      I see it in the same way it's worth our time to use compilers to write assembly code. Yes people can do it better but some really skilled people can make a computer do it well enough.

    25. Re:Forgive my ignorance WAS:re: Garbage collector? by eyrieowl · · Score: 1

      No, there's not. You can't reference a "pointer" in a bitwise fashion. Java doesn't have anything which is explicitly a pointer, for starters.

    26. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 2, Interesting

      I find it unrealistic to think that you could prevent deliberate "dangling pointers".

      Which is strange, because languages that do so have been around for ages, and certainly much earlier than Java (e.g. Smalltalk is one).

      Most such languages have an "out" somewhere, so that you can use the language to call C system APIs, or use device-mapped hardware, because that's all that commercial software *did* in the olden days.

      Also, if you do deallocations (or close file handles, or free locks or other resources) in destructors of man classes, you eventually screw up

      Why?

      Of course, idiomatic C++ is not to close file handles in destructor of every class that needs one, but to write a class encapsulating a file handle (which does close it in its destructor), and then use it in all other classes that need to own a file handle.

      Yes, that was my point. Don't free resources in the destructor of every class that uses resoruces. There should be only one destructor that frees memory, only one that closes a file handle, etc. And those all fit a similar pattern and can themselves derive from a common base class/template to further reduce the possibility of error.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    27. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      I'm guessing that you can use Java in *some* way to call C system APIs, and to interact with device-mapped hardware. Most other high level languages have some dark corner where you can peek under the hood, to accommodate such needs.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    28. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      I ran a complete test suite under Purify, and found 5, yes, five, memory leaks

      Awesome. Now what about the ones Purify didn't find? Obviously your "complete test suite" couldn't have fully exercised the application, if it is as complex as you say it is.

    29. Re:Forgive my ignorance WAS:re: Garbage collector? by FiskeBoller · · Score: 3, Interesting

      If you're a sole programmer writing everything yourself, I'd be inclined to agree with you. Most work I see, however, involves significantly larger chunks than 40,000 LOC and coordination with other teams or contributors. C/C++ has no inherent unified memory management scheme, and so the patterns and responsibilities for memory management can vary widely between teams, libraries, or chunks of code. That is something that often gets overlooked when discussing Java memory management. Java GC has literally has made the coordination and use of library code very simple.

    30. Re:Forgive my ignorance WAS:re: Garbage collector? by Thomasje · · Score: 1

      I hear you can marshal Java data for use by C libraries and vice versa. I'd expect a hole there where you could get the contents of a pointer.

      There's no hole; when marshalling a compound object, the actual bits of the pointers aren't marshalled, the objects they point to are. Marshalling the bits of a pointer would be pointless (no pun intended) because they wouldn't mean anything to the receiver.

      Clearly Java debuggers can get the contents of pointers

      They can't, and they don't need to; all a debugger needs to be able to do is dereference pointers.

    31. Re:Forgive my ignorance WAS:re: Garbage collector? by Thomasje · · Score: 1

      That would be JNI, the Java Native Interface. Depending on the security manager used by a JVM, this hole can be plugged, if that level of paranoia is deemed necessary. Typically, a stand-alone JVM will permit calling native code, but a JVM that is set up to dynamically load code from potentially untrusted sources (like a Java application server, or an embedded JVM in a web browser) will not.

    32. Re:Forgive my ignorance WAS:re: Garbage collector? by shutdown+-p+now · · Score: 2, Informative

      Most such languages have an "out" somewhere, so that you can use the language to call C system APIs, or use device-mapped hardware, because that's all that commercial software *did* in the olden days.

      In case of Java it's native methods / JNI. However, it's still not on JVM level - Java can only declare some method as native, it's the JNI spec that defines how such a method could be implemented in C. However, a JVM can refuse to execute native methods, and does so when running sandboxed (e.g. as an applet). But it still needs to manage memory for all the sandboxed code in a guaranteed-safe way, hence the need for GC.

      On the other hand, .NET has the full bunch right in the VM - raw data & function pointers with arithmetic, explicit arbitrary-layout structs (which include unions as a subset), etc. But it also divides all opcodes into "verifiable" (meaning no statically-uncheckable pointer trickery) and "unverifiable", and does not execute methods containing unverifiable code when sandboxed. So it also needs GC for verifiable code.

    33. Re:Forgive my ignorance WAS:re: Garbage collector? by Pollardito · · Score: 1

      Explicit memory allocation/deallocation relies on the programmer to know the last places in the program where the allocated memory is ever used, so that they can be sure to free the memory at or after those points. In large object oriented systems where you're not supposed to need to know how this object that you've got does its business, having to know that it has allocated itself some memory breaks the wall.

      more detail if you care

    34. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      So in a Java debugger, there's no raw memory display? No way to see the bytes that make up your object? To each his own, I guess.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    35. Re:Forgive my ignorance WAS:re: Garbage collector? by teknopurge · · Score: 1

      True, but Java is not immune from that kind of problem, either. A common case is adding an object to a map, and forgetting to remove it when it's no longer needed. Ta-dah, memory leak..

      As long as there are no references to the object the GC will reclaim the memory in that map. (see java.lang.ref.Reference and all the subclasses)

    36. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      That makes sense. If it's not in the core language, you can easily exclude it of you're feeling paranoid.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    37. Re:Forgive my ignorance WAS:re: Garbage collector? by idontgno · · Score: 5, Funny

      In C++, there are better ways to prevent memory leaks than carefully freeing everything in your destructors (which doesn't work anyhow if your constructor throws an an awkward moment).

      You accidentally a few words. You might say you accidentally a grammar exception at an awkward moment.

      --
      Welcome to the Panopticon. Used to be a prison, now it's your home.
    38. Re:Forgive my ignorance WAS:re: Garbage collector? by gangien · · Score: 1

      No, there isn't.

    39. Re:Forgive my ignorance WAS:re: Garbage collector? by deKernel · · Score: 1

      In C++, there are better ways to prevent memory leaks than carefully freeing everything in your destructors (which doesn't work anyhow if your constructor throws an an awkward moment).

      For this situation I would suggest that you don't do any allocation in your constructors. Use your constructors to properly initialize any primitive data members you have, and create a public method (I personally call it Init()) that does any allocation or large scale initialization. Now this is not the most ideal solution, but it also allows you to perform "lazy initialization" if you desire some time down the road.

    40. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      Try training your developers so they know how to design and implement code properly. People who have memory leaks in C++ are going to have memory leaks in Java, it's just that people will tend to pay less attention to them. Trust me, I cut my teeth mostly on Java and then worked in it professionally for several years; the amount of slop you allow because of garbage collecting is terrible -- it wasn't just me, it was everyone at work letting the idea of object ownership go on the slide except for those few objects that handled huge blocks of memory. Now that I've been working in the C family for a couple of years, my shit's tightened up and I write code that not only has no leaks but also has design aspects - such as ownership and scope - much more clearly defined for all the data.

    41. Re:Forgive my ignorance WAS:re: Garbage collector? by AnyoneEB · · Score: 1

      Correct. Have you really never used a [memory] safe programming language? The only Java debugger I have used is the one in Eclipse which displays objects in a tree with the contents listed by field name (and uses their .toString() methods to get a String summary to display, but for many objects that is useless). Java does not really deal with memory layouts of its objects.

      --
      Centralization breaks the internet.
    42. Re:Forgive my ignorance WAS:re: Garbage collector? by Thomasje · · Score: 2, Interesting

      True, but Java is not immune from that kind of problem, either. A common case is adding an object to a map, and forgetting to remove it when it's no longer needed. Ta-dah, memory leak..

      As long as there are no references to the object the GC will reclaim the memory in that map. (see java.lang.ref.Reference and all the subclasses)

      The problem I was thinking about occurs when the map in question has a much longer lifetime than the objects it contains. For example, a multi-window application may implement a Windows menu by maintaining a map, that maps window names to window instances; the map's key set would be used to build the window menu, and the map itself would live for the application's entire lifetime. Now, unless you remove windows from the map when you dispose them, you'll have a memory leak.

      It's usually not hard to get this kind of thing right, but you do have to write code to make it work correctly; the GC will not prevent this kind of leak. Using a WeakHashMap can often help, but still, you'd have to remember where to use WeakHashMaps and where to use the regular kind, which requires thinking about object ownership... and my original point, a couple of posts back, was that once you have a clear picture of how object ownership should be managed in your app, you won't find it very difficult to use explicit memory management correctly, either. That said, GC does undeniably require you to write *less* code, so I wouldn't argue that GC is a Bad Thing -- just something you should not blindly trust to prevent all memory leaks.

    43. Re:Forgive my ignorance WAS:re: Garbage collector? by Darinbob · · Score: 1

      While in theory, avoiding memory leaks is easy, in practice, it is rather difficult for anything but the most trivial programs. that's one of the reasons why garbage collection was created in the first place.
      One of the small reasons. It was basically invented to deal with the problem of memory in Lisp, which did not have manual memory allocation but which had a ton of implicitly created ephemeral data. These weren't "leaks", but an implicit part of the design of the language. This also gave early Lisps (which were inevitably interpreted) a bad reputation for being slow because the garbage collectors often weren't very good. Modern garbage collectors build on decades of research from Lisp and Smalltalk systems.

      This is vastly different from a traditional procedure language like Java where memory and objects are explicitly allocated. Once you have allocation, you have to worry about deallocation. So they borrowed the garbage collection idea from functional languages.

      You also get more advantages than just removing explicit object deallocation. Garbage collectors help to compact memory as well, improving performance. It also leads to different styles of programming, such as not worrying about ephemeral data. Ie, in Lisp or Smalltalk it is common to copy an entire list (changing parts of it along the way) and thus avoid the problem of deciding who "owns" the list, whereas in C/C++ that technique can lead to lots of wasted memory and memory fragmentation and so there is often a big infrastructure to deal with object ownership and copying issues.

    44. Re:Forgive my ignorance WAS:re: Garbage collector? by HappySmileMan · · Score: 1

      I've been programming in non-garbage-collected languages for 20+ years, written decidedly non-trivial programs, and I've never once had a memory leak.

      I lol'd

    45. Re:Forgive my ignorance WAS:re: Garbage collector? by HappySmileMan · · Score: 1

      This is simply false. I've never made such a mistake, not in 20 years of coding. When I'm the technical lead or architect for a project, there are no memory leaks in the project

      I lol'd, hard.

    46. Re:Forgive my ignorance WAS:re: Garbage collector? by Thomasje · · Score: 1
      The problems with large projects with many developers, affect GC environments as well. I once had a lot of fun (not!) trying to debug memory leaks in a Java application, that turned out to be caused by Java libraries that did not release references correctly in some cases -- references to application objects, created outside the library. So, I ended up debugging the libraries rather than debugging *my* code.

      Any large project is prone to this kind of thing, and your only defenses are documenting ownership in all APIs (even internal ones), testing using memory analyzers, and, perhaps most importantly, regular and thorough code reviews. Unfortunately, in most places where I've worked, code reviews are either sloppy affairs where the senior devs who could potentially contribute just make some obvious criticisms about indentation and naming conventions, or else they simply don't happen at all... which makes it hard for the junior devs to learn how to do their job better.

    47. Re:Forgive my ignorance WAS:re: Garbage collector? by Algan · · Score: 1

      This is simply false. I've never made such a mistake, not in 20 years of coding. When I'm the technical lead or architect for a project, there are no memory leaks in the project (or at leats none where I have authority).

      Yeah, right, and also your poop doesn't smell and comes out in pretty pastel colors.

      --
      If con is the opposite of pro, is Congress the opposite of progress?
    48. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      I've been programming in non-garbage-collected languages for 20+ years, written decidedly non-trivial programs, and I've never once had a memory leak.

      You're either a lying sack of shit or an oblivious moron.

      Were I interviewing you, that statement would effectively end the interview immediately. The most DANGEROUS coders are the ones who think they don't make mistakes. Because they're nowhere near as good as they think they are.

    49. Re:Forgive my ignorance WAS:re: Garbage collector? by ADRA · · Score: 1

      All of what you said is possible and much more once you have native code interface access... but, one cannot run native code (that hasn't been signed by for the JVM itself) unless the security context has been set to allow basically all operations. Since the native hook (JNI) allows for any use of C libraries within the processes code space, an application with native hooks looses all sand-box restrictions. Of course thats why a java applet on the internet requires a popup in order to elevate sandbox privileges to that level.

      --
      Bye!
    50. Re:Forgive my ignorance WAS:re: Garbage collector? by ADRA · · Score: 1

      In practice, you (a standard developer) never need to see the raw memory byte level contents of an object. That said, debuggers and profilers can and do get raw access to objects, but they use the many debugging/profiling hooks (JVMTI, JVMDI, etc..) into the JVM to do so, not by using a standard top level core API.

      --
      Bye!
    51. Re:Forgive my ignorance WAS:re: Garbage collector? by Estanislao+Mart�nez · · Score: 1

      Garbage collection is usually faster than manual allocation -- see Urban Performance Legends, Revisited

      Not so fast. It is certainly true that a stop-and-copy algorithm has lower algorithmic time complexity than manual memory management--but it uses more memory, in more than one sense: (a) copying from the old heap to the new heap requires that a new heap be allocated; (b) doing a collection requires touching a lot of memory pages which would otherwise not be touched often, which increases the size of the program's memory working set, limiting the virtual memory manager's ability to manage system memory.

      Garbage collection allows objects to be compacted in memory, which increases locality and hence performance greatly.

      This is extremely tricky, because again, collection touches memory pages that the program wouldn't touch otherwise, which can offset the benefit from compacting.

    52. Re:Forgive my ignorance WAS:re: Garbage collector? by omglolbah · · Score: 1

      The type of programming I do is focused on solving a task. I would rather not spend a huge amount of time doing housekeeping if I can have a GC doing it for me.
      A well written library is a whole lot more useful than a myriad of custom solutions that may or may not be re-usable in the next project.

      There are of course pros and cons to all solutions, but I personally like having the memory allocation being done behind the scenes :)

    53. Re:Forgive my ignorance WAS:re: Garbage collector? by dstar · · Score: 1

      Even if the programmer is very highly skilled, memory management is tedious and difficult, and it is impossible to never make a mistake.

      This is simply false. I've never made such a mistake, not in 20 years of coding. When I'm the technical lead or architect for a project, there are no memory leaks in the project (or at leats none where I have authority). It's a matter of programming style (and using C++, not C). I have, however, had to fix others' memory leaks in garbage-collected languages. You have to try pretty hard to leak memory in C#, but it's not perfect.

      That statement right there ensures that I would _never_ recommend you for any position that I had any say in. Either you're lying through your teeth, or you're so incompetent you never noticed your mistakes.

      Pick whichever one you think makes you look better -- from where I stand, they're _both_ pretty damning.

    54. Re:Forgive my ignorance WAS:re: Garbage collector? by gbjbaanb · · Score: 1

      Its true, java (and .NET) has more memory leaks than the old C++ code with RAII.

      Really, the problem is that too many people have been told that they don;t have to worry about memory management (actually they mean object lifetime management) so they don't - they think the GC will magically handle everythign for them, and as a result, end up with held references all over the shop.

      The classic morality tale about this is the Princeton DARPA challenge team, who pored over their C device driver code, line by line to find their memory leak, ignoring the C# code because that "couldn't possibly have a memory leak".

      In .NET its very often caused by GUI development, C# has a nice sugary syntax to associate objects to event handlers, deleting the object later does not free it (as the event handler still contains the reference you never explicitly added), sometimes you can delete the GUI control too, and it still won't go (as it is referenced by a dialog or other controls).

      In short, there's no magic bullets, every programmer should be made to do things properly, and 'easy to use' languages just mean you get the less skilled developers using them.

    55. Re:Forgive my ignorance WAS:re: Garbage collector? by geekboy642 · · Score: 1

      I've never made such a mistake, not in 20 years of coding.

      Please, what company do you work for? I want to short your clients.

      --
      Just another "DOJ fascist authoritarian totalitarian bootlicker" -- Zeio
    56. Re:Forgive my ignorance WAS:re: Garbage collector? by gbjbaanb · · Score: 1

      no, if 95% of C programmers moved to managed languages, we'd just get a lot more bugger, slower running software. Such languages are easier to use, so a developer can churn out more, but a poor programmer will always find ways to do things wrong.

    57. Re:Forgive my ignorance WAS:re: Garbage collector? by ADRA · · Score: 1

      Two points:

      1. Peer association break simple reference counting. If you're doing non-trivial OO coding, you'll almost certainly have cyclic associations throughout
      2. Unless I'm missing something, the counter itself needs concurrency locking which may eventually become a big deal if you're dealing with a large thread count applications of this object.

      Looking at the wikipedia article on GC's it mentions a blurb on ref counters that seems to echo some of this sentiment.
      http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Reference_counting
      http://en.wikipedia.org/wiki/Reference_counting

      --
      Bye!
    58. Re:Forgive my ignorance WAS:re: Garbage collector? by LizardKing · · Score: 1

      I've been programming in non-garbage-collected languages for 20+ years, written decidedly non-trivial programs, and I've never once had a memory leak.

      Sorry, you sound like one of those kids at school who were always coming out with the most preposterous bull.

    59. Re:Forgive my ignorance WAS:re: Garbage collector? by petermgreen · · Score: 1

      I don't use Java, but I hear you can marshal Java data for use by C libraries and vice versa.
      If the security manager lets you then you can. If you are introducing untrusted code to your VM then you set up the security manager not to allow the untrusted code to do that (as for example the java plugin does for untrusted applets).

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
    60. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      40,000 lines isn't large. Try 1 million lines, written by a team rather than a single developer (because no single developer can reasonably handle it).

    61. Re:Forgive my ignorance WAS:re: Garbage collector? by mario_grgic · · Score: 1

      Well, automatic garbage collection means exactly that. It does not mean automatic resource collection nor does it mean that object ownership is automatic.

      Of course Java and C# has memory or resource (more common) leaks. It's always the responsibility of the programmer to know what they are doing :D.

      --
      As the island of our knowledge grows, so does the shore of our ignorance.
    62. Re:Forgive my ignorance WAS:re: Garbage collector? by publiclurker · · Score: 1

      You know, I'm pretty sure I've had to fix some of your code.

    63. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      However, I can back it up. This is why I'm well paid, and recently I seem to find work helping companies get their act together on stuff like this. Of course, I'm saying this on the internet, with all the credibility that implies. :)

      --
      Socialism: a lie told by totalitarians and believed by fools.
    64. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      But the problem here is that GC works well only in an application environment. Embedded environments and device drivers are another world.
      I do hate it when people insist that GC is the panacea of all programming. And I disagree totally that it is impossible to deal with memory leaks in languages like C. You know there are other ways to manage memory than malloc() and free().

      Crack open any non-trivial C program and I suspect you'll find some form of memory management scheme. Apache has pools; Mozilla has automatic ref-counting (and GC in limited arenas of objects); embedded stuff usually has fixed-size objects that get moved around from list to list -- often for *both* efficiency and correctness.

      GC is nice for a certain class of problems. It deals poorly with very large data sets, caches, virtual memory, or untyped languages (where you can't tell a pointer from a scalar). But for your typical "coupon processor" software it's a wonderful invention. That doesn't mean it automatically makes things better under all circumstances.

      Hmf. I remember working on one embedded system where the task took a bounded amount of time. The solution was simple -- the watchdog simply reset the processor every cycle -- only a small amount of global state was kept. The CPU just kept running until the end of the task at which point it hit a jam loop. Sometimes high reliability just has to win over the convenience of some software guys.

    65. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      I actually would find that quite difficult. I often look at the generater assembly and the raw memory of data structures to see just what the compiler really did with my source.

      And, of course, programs crash, and sometimes all you have is the memory dump. It's good to be able to analyse those even if the soruce you have doesn't quite match exactly with the customer environment.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    66. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      Lazy initialization is often is useful tool, but you shouldn't be dependent on it as the only way to code. Having a library of "rich primitives" that clean up after themselves means you can do everything through data members, which *do* get properly cleaned up when the contstructor throws (or when ordinary code throws and those "primitives" are on the stack, etc).

      C++'s biggest current problem is that these "primitives" aren't part of the language or the standard library. At least C++0x will give us shared_ptr as a standard.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    67. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      I find this comment completely unbelievable. If a programmer cannot make sure he handles memory correctly then he really has no business being a programmer.

      This comment is really just proof of my opinion that universities are churning out shit developers.

    68. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 0, Offtopic

      And yet, it's true. In the kind of programming I do, memory leaks and the like are the bane of some shops existance, and you'll absolutely hear about it if you make a mistake. You run multiple and various leak detectors one code that's runs in an appliance, for example, because that's usually what limits your uptime. It is actually possible to be good at this, you know, if that's the focus of your career.

      Have you ever seen a real hacker? I mean, a man who makes furniture with an axe? I did once - he made a table. Each leg was four whacks with an extremely sharp hatchet. The result was beautiful, and smoother than you can get with sandpaper. But the amazing thing? He still had all his fingers. Such things are possible, if you're really serious about safety and leaks. ;)

      --
      Socialism: a lie told by totalitarians and believed by fools.
    69. Re:Forgive my ignorance WAS:re: Garbage collector? by ink · · Score: 1

      The reason why Java has garbage collection has nothing to do with programmer convenience; it is needed in order to make Java's security model work. Without garbage collection, a thread could allocate a chunk of memory and then free it, while hanging on to the pointer -- and then periodically take a look at what shows up in the memory area where the previously freed block used to be.

      Ridiculous. The only way to allocate dynamic memory from the Java language is by creating objects; there is no way to "hang on to a pointer" because there are no pointers. If you're talking about the JVM itself, then that all depends on the implementation of the VM -- but even still, there is no idea of a pointer unless you're in JNI, in which case you're bypasing the security model anyway...

      Any Java process running in the same VM would be at risk. This kind of deliberate use of "dangling pointers" is easy to prevent if using garbage collectors, very difficult to prevent otherwise.

      How is thread 2 going to get a reference to an object that is "no longer being used" by thread 1? Again, there are no pointers.. and this has nothing to do with garbage collection.

      Protecting processes running in the same VM from each other may not seem terribly useful now, but Java was originally designed to be used in embedded controllers, where the JVM would *be* the operating system, and where processes had to be protected from each other without the help of a hardware memory management unit.

      Oh wow. +5 insightful for THAT? There are no processes in the JVM. A JVM can create new processes, but it those processes do not run in the same VM.

      FWIW, I also beg to differ about the difficulty of manual memory management. In C++ it is usually very easy, as long as you're consistent about doing deallocations in destructors. I once had to write a 40,000+ line C++ program, with lots of dynamic memory management going on; once development was complete, I ran a complete test suite under Purify, and found 5, yes, five, memory leaks. Considering that most leaks are the result of mis-handled object ownership, which is an issue that garbage collection does not eliminate in general, you should be careful about your design, *and* use memory analyzers like OptimizeIt, even when developing in a GC environment.

      You probably didn't use multiple 3rd-party libraries then. Each one will potentially use a different model. Particularly insidious libraries have you free memory inside structs before freeing the struct (object) itself. Java has no ambiguity in this regard. You don't have to worry about how to "free" object Foo from some factory in Mary's handy library -- it Just Works.

      Garbage collection is all about programmer convenience. The tradeoff is that it causes issues for performance testing -- but there are many, many tools to help with that, and they are much easier to implement than memory leak detectors (particularly in event-driven systems with near-infinite states).

      Good riddance to C++. It's great for games and (maybe) operating systems, but keep it the hell away from the datacenter.

      --
      The wheel is turning, but the hamster is dead.
    70. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 0, Troll

      And yet you're incorrect. Further, I could teach you how to do the same, as I have many people over the years, from junior programmers to team leads. Like I said, a coding style requiring you to check for mistakes in every function or class means mistakes are inevitable. That's why I've never liked C. However, there are C++ coding styles where the particular problem of leaking resources becomes very simple and managable.

      I work on the sort of software where resource leaks (in particular) are going to be noticed. I've worked for companies with QA engineers who were dedicated full time to leak detection, because leaks in production code would affect customer perception of the product quite badly.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    71. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      That's not to say unmanaged code doesn't have its place, but in my experience managed code tends to get developed faster and cheaper than equivalent unmanaged code, so it only makes sense to use unmanaged code where you really need the performance or nuts&bolts control. Your typical productivity or business logic application don't. Drivers, real-time systems, etc do.

      Garbage collected code really only has a place on powerful PC, Sever platforms etc... In my experience on smaller platforms such as mobile phones, Java for example is almost more trouble than it is worth. And don't anybody start talking about mobile platforms being a niche market, it is a very big and growing market. You are IMHO usually better off writing portable managed C, C++ or even Obj. C code, precisely because of the bare metal resource control that you get. Just try to port, say, Obj. C code that uses garbage collection to iPhone OS which doesn't support garbage collection... fun... fun... fun. The one thing I like most about Obj. C is that you get the entire range of memory management strategies from manual reference counting, through auto-release pools to garbage collection. I write a lot of memory managed code simply to maximize my portability options and it really isn't as hard or as error prone as people claim it is. You do have to put in a bit of work to learn the ropes of memory management. Writing good OOP code will help you a lot and you will have to get used to using analysis tools to find memory leaks etc... It's extra work but it isn't exactly quantum physics either.

    72. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      No such claim. It simply isn't that hard to avoid leaks if you use the right C++ style; no heroism required.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    73. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      I certainly don't work for a consuling company with "clients". I've worked on a variety of appliances and turn-key systems where there's just no tolerance for leaks. I've also worked on some big-name shrink-wrap systems software where they were similarly paranoid, because software uptime really mattered.

      Really, why is it so unbelievable that a coding style can remove the possiblility for memory leaks? A garbage collector largely does. Simply not using dynamically allocated memory also does (my first 5 years of coding were in a mainframe assemby environment where there was no malloc(), strange as that may seem, though we used dynamic memory from small pools in a few places where there was no other way.

      Have you ever seen how memory management is done in an appliance or switch? Or in good idiomatic C++?

      --
      Socialism: a lie told by totalitarians and believed by fools.
    74. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      Well, I did use Scheme back in the day, but there was no debugger. My professional coding, however, has all been assembly and C++ (and a very small amout of actual C).

      --
      Socialism: a lie told by totalitarians and believed by fools.
    75. Re:Forgive my ignorance WAS:re: Garbage collector? by blueskies · · Score: 1

      Five dancing Memory leaks!

    76. Re:Forgive my ignorance WAS:re: Garbage collector? by againjj · · Score: 1

      The reason why Java has garbage collection has nothing to do with programmer convenience; it is needed in order to make Java's security model work. Without garbage collection, a thread could allocate a chunk of memory and then free it, while hanging on to the pointer -- and then periodically take a look at what shows up in the memory area where the previously freed block used to be. Any Java process running in the same VM would be at risk. This kind of deliberate use of "dangling pointers" is easy to prevent if using garbage collectors, very difficult to prevent otherwise.

      Wikipedia mentions a couple ways, tombstones (which I called handles), locks-and-keys (which appears to be slightly inaccurate, but the idea is correct), and a probabilistic allocator. Just build one into the language.

      FWIW, I also beg to differ about the difficulty of manual memory management. In C++ it is usually very easy, as long as you're consistent about doing deallocations in destructors. I once had to write a 40,000+ line C++ program, with lots of dynamic memory management going on; once development was complete, I ran a complete test suite under Purify, and found 5, yes, five, memory leaks. Considering that most leaks are the result of mis-handled object ownership, which is an issue that garbage collection does not eliminate in general, you should be careful about your design, *and* use memory analyzers like OptimizeIt, even when developing in a GC environment.

      So, even after being careful about memory management in 40 KLOC written by a single person, you still had five memory leaks? And that is easier than GC how? Remember that you have had to develop a method of memory management, that you are not dealing with competing methods of memory management from multiple developers, and that the program is not large. Sorry, but you are not convincing.

    77. Re:Forgive my ignorance WAS:re: Garbage collector? by Thomasje · · Score: 1

      The reason why Java has garbage collection has nothing to do with programmer convenience; it is needed in order to make Java's security model work. Without garbage collection, a thread could allocate a chunk of memory and then free it, while hanging on to the pointer -- and then periodically take a look at what shows up in the memory area where the previously freed block used to be.

      Ridiculous. The only way to allocate dynamic memory from the Java language is by creating objects; there is no way to "hang on to a pointer" because there are no pointers. If you're talking about the JVM itself, then that all depends on the implementation of the VM -- but even still, there is no idea of a pointer unless you're in JNI, in which case you're bypasing the security model anyway...

      OK. There are no "pointers" in Java, there are just these things that... somehow... reference objects. Oh, right, now I remember, they're called "references". How stupid of me; I used the wrong word and this totally invalidates my point!

      So, let's say I do this:

      byte[] b = new byte[100000000]; free(b);

      OK, I know there is no "free()" in Java, but that's kinda the point.
      What would happen if I were to dereference b after having freed that large array? What memory would it point to, oops, excuse me, what memory would dereferencing b cause to be read or written to?

      It's a real honor to be sneered at by someone with a 4-digit slashdot ID who clearly has no fscking clue what he's going on about. Good day to you, sir! :-)

    78. Re:Forgive my ignorance WAS:re: Garbage collector? by againjj · · Score: 1

      I hear you can marshal Java data for use by C libraries and vice versa. I'd expect a hole there where you could get the contents of a pointer.

      There's no hole; when marshalling a compound object, the actual bits of the pointers aren't marshalled, the objects they point to are. Marshalling the bits of a pointer would be pointless (no pun intended) because they wouldn't mean anything to the receiver.

      I think that he is referring to JNI, at which point you have a pointer. However, at that point you are in C land, and any pointer complaints are C memory management issues, so the pure Java security model holds. Java explicitly states that native libraries blow a hole in security so large a tank can drive through.

    79. Re:Forgive my ignorance WAS:re: Garbage collector? by Nicopa · · Score: 1

      Java "machine code" targets an abstract CPU which can handle "objects", "methods". You can disassemble compiled Java code and you see "invokevirtual" which means "invoke a virtual method on an object".

      Then, an object in Java is a fundamental thing, there's no way to "decompose" it. There no way of getting its memory image. This has some nice properties:

      • The vm can reorder object fields to play nice with machine's alignment.
      • Security, you only can access the objects you have been given to. There's no pointer arithmetic. At all.
      • All objects know who they are, there are no undetected wrong casts (similar to the newer dynamic casts C++ now have)
    80. Re:Forgive my ignorance WAS:re: Garbage collector? by bertok · · Score: 1

      That's a tad arrogant. Memory management is already non-trivial in small programs, but have you ever tried doing it in a program that is all of the following, all at once:

      - event driven
      - multithreaded
      - modular
      - developed by several people

      In environments like that, you end up spending an awful lot of time figuring out just precisely which thread gets to deallocate memory, except when there's an event handler, but not when.. you get the idea. I've seen C++ code that basically kept making copies of every string that was passed between modules, because there was no other truly safe way of passing strings around. In a string-heavy program like a web server, or a database-driven app, that can be hideously inefficient.

      This is why almost all (99%?) of web development is done with managed languages, because it hits all 4 of those of problem points.

    81. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      I dislike the very virtualness you like. But I guess if you need security at a finer grain than a process boundary, it's a real help. Hmm, perhaps debugging at the bytecode level would be enough to solve those "dammit, my source code looks right" bugs. Does Java have the notion of application crash dumps, where you can debug the remains of a crashed program after the fact?

      --
      Socialism: a lie told by totalitarians and believed by fools.
    82. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      Garbage collection is not necessary for safety. If Java used a traditional memory allocation/deallocation system, and the deallocator was designed to null out all references upon deallocation of the object, then it would be impossible for a Java program to snoop on memory using a reference to an object that has been deallocated.

    83. Re:Forgive my ignorance WAS:re: Garbage collector? by Nicopa · · Score: 1

      There's no need. There are no segementation faults in Java. There's no way you can access memory you don't own. And then, any error just provokes an exception, which can be catched.

      You are right that Java model help with the need of having finer-grain-than-a-process security. It's partly because it was made for applets. Java supports running safely completely untrusted code.

      And your objection to "virtualness" can be replied with an analogy of C vs assembly language. In Java you loose control, but the VM gains control to optimize... just as in C, gcc usually knows more about how to optimize. And speed-wise Java is very good, is at most 2x slower than pure C (I think it's even faster), which is a great thing actually.

    84. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      Oh, well, sure. If you ban allocating memory from your program, you certainly can't leak allocated memory. Are you simple?

    85. Re:Forgive my ignorance WAS:re: Garbage collector? by Thomasje · · Score: 1

      The reason why Java has garbage collection has nothing to do with programmer convenience; it is needed in order to make Java's security model work. Without garbage collection, a thread could allocate a chunk of memory and then free it, while hanging on to the pointer -- and then periodically take a look at what shows up in the memory area where the previously freed block used to be. Any Java process running in the same VM would be at risk. This kind of deliberate use of "dangling pointers" is easy to prevent if using garbage collectors, very difficult to prevent otherwise.

      Wikipedia mentions a couple ways, tombstones (which I called handles), locks-and-keys (which appears to be slightly inaccurate, but the idea is correct), and a probabilistic allocator. Just build one into the language.

      I didn't say it's impossible to avoid dangling pointers without GC, just that it is very difficult.
      OK, so it's not "very difficult" -- I concede the point. It is merely "difficult", as in "a lot more involved than simple malloc/free". GC is not the only solution, but the other solutions aren't much better in terms of performance penalties.

      FWIW, I also beg to differ about the difficulty of manual memory management. In C++ it is usually very easy, as long as you're consistent about doing deallocations in destructors. I once had to write a 40,000+ line C++ program, with lots of dynamic memory management going on; once development was complete, I ran a complete test suite under Purify, and found 5, yes, five, memory leaks. Considering that most leaks are the result of mis-handled object ownership, which is an issue that garbage collection does not eliminate in general, you should be careful about your design, *and* use memory analyzers like OptimizeIt, even when developing in a GC environment.

      So, even after being careful about memory management in 40 KLOC written by a single person, you still had five memory leaks? And that is easier than GC how? Remember that you have had to develop a method of memory management, that you are not dealing with competing methods of memory management from multiple developers, and that the program is not large. Sorry, but you are not convincing.

      Yes, I had 5 memory leaks in 40000 lines of code -- and I found and fixed them all in one afternoon. I thought that wasn't bad, considering it had taken me 6 months to write those 40000 lines to begin with. If you know some way to write code that doesn't have memory leaks at all, I'd be interested to know how you manage that. It's not like using Java, or GC in general, prevents all memory leaks; I have had to deal with that kind of problem too, but I'm always glad to learn.

    86. Re:Forgive my ignorance WAS:re: Garbage collector? by HR · · Score: 1

      What you say might have some basis in reality but I have to say it sounds like bullshit to me. Java could easily have provided for manual memory management without using direct pointers to memory in order to do so. Hypothetical allocation / deallocation methods could simply operate on references that may only have either a legal value or null (when deallocated or going out of scope on stack allocation).

      If you bothered to do the slightest bit of research, Gosling himself says many times that it's for programmer convenience and to increase the robustness of applications. Pointer bugs are the bane of C and C++ programmers (yes, I've programmed in both for about 15 years and had my share of them as well). Gosling was shooting for something like C++ with all the hard bits removed.

      Can you provide a reference for your claim that it has nothing to do with programmer convenience and is only about the Java security model?

    87. Re:Forgive my ignorance WAS:re: Garbage collector? by TheRaven64 · · Score: 1

      A lot of C++ programmers adopt a style which makes it very difficult to leak memory. The down side is that all objects are arranged in an ownership tree (i.e. with a single parent). This has two disadvantages. If you alias objects, you need to be very careful of ownership. Most C++ programmers avoid this by gratuitous copies. Because of the tree structure, the deallocation of objects must occur in a precise order, meaning that a random object's lifespan is typically much longer than it needs to be. Neither of these are technically memory leaks, because the objects are always references by a path from some arbitrary root (globals and stack variables), but the memory usage is much, much higher than it needs to be. These same programmers dislike GC because their style of programming keeps references to unused objects around for a long time and so the GC doesn't provide any benefit.

      --
      I am TheRaven on Soylent News
    88. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      Actually, you still can have memory leaks, sort of, even with fixed-size arrays. We sure had plenty at my last job. And dangling pointers were an absolute menace.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    89. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      Yeah, the applets thing makes sense.

      C# works the same way with exceptions, and it's a huge pain for debugging. When there are unhandled exceptions at a customer site, it's very hard to get to the bottom of it. You get the function call stack, but that's it, and sometimes that's just not where the problem is. And of course, programs still crash, when they call C code that in turn has a seg fault. Without a dump, there's *nothing* to go on for the C code (weeks of my life I'll never getback for just such a C/C# issue).

      What really annoys me about the C# exceptions thing is that there's now a large group of programers who think that if they catch all exceptions, and clean up external state there (such as resource locks), they can't possibly leak. This causes no end of grief when they inevitably leave stuff locked due to machine crashes, blue screens, network outages, etc, and can't believe there could possibly be a problem with their design.

      I dunno: for all the claims of high level languages being fast, we ran 2000 active users on a mainframe with the processing power of a 200 MHz Pentium, processing terminal traffic almost identical in content to HTML Gets and Posts for the same sort of data today. Of course, our "applets" had no memory security at all (not even process boundaries), but somehow it just wasn't a big problem - but then COBOL didn't have pointer arithmatic either, so maybe that's why.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    90. Re:Forgive my ignorance WAS:re: Garbage collector? by shutdown+-p+now · · Score: 1

      When I'm the technical lead or architect for a project, there are no memory leaks in the project (or at leats none where I have authority). It's a matter of programming style (and using C++, not C).

      So you never had a cyclical structure in C++ where ownership is not straightforward?

      You have to try pretty hard to leak memory in C#

      Not really. You just have to forget to unregister an event handler, or create a long-lived lambda alongside a short-lived one in the same scope with captured reference locals...

    91. Re:Forgive my ignorance WAS:re: Garbage collector? by Thomasje · · Score: 1
      OK, never mind the "bullshit", me never "bothering to do the slightest bit of research", whatever. If *you* had bothered to do even the slightest bit of research before accusing me of talking out of my rear end, you might have stumbled across this little tidbit (which I just found after 2 minutes of googling):

      But in terms of doing special things for other languages, there are actually quite a few languages targeted at the Java VM for quite a while. And it actually works pretty well for a wide variety of languages. There are some languages that are very hard to do, like C and C++. And thats mostly because theres no way to do them correctly without creating huge security holes. And thats part of the problem with C and C++. Their naked pointers are just a problem.

      See here.

      Gosling doesn't actually state that the JVM was designed the way it was because of the naked pointer problem, so you may not be convinced by that interview, which took place more than a decade after Java was first released to the public. And, since I didn't think to make a note of the article that mentioned the Java design goals, more than 10 years ago, I can't prove *my* point right now, either. Mea culpa.

      Maybe Gosling only realized that "naked pointers" can cause security problems after he designed Java?

      Whatever...

    92. Re:Forgive my ignorance WAS:re: Garbage collector? by Mr2001 · · Score: 1

      It's actually easier IMO to avoid file handle leaks, resource lock "leaks", and leaks of everything except memory in C++ than in languages like Java and C#.

      How do you figure?

      If I write a C# class that uses an OS resource like a file handle, I can write a finalizer for that class that will close the file no matter what happens in my app. And then as long as these handles are only used via my class, I never have to worry about leaking a file handle: the GC will call my finalizer before reclaiming the object's memory.

      In C++, I can write a destructor for the class to get a similar effect, but I have to ensure that I only ever allocate instances on the stack (where destruction is guaranteed by the compiler). If I accidentally allocate an instance on the heap, it's a potential leak.

      --
      Visual IRC: Fast. Powerful. Free.
    93. Re:Forgive my ignorance WAS:re: Garbage collector? by BikeHelmet · · Score: 1

      but a poor programmer will always find ways to do things wrong.

      But at least it won't leak memory up the wazzoo and crash constantly, right? :P I'd take horrible performance over that!

    94. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      use WeakReferance in a map you ignorant asshole

    95. Re:Forgive my ignorance WAS:re: Garbage collector? by LittleJedi · · Score: 1

      I think you're probably correct. However, I say that with some regret: C++ was my first programming language and remains my favorite, and I actually enjoyed doing my own memory management. I suppose my feeling of some regret is probably similar to people who felt they lost something when they no longer wrote in assembly or binary or punch cards.

      At least there are a few areas left where you can still do your own memory management.

    96. Re:Forgive my ignorance WAS:re: Garbage collector? by geekboy642 · · Score: 1

      There is no such thing, in Java, as allocating a chunk of memory.
      There is no such thing, in Java, as a pointer to memory.
      There is a thing called a reference, which may be one of two things: a pointer to a specific object instance (basically a vtable) or null.
      Vtables contain a reference counter. When the counter reaches zero, the bus explodes^W^Wobject is a candidate for GC, and means that there are no references left to the object. If the JVM is coded correctly--and this is a very critical piece of code, it's very thoroughly tested--there is no way to keep a reference to an object whose reference count is zero. The following code should be instructive:

      BigAssArray foo = new BigAssArray (1000000000);
      int bar = 0;
      foo.populateWithRandomNumbers;
      bar = foo.getContentsOfArray(0);
      System.out.println(bar);
      foo = null;
      // NullPointerException will be thrown here
      bar = foo.getContentsOfArray(0);
      System.out.println(bar);

      No matter how you obsfucate your code to hide it, you cannot confuse the compiler enough to let you continue using a null object in the way you are envisioning. GC in Java is completely orthogonal to security.

      --
      Just another "DOJ fascist authoritarian totalitarian bootlicker" -- Zeio
    97. Re:Forgive my ignorance WAS:re: Garbage collector? by rossjudson · · Score: 1

      At some point this is supposed to be Slashdot, so I'll bite.

      You claim your Kung Fu is strong, but reference a mysterious "style".

      Functional? Object-oriented? Stack-oriented?

      Single-threaded? Multi-threaded? CSP? Event-oriented?

      Heap allocation? Stack allocation? Fixed-size pools?

      Mix and match as you will. Chances are some of the folks here will be able to understand a code sample demonstrating your iron monkey style, should you choose to provide it.

    98. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      I seem to find work helping companies get their act together on stuff like this.

      Ahh... Now I think we understand. You seem like a consultant -- you come in, tell everyone what's "wrong" with systems you really don't understand, "fix" them, then get out before your memory leaks bring down production every few weeks.

    99. Re:Forgive my ignorance WAS:re: Garbage collector? by Thomasje · · Score: 1

      There is no such thing, in Java, as allocating a chunk of memory.

      Right, so when I say

      byte b = new byte[10000000];

      what is getting allocated, exactly? It looks to me like that would be 10 million bytes of memory, but according to you, apparently it's not. Please enlighten me as to what it is being allocated, exactly, then?

      There is no such thing, in Java, as a pointer to memory.

      Right. There's only references, which do... what, exactly? How do I get from the b above to the 10 million bytes of memory that I just allocated?

      There is a thing called a reference, which may be one of two things: a pointer to a specific object instance (basically a vtable) or null.

      *groan*

      A vtable is an object that describes a class. It contains pointers to the virtual methods defined by that class, and it has a pointer to the vtable of its superclass (if it has a superclass).
      An object contains a pointer to its vtable.
      Repeat after me: a reference is a pointer to an object, and an object is an instance of a class. An object that belongs to a class that has virtual methods, needs to have a pointer to the vtable of its class. In Java, all classes have virtual methods, so all objects contain pointers to a vtable. In C++, objects that belong to a class that doesn't have any virtual methods, have no pointers to any vtables.

      *sigh*

      I don't mind being lectured, but being lectured by someone who doesn't know what he's talking about is... Well, it's amusing, I guess, but it's also a bit sad. So do your homework, dude.

      Back on topic, what I was saying is that garbage collection is necessary to prevent one thread within a JVM from being able to peek at memory that has been allocated by another thread. If thread A wants thread B to be able to look at its data, it can pass references to that data to thread B, but the whole point is this: if thread A does not want thread B to be able to look at its data, all it has to do is not pass any references to its data to thread B... but making that secure requires preventing thread B from peeking at anyone else's memory that it hasn't been given any references to, and that requires garbage collection -- or some other way to prevent pointers from pointing at something that they shouldn't be pointing at.

    100. Re:Forgive my ignorance WAS:re: Garbage collector? by geekboy642 · · Score: 1

      Three words for you, you pompous and ill-informed windbag:

      NULL POINTER EXCEPTION.

      --
      Just another "DOJ fascist authoritarian totalitarian bootlicker" -- Zeio
    101. Re:Forgive my ignorance WAS:re: Garbage collector? by rackserverdeals · · Score: 1

      what is getting allocated, exactly? It looks to me like that would be 10 million bytes of memory, but according to you, apparently it's not. Please enlighten me as to what it is being allocated, exactly, then?

      An object that can hold that many bytes. You're not allocating anything directly. The JVM handles that.

      Right. There's only references, which do... what, exactly? How do I get from the b above to the 10 million bytes of memory that I just allocated?

      You don't get to that memory, you get to that object. It just happens to be stored in memory but it could be stored on stone tablets if that was possible..

      or some other way to prevent pointers from pointing at something that they shouldn't be pointing at

      As a java developer, you don't have pointers, which you keep going back to. You have object references. Behind the scenes there are likely pointers but you don't get access to them. You're arguing that it was done for security instead of ease for the programmer which is missing the point. Keeping your code secure by preventing memory leaks and illegal memory access is difficult and time consuming. By fixing one, you get the other. Which was the motivating factor is only something Gosling can answer.

      The point is in Java applications, you can still have "memory leaks". The difference is in Java, those leaks result in poor resource management and bloated programs. What you don't get is the security risks that poor memory management in C/C++ can give you.

      You don't need a garbage collector for the type of security you're talking about. Java could have had a free operator that would point all references to null and handle the security issues, but it would make things difficult for the developer.

      --
      Dual Opteron < $600
    102. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      If the system can null out all references to an object when you free it, then it knows how to find all references to the object. Which means it knows whether the object still has any references. In what sense is that not a garbage collector? Also, how could you ever ensure no thread has a copy of that invalid reference in cache or a register?

    103. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      You think you've never once had a memory leak.

    104. Re:Forgive my ignorance WAS:re: Garbage collector? by ADRA · · Score: 1

      yeah, they have the ability to dump full heap/stack dumps on really bad errors if you enable them, but typically Java tells you (generally if not specifically) where your errors occur unless you're doing something really funky, or your error happens to be OutOfMemory, in which case the memory 'leak' could be difficult to trace without a good profiler like jprofiler.

      --
      Bye!
    105. Re:Forgive my ignorance WAS:re: Garbage collector? by master_p · · Score: 1

      You know, unmanaged programming languages can have garbage collection too.

    106. Re:Forgive my ignorance WAS:re: Garbage collector? by pnetz · · Score: 1
      You are mixing terminology.This thread is not about managed code but rather about garbage collection.

      Unmanaged code might very well utilize garbage collection through compiler or library support.

      That leaves the advantage of providing selective garbage collection in languages supporting manual memory allocation, which can leverage software architecture and performance.

      Your statement, as well as the general notion of this thread, that writing code in languages enforcing global garbage collection, is faster or cheaper, is false. Given the situation of enforced vs selective garbage collection, I might even argue to the contrary.

    107. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      1) Oh, yes, let's solve the problem of potentially leaking memory by using a few orders of magnitude more memory in the first place.
      2) Overhead *and* you have to twist the structure of your program to fit that pattern. Also, try using a decent GC, it'll have less overhead anyway.

    108. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      Most memory leaks in C++ are written by people coming from a Java-only education who don't have a clue about memory management and think they can just do "new" all time. So the problems in C++ are actually caused by ignorant Java programmers.

      If you have a good written set of base-classes that handle your data, the lifetime of objects, writing a program in C++ is a lot _easier_ to handle the memory management, because you just _know_ where an object gets deallocated, because if you didn't write it. Java however, still is also succeptible for bad programmers, who leave object references dangling in other objects by are unaware that the object will not be freed by the magical garbage handler and run out of memory.

      So, crappy programmers will write crappy code. No matter in Java or C++. So your standpoint is that we should all switch to "managed" (.net lingo btw, not Java) languages, just to accomodate to bad programmers in the world? Even though they will write crappy hard-to-debug-and-follow-object-lifetime - code anyway, just seems stupid.

    109. Re:Forgive my ignorance WAS:re: Garbage collector? by Attlanttizz · · Score: 1

      And there you have one of the most badly handled aspects in C++/C and similar languages: object ownership. You have to handle it yourself. This gives result to either double deallocation, or failure to deallocate. Of course if you keep everything localized, and/or use smart pointer classes, this alleviates the problem. But even so this gives rise to weirdo situations and some weirdo programming constructs that are hard to fathom for some people of average programming capabilities.

      Now to say that garbage collection rules out all memory leaking, is also not true. There will always be unmanaged resources (meaning not managed by the environment), or external resources, that you need to deallocate or release yourself. For instance if you need aligned memory blocks for IO or DMA, you still need to defer to OS libraries that are often C++/C based, and those give you pointers to memory instead of references. Another thing is forgetting to dereference objects. Other times you have to defer to environment constructs that in themselves might lead to memory loss due to badly written software.

      That coupled with the fact that programmers tend to think they are safe from memory loss in their garbarge collected environment, may result in memory loss that is never found because people think it doesn't happen. And then you have the programmers that didn't have any proper education... they will look at you if you explain all that as if you are a stupid arcane C++ era programmer, that needs to boast with his knowledge.

      Java, .NET, they brought some good things to programming languages, but they also brought some bad programmers and bad programming to the business. Not all is roses and sunshine.

    110. Re:Forgive my ignorance WAS:re: Garbage collector? by eeyoredragon · · Score: 1

      I was once asked to count the number of classes and methods that existed in a product I worked on to "measure its complexity and richness"... yah... After laughing myself to tears, I wandered around the office... one, two, three, four. four dataclasses! ahahah... No one seemed to get it :(

    111. Re:Forgive my ignorance WAS:re: Garbage collector? by hazah · · Score: 1

      There is no way to do what you are proposing unless free() is a JNI method.

      Multiple previous posts have repeatedly stated that once you are inside a JNI method, you are no longer programming in Java.

      The language, as it is, provides absolutely no syntax to "free" b. As long as you can use b, it points to that array. Again, only with JNI is this even conceivable, and JNI is NOT Java, it's C, with it's own rules about EVERYTHING.

    112. Re:Forgive my ignorance WAS:re: Garbage collector? by hazah · · Score: 1

      would think it would be a lot more robust to keep track of allocation and deallocation explicitly, add when you need, and delete when you don't need, and not count on some generic mechanism.

      Ok... so I allocate object A. Then I allocate object B, C, and D that all reference A but aren't aware of eachother. Then I release D, and don't know whether to release A, so now A needs to have some sort of reference counting mechanism, and I have to remember to use it each time I create or copy or pass a reference to A.

      Say you are using C++, in this case, the problem you're describing easily lends itself to the proxy pattern. Whereby you define a class to represent the handle & reference counting semantics for you. Since this is a very generic pattern, that class definition is probably just one line of code and the include. You then never even think about the original class, and use the handle class as if it was the original class.

      Or... I can use a language that implements the reference counting stuff for me and implicitly calls it when I allocate new objects, create, copy, or pass references, and expire them as they go out of scope, without me having to write explicit destructors.

      The above scheme gives you exactly what you crave. It also has this nifty property of being specialised for differing purposes / optimisations as necessary. This is usually done through an additional template parameter that is set to a good generic default.

      The language that implements this stuff for you rarely lets you adjust anything if you have good reason to, they only provide the defaults.

      Basically, if you do any sort of remotely complicated object allocation where you are going to need to implement reference counting to keep track of them, you might as well use a garbage collector. That's what it does, it comes thoroughly debugged, and you don't have to waste time implementing and debugging your own.

      You do not have to debug your empty class, and the compiler will happily complain if you're using it wrong.

      So, a garbage collector language is MORE robust (assuming robust means 'more reliable').

      A garbage collected language is robust provided the problem you are solving maps well to the memory management techniques employed by the garbage collector. As soon as the problem steps outside of that domain, you're in the same boat as a C programmer, having to do all your method calling explicitly to make sure things go right.

      On the other hand, with a templating scheme (I love my templates), you have a powerful and robust way to implement what you need by simple configuration.

      That said, I am very well aware of how easy it is to abuse templates in general, and am not of the opinion that they are the magic hammer and that all problems are now nails.

      That's not to say unmanaged code doesn't have its place, but in my experience managed code tends to get developed faster and cheaper than equivalent unmanaged code, so it only makes sense to use unmanaged code where you really need the performance or nuts&bolts control. Your typical productivity or business logic application don't. Drivers, real-time systems, etc do.

      The domain of C++ is any general computing problem for which C++ provides appropriate abstractions for. That's pretty damn nearly everything out there in the business world and then some, since C++ provides: functions, fully runtime polymorphic classes, as well as the ability to overload almost any operator, all within the generic context of templates. Putting that together gives you something that looks like weird python derivative.

      You may argue that I'm only offsetting the quantity of code involved to the library files I'm linking, and that my short programs are longer than they seem. But I would say that the only real difference is that in a managed program the extra code is in the manager itself serving exactly the same purpose.

      As always, use the best tool for the job. C is not always the best tool.

      And I never said it was :).

    113. Re:Forgive my ignorance WAS:re: Garbage collector? by vux984 · · Score: 1

      You are mixing terminology

      Yes I was. Thanks for pointing that out.

      Your statement, as well as the general notion of this thread, that writing code in languages enforcing global garbage collection, is faster or cheaper, is false.

      I disagree. I find projects go faster in C#.net or Java than in unmanaged c/c++, in large part due to the way memory management is handled.

      I concede I haven't tried boost, and I concede it could help significantly, but its still going to be more complicated to use than C#.NET or Java.

      That leaves the advantage of providing selective garbage collection in languages supporting manual memory allocation, which can leverage software architecture and performance.

      This is a good point though. When you do genuinely need manual memory allocation, its probably only for a portion, so having that flexibility and being able to use GC for "the rest" is potentially a big advantage. But if you don't need manual memory allocation at all, I think you are better off in a language that just provides it.

    114. Re:Forgive my ignorance WAS:re: Garbage collector? by Anonymous Coward · · Score: 0

      > Non-managed languages should be used only when
      > the performance benefits outweigh the dangers.

      You may want to benchmark your languages / libraries before jumping to conclusions about performance. A tight loop of free(malloc(20)) is about ten times slower than an equivalent Java new MyClass() loop on the systems where I try it (Linux and Windows). And yes, I run the loop enough times so that several GCs get run. Try it!

      Manual memory allocation is like the "register" keyword: in the bad old days the programmer needed to do the computer's work manually, but it's mostly automated now.

    115. Re:Forgive my ignorance WAS:re: Garbage collector? by LizardKing · · Score: 1

      Yeah, and my cock is so long it rubs against one of my ankles when I walk. If you can really back up your claims, then I'd know about it because I'd have read your books and articles.

    116. Re:Forgive my ignorance WAS:re: Garbage collector? by Thomasje · · Score: 1

      What part of my post is that supposed to be a reply to?

    117. Re:Forgive my ignorance WAS:re: Garbage collector? by geekboy642 · · Score: 1

      Well, I assumed you had just missed the entire meat of my comment. After all, you basically ripped apart the intro, ignoring about 75% of what I said. So I figured if I gave you the summary of what I had said, you couldn't help but actually read and reply to what I was trying to get through your thick skull. Apparently I was wrong. I applaud your powers of obliviousness and self-importance.

      But please, I beg of you, tell me the name of the company you work for, own, contract with, are partner in, or otherwise produce programming code for. Shorting your stock will make me rich, I tell you! Filthy rich!

      --
      Just another "DOJ fascist authoritarian totalitarian bootlicker" -- Zeio
    118. Re:Forgive my ignorance WAS:re: Garbage collector? by Thomasje · · Score: 1

      You're still not answering. When you said "Three words for you, you pompous and ill-informed windbag: NULL POINTER EXCEPTION", what was that supposed to be a reply to? And don't just say "post #28146789", how about telling me what part of that post? I'm curious what you're so pissed about.
      If you can't answer a simple question like that, have a valium and get an early night already. Sheesh!

    119. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      Sadly, there isn't much published work on proper idomatic C++. I don't know who invented shared_ptr (though I probably should), but it's all one really needs to add to the STL to make it easy to avoid memory leaks. Thank goodness shared_ptr made the cut for C++0x, and is aready available for most compilers as part of TR1. Avoiding handle leaks and the like are easy by analogy to auto_ptr.

      If you don't know what C++0x and TR1 are, you probably still think of C++ as "C with Classes" from the 80s, and are mystified by my claims.

      Oh, "and deep".

      --
      Socialism: a lie told by totalitarians and believed by fools.
    120. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      Sadly, I've never needed a non-trivial cyclical structure professionally. Nor have I ever needed floating point, though I have used that weird "fixed point" data type that's common on mainframes and dead languages.

      Nor would I ever use lambda professionally - function programming is just too hard for a "fresher" to maintain. And, sad though it is, modern programming is all about designing around programmers with 1 year of experience, 12 timezones away, who are culturally incapable of saying "I can't do that", are in the field strictly for the money and social prestige, and wouldn't know a lambda if they sat on one.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    121. Re:Forgive my ignorance WAS:re: Garbage collector? by shutdown+-p+now · · Score: 1

      Nor would I ever use lambda professionally - function programming is just too hard for a "fresher" to maintain. And, sad though it is, modern programming is all about designing around programmers with 1 year of experience, 12 timezones away, who are culturally incapable of saying "I can't do that", are in the field strictly for the money and social prestige, and wouldn't know a lambda if they sat on one.

      Well, times are changing (as they always do). I'd imagine that, 40 years ago, the exact same thing was said about structured programming as opposed to GOTO-based spaghetti code. Lambdas aren't really significantly harder to learn - they're just different from what many people have gotten used to. Now that a new bunch is learning on the likes of Python and Ruby and the more recent C# and VB, they'll pick it up much easier.

      Of course, 10 years down the line, we'll have the same migration problem with whatever other academic feature will become mainstream by then. I don't know, maybe DbC? or, heck, monads/arrows?

      Still, progress goes on.

    122. Re:Forgive my ignorance WAS:re: Garbage collector? by lgw · · Score: 1

      Isn't funtional programming as old as structured programming? It's not like it was a follow-on or something. Object oriented programing is also quite old, it just didn't become a fad until the 80s.

      If anything, working programmers are becoming less knowledgeable about the academic side over time. Just try to find a recent graduate who groks pointers these days, let alone lambda and recursion. Functional programming is harder to learn, and is only better for a narrow range of problems, so I don't see it taking over.

      Of course, I totally suck at predicting fashin trends, so who knows?

      --
      Socialism: a lie told by totalitarians and believed by fools.
    123. Re:Forgive my ignorance WAS:re: Garbage collector? by shutdown+-p+now · · Score: 1

      Isn't funtional programming as old as structured programming?

      Functional programming theory is, but structured programming became useful "in production" earlier.

      Object oriented programing is also quite old, it just didn't become a fad until the 80s.

      OOP is definitely older then either structured or FP, though. And it's precisely what I mean when I say that originally academic ideas (the first definitely OO language, Simula, was quite academic) find their way into mainstream eventually.

      If anything, working programmers are becoming less knowledgeable about the academic side over time. Just try to find a recent graduate who groks pointers these days ...

      Since when are pointers "academic"?

      Functional programming is harder to learn, and is only better for a narrow range of problems, so I don't see it taking over.

      I don't see it taking over either, but I see it being added to the toolbox alongside existing tools, such as structured and OOP. We already see this in mainstream languages Python, Ruby, C# 3.0, and even more so in the upcoming wave of Scala and F#. Ideally, I want to be able to use FP for problems where it makes sense, OOP for problems where it makes sense, etc; with boundaries between them being as seemless as possible. F# and Scala effectively let me do it today.

  24. Re:RIP Java..we hardly knew ye. by Anonymous Coward · · Score: 1, Funny

    It had no good debugger, no usable UI interface

    I think the UI interface of the ATM machine where you enter your PIN number runs Java.

  25. Harmful to open source and small businesses by jeichels · · Score: 1

    If Oracle monetizes Java too harshly, small businesses may not use it and will opt for other open source languages. Java open source projects and Linux could take a dive over time due to lack of new project interest. The one company that likes this the most is likely Microsoft. As businesses are likely going to have to pay for a language, they may as well go for a highly integrated one. C# may become more palatable.

    --

    JohnE
    jobbank.com - Search jobs, post resume,

    1. Re:Harmful to open source and small businesses by Anonymous Coward · · Score: 0

      Speaking as someone who just spent a week adding a basic Swing GUI to a trivial industrial control program, I'd say they've already managed that. I had this program working from the command line in a day. Frankly, the time it took me to struggle through the layout managers and got some readout displays updating in realtime; it would have been as fast to embed a Graphics2d Object in an AWT window and write my own widget toolkit from scratch.

      First and last business app I ever agree to write in Java. Granted I'd never used Swing before and I use vim (can't stand IDE's) but there's no way on earth a trivial GUI should involve a week of mind-numbing drudgery through javadoc.

  26. Not Oracle touch by Anonymous Coward · · Score: 0

    Sun started monetizing on Java few months prior to even buyouts were discussed - I support/maintain a bunch of Java based applications and Sun notified us that Java versions will no longer be supported for free and we would need to buy a JavaSE for Business (JFB) contract if we needed support. This applies not only to older versions but also to newest ones - no version is going to be supported on Windows and Linux for free and without support the Solaris bundled versions will be supported for lesser period than before.
    They have also begun to make JES only work/supported on Solaris - so if you want JES you need to buy Solaris and Sun Server by definition.

  27. Re:suprised???? by KerberosKing · · Score: 3, Insightful

    did anyone really think Oracle was going to continue to release fully featured JDKs for free?????.....this is why the day Oracle bought Sun, i started learning C#....

    lol, yes because C# is owned by a much more FOSS-friendly company. Microsoft would never charge to support experimental features in production-code.

  28. G1 is already in OpenJDK by TeaCurran · · Score: 5, Informative

    G1 is in the latest OpenJDK builds. Since it is GPL you are free to use it without any license restrictions.

    The note in the release notes is only saying that Sun won't officially support it in their releases without a support contract.

    If you are concerned, use OpenJDK.

    1. Re:G1 is already in OpenJDK by argent · · Score: 1

      Since it is GPL you are free to use it without any license restrictions.

      "It" being G1 or OpenJDK?

      Do you mean GPL or LGPL?

    2. Re:G1 is already in OpenJDK by TeaCurran · · Score: 1

      OpenJDK and G1 are both GPL

    3. Re:G1 is already in OpenJDK by vedder110 · · Score: 1

      It's GPL with Classpath exception. The Classpath exception combined with the GPL is very similar to the LGPL because it allows you to "link" to the OpenJDK libraries without having to license your code under the GPL.

    4. Re:G1 is already in OpenJDK by Anonymous Coward · · Score: 0

      "Since it is GPL you are free to use it without any license restrictions." ... other than those contained in the GPL, of course.

  29. Reference Counting != Garbage Collection by samweber · · Score: 5, Informative

    No, no, no! Creating a cycle of object references does not cause a memory leak in Java!

    You are assuming that a garbage collector uses reference counting. However, reference counting doesn't work for the very reason you state, and therefore GCs don't do it that way. They actually check whether an object is usable by the program, and not just whether it has any old reference to it.

    1. Re:Reference Counting != Garbage Collection by nog_lorp · · Score: 1

      Exactly. In theory, Java uses reference counting all the time and Mark-Sweep at intervals or when JVM heap space runs low.
      In practice, it only uses Mark-Sweep.

      Mark-Sweep is the process of pausing the program, marking every single object with a "free this" flag, and then following through the stack following every reference and unmarking every object it comes across.

    2. Re:Reference Counting != Garbage Collection by shutdown+-p+now · · Score: 1

      In theory, Java uses reference counting all the time ...

      In what theory? I've never, ever heard of Java using reference counting. Not in official specs, not in the books, nowhere. A compliant JVM is certainly not precluded from doing so (though it still must handle cyclic references, so it needs something apart from pure refcounting), but it is widely understood that it's not a good approach for various reasons (apart from cyclic references problem, it adds a pretty hefty performance penalty).

      Mark-Sweep is the process of pausing the program ...

      Not necessarily. Modern tracing GCs (such as the ones in Java and .NET) can actually do quite a lot concurrently, without pausing other threads.

    3. Re:Reference Counting != Garbage Collection by HeronBlademaster · · Score: 1

      It used to in C#... I'm half-sure they've fixed it by now.

    4. Re:Reference Counting != Garbage Collection by radtea · · Score: 1

      A compliant JVM is certainly not precluded from doing so (though it still must handle cyclic references, so it needs something apart from pure refcounting)

      Actually, a compliant garbage collector in Java doesn't have to do anything except support the GC interface. Unless the spec has been updated (it's been six years since I cared, thank heaven) the GC can be implemented such that it never actually collects garbage (I suspected one particular JVM was like this, back in the day...)

      To put it another way, the spec leaves the question of when to collect garbage up to policy, and a perfectly valid policy would be "when the program exits." There is an interface to allow clients to suggest that actually collecting garbage might be a good idea right now, but GCs are free to ignore those suggestions, and there is no interface to say, "Collect my garbage now goddamnitIreallymeanit!"

      Most developers have a pretty good idea when such a thing would be useful (like, say, when they've just had an allocation failure because the lazy garbage collector can't be bothered to run) but unfortunately the writers of the Java spec figure that the implementors of GCs know better than the application developers when the GC should run, because of course the implementors of the GC have so much more information about what the application's needs are than the application developers...

      I have no doubt things are better now, but as Java was a lot of people's first introduction to a GC'd language in the '90's it put a lot of us off GC for a long time.

      --
      Blasphemy is a human right. Blasphemophobia kills.
    5. Re:Reference Counting != Garbage Collection by Talchas · · Score: 1

      If you are getting an allocation failure in Java when you actually have the memory available (if you include garbage), then your VM probably sucks and should be changed. The sun VM may eventually not check extremely long lived objects, I don't recall, but in general if you would run out of memory when allocating the VM should do a GC pass first before throwing an error.

      --
      As the Americans learned so painfully in Earth's final century,free flow of information is the only safeguard against...
    6. Re:Reference Counting != Garbage Collection by Logic+and+Reason · · Score: 1

      However, reference counting doesn't work for the very reason you state, and therefore GCs don't do it that way.

      Good GCs don't do (only) reference counting. Perl's does, for one, and Perl suffers from exactly those kinds of memory leaks.

    7. Re:Reference Counting != Garbage Collection by Anonymous Coward · · Score: 0

      C# uses a generational (copying) collector, and they like to brag about the fact that it has super fast allocations (usually O(1), unless you can't complete the operation without a collection).

      Generational collectors are generally faster than mark and sweep collectors, but they require several times as much allocated memory. So if your program has 2GB available to programs, you might only be able to get 500MB to 1GB from the collector, depending on the number of generations.

    8. Re:Reference Counting != Garbage Collection by Anonymous Coward · · Score: 0

      > However, reference counting doesn't work for the very reason you state, and therefore GCs don't do it that way.

      Well... reference counting _works_ - it just doesn't work very well. But is damn fast, so it actually does get used sometimes (in Perl5, for instance). It does generally put a greater onus on the programmer (since they have to be sure not to create cycles or to break them appropriately) than other sorts of GCs, but it is damn fast. And as TheRaven64 noted above, you can combine reference counting with cycle detection to get the accuracy marksweep, generation, or treadmill style GCs. These kinds GCs still aren't as accurate as they could be though, since they only free objects that are no longer referenced: a leak can still occur if a reference is kept to an object that is no longer used. (Haskell is the only language I'm aware of with a GC that attempts to free objects that are no longer used but still referenced)

    9. Re:Reference Counting != Garbage Collection by Anonymous Coward · · Score: 0

      Reference counting is the slowest form of garbage collection. It requires memory barriers (increments and decrements must be atomic) and chews up bandwidth to main memory (which is severely limited on modern machines) and cache space in proportion to the number of short-lived dead objects, not merely the number of long-lived live ones.

  30. Re:RIP Java..we hardly knew ye. by Anonymous Coward · · Score: 0

    Nope, not even close..embedded systems generally run C/C++, there is no room for java bloat.

  31. Maybe Mono isn't that "bad" for Open Source after by melted · · Score: 1

    Maybe Mono isn't that "bad" for Open Source after all. A little competition will put a damper on stupid shakedown attempts like this one.

  32. I got an offer! by Sybert42 · · Score: 0

    Anyone who thinks the singularity will (make this moot && come before 10 years are up), don't reply to this! Now that's cool.

  33. Oh no! by HyperQuantum · · Score: 1

    Java is doomed! Everyone switch to .NET!

    oh wait...

    --
    I am not really here right now.
  34. Bad Oracle touch by NewbieProgrammerMan · · Score: 3, Funny

    So the Oracle touch is already taking effect.

    Fork you, Oracle!

    --
    [b.belong('us') for b in bases if b.owner() == 'you']
  35. Why would you call it G1? by Sangbin · · Score: 2, Insightful

    Developers may search for JRE on Android...which is also called G1.

    Do you really want mixed results on Google search for "G1 Java"?

    1. Re:Why would you call it G1? by Anonymous Coward · · Score: 0

      I imagine both of these products were developed at around the same time and the fact that they came up with the same codename is purely coincidence.

      The Java G1 stuff is not consumer facing anyway and developers already know what to look for. No point wasting a bunch of effort renaming something like this when it's no big deal.

    2. Re:Why would you call it G1? by TheRaven64 · · Score: 1

      The first papers I read on the G1 garbage collector were a couple of years ago. They've been working on this for a longtime and had publicised the name quite a while before Google announced Android.

      --
      I am TheRaven on Soylent News
  36. Oracle deal not done yet. by cneth · · Score: 4, Informative

    Oracle does not yet own Sun and can't (yet) set business direction for it. It's just a new, experimental feature, folks.

    1. Re:Oracle deal not done yet. by Anonymous Coward · · Score: 0

      If you think that they're actually waiting for the deal to formally close, before Oracle starts making its influence felt, you are very naive. This is _directly_ related to the acquisition. Some VP trying to prove he's worth his salt, before Oracle decides to toss him or not.

    2. Re:Oracle deal not done yet. by Anonymous Coward · · Score: 0

      Wow a /.'er who actually knows something of the real world. I was just about to point that out, thanks for beating me to it.

  37. Larry effect by G3ckoG33k · · Score: 1

    Hot Java on the yacht!

  38. Re:RIP Java..we hardly knew ye. by boristdog · · Score: 1

    It had no good debugger, no usable UI interface

    I think the UI interface of the ATM machine where you enter your PIN number runs Java.

    GOLD, Jerry! GOLD!

  39. sensationalism by bcrowell · · Score: 4, Interesting

    The slashdot summary seems to me to have a heavy dose of sensationalism.

    Oracle's implementation of java is GPL'd. What more do we want from them?

    I doubt that there's been any recent research that's uncovered some fantastic new mechanism for garbage collection that was never known before. Garbage collection used to suck, and that was one of the problems, historically, with LISP. Over the decades, garbage collection has gradually gotten better. All the improvements in garbage collection are in the public domain. Gc is not generally a performance bottleneck for modern garbage-collected languages.

    It would be slightly more worrisome if this new gc algorithm was patented -- but I haven't seen any evidence that it is. If it's not, then nothing is preventing anyone from making a fully GPL'd version of java with the new algorithm. If it was patented, then this would be a problem for all garbage-collected languages with open-source implemtations, not just java.

    Does java's performance really depend much on the efficiency of its gc? My main complaint about java's performance is that the VM and libraries take too long to load.

    1. Re:sensationalism by TFoo · · Score: 1

      Yes, for long-running servers, GC performance can still be a very big issue with Java (and all GC languages). For short- or medium-lived apps (the kind that you're more thinking about -- since you talk about VM and library load time) GC performance is less of an issue.

    2. Re:sensationalism by Anonymous Coward · · Score: 0

      Actually, for long running servers, it depends on whether you focus on throughput or latency.

      For throughout, GC is better because infrequent pauses are compensated by faster allocation (with modern GCs, increment a pointer) and better deallocation throughput (no need to maintain a complex free heap structure).

      For latency, you're better off with manual freeing because there's an upper limit on response time.

      Note: this doesn't apply to reference counting.

      If you're interested in startup time, GC is irrelevant. If you have enough RAM, it's faster to (basically) not deallocate, which a GC allows you to do, but compiling the VM code is slower -which is nothing to do with GC, really-.

    3. Re:sensationalism by Anonymous Coward · · Score: 0

      "Oracle's implementation of java is GPL'd. What more do we want from them? "

      Are you kidding? It's not BSD'd!

  40. G1 is for the Entreprise by jeanph01 · · Score: 5, Informative

    Here [http://developers.sun.com/learning/javaoneonline/j1sessn.jsp?sessn=TS-5419&yr=2008&track=javase] what sun says about it : The Garbage-First garbage collector (G1 for short) is the next-generation low-pause garbage collector that will be included in the Java HotSpot virtual machine. G1 will be the long-term replacement for the Concurrent Mark-Sweep (or CMS) garbage collector, Sun's current low-pause garbage collector. G1 targets medium to large multiprocessor machines and large heaps, relying heavily on the concurrency and parallelism such machines offer. Like CMS, G1 is generational, which benefits throughput. Unlike CMS, G1 compacts to battle fragmentation and to achieve more-consistent long-term operation. As its name suggests, G1 concentrates its collection and compaction activity first on the areas of the heap that are likely to be full of reclaimable objects, thus improving its efficiency. G1 uses a pause prediction model to meet user-defined pause time targets. It achieves smoother pause times than CMS, with fewer or no outliers at comparable or better throughput, as this presentation shows. The initial target pause times are in the low tens of milliseconds. === So this is more for entreprise multiprocessors, multiservers java. And those entreprise normally will buy a support contract. So it's almost a no news.

    1. Re:G1 is for the Entreprise by binarythoughts · · Score: 1

      In terms of throughput, how does it compare to the throughput garbage collector?

    2. Re:G1 is for the Entreprise by Paul+Fernhout · · Score: 1

      VisualWorks Smalltalk had this "new" kind of garbage collector more than ten years ago. See:
          "VisualWorks space descriptions"
          http://www.smalltalkconsulting.com/papers/papersByOthers/visualworksSpaceDescriptio.html
      "NewSpace is used to house newly created objects. It is composed of three sub-spaces: an object-creation space (Eden) and two SurvivorSpaces. When an object is first created, it is placed in Eden. When Eden starts to fill up (i.e., when the number of used bytes in Eden exceeds the scavenge threshold), the scavenger is invoked and those objects housed in Eden and the occupied SurvivorSpace that are still reachable from the system roots are copied to the unoccupied Survivor Space. Thereafter, those objects that survive each scavenge will be shuffled by the scavenger from the occupied SurvivorSpace to the unoccupied one, until such time that the aggregate size of these survivors threatens to make the scavenge pause excessively long (i.e., when the number of used bytes in SurvivorSpace exceeds the tenure threshold), whereupon the scavenger will attempt to speed up subsequent scavenges by moving some of the older surviving objects from NewSpace to OldSpace. We say that such objects are being 'tenured' to OldSpace. ..."

      Just one more thing Java is borrowing from Smalltalk. Now, if they would only borrow the syntax... :-)

      --
      A 21st century issue: the irony of technologies of abundance in the hands of those still thinking in terms of scarcity.
    3. Re:G1 is for the Entreprise by TheRaven64 · · Score: 1

      Not quite. G1 is actually pretty impressive technology. It's not as nice as some of the GC algorithms to come out of IBM in the last couple of years, but it's a way ahead of a traditional generational GC.

      --
      I am TheRaven on Soylent News
  41. Wait! Holy cock-gobbling fucktarded shit! by Anonymous Coward · · Score: 0

    Someone actually asked for MONEY for the product of their work? What a communist bastard! I plan to install the latest Ubuntu and flagellate myself bloody in protest. FIGHT THE POWER!

    1. Re:Wait! Holy cock-gobbling fucktarded shit! by SoulRider · · Score: 1

      I think that be fascist bastard?

      Its communist bastards that just give their stuff away.

      Get your memes straight man!

  42. Re:RIP Java..we hardly knew ye. by Anonymous Coward · · Score: 0
  43. A Java hate piece on Slashdot??? by COBOL/MVS · · Score: 2, Insightful

    But that's the kind of stupid shit that's been spewing from here for the last 10 years.

    PS - the look and feel of slashdot sucks

    --
    GOBACK.
    1. Re:A Java hate piece on Slashdot??? by WankersRevenge · · Score: 4, Interesting

      Java got a bad rap back in the day when the language was poised to take over the desktop and then everyone used it, and were killed by its abysmal performance. Back in the 2000, I cursed java every week as I entered my development time into this crap-ola windows box that performed like a fat man running through a river of melted taffy. Loading an applet was a painful flow breaking experience that usually did nothing to a page. When people think of java, they think of this time. it's the slashdot two minute hate.

      These days, Java works well both on the desktop and on the server. Shocking, I know. I'm currently developing a desktop app for OS X and people have no idea it's a java project. It looks and behaves as if written in Objective C. Our engineering team just wrote a server app in java that had over three million entries. At one point, it was creating nine hundred entries per second without breaking a sweat. But people don't see that. They just have mental images of all the crappy applets back in the days of yore, then make uninformed opinions about the current state of the language.

      My biggest complaints about java are the inconsistent implementations between platforms so something might work great on a mac, but throws exceptions on windows. Write once, run everywhere is a lie. My code is 100% java (no native code) that runs perfect in both mac and windows, yet makes the official Linux JVM puke. I hate the fact the language is object orientated, but objects are expensive to create. I hate the fact that Swing makes it easy for good java developers to write terrible user interfaces. The GridBag layout was designed by a very bitter programmer. I hate the fact that java eats and eats all the memory it can find like a kid diving his face into birthday cake. People say there's no memory leaks in Java, but once you start playing with JOptionPane, you realize that's a nice little lie. And there is work in managing your objects. I can make an app bloat up like firefox in no time. There's a few other nitpicks, but speed has never been one of them. If it were, I would be writing my app in C++ with QT, or Objective C.
       

  44. Force garbage collection by bjb_admin · · Score: 1

    I thought to force garbage collection you do FRE(0) ?

  45. RTFA by Anonymous Coward · · Score: 2, Interesting

    Seriously, your headline is exactly backwards. Read what the pay for support is for. The G1 is beta so you pay for support... the older versions of Java that are out of date are also pay for support.

  46. wait, I am confused... by ca111a · · Score: 1

    Is Microsoft actually better in handling this kind of situation?

    1. Re:wait, I am confused... by raijinsetsu · · Score: 3, Funny

      What situation is that? If you're talking about tying a customer to a painful and harmful contract, then yes.

  47. Even when... by jd · · Score: 2, Insightful

    ...you have explicit allocation/deallocation, you get holes in memory. There's no way to avoid it, for the same reason that fragmentation occurs on disks. Unless the chunk you allocate is exactly the same size as the chunk last deallocated, there will be a region of memory that cannot be used.

    This means that your heap will end up looking like swiss-cheese, unless you have some means of shuffling things around. Unless the programmer can absolutely guarantee that mallocs and frees only occur in such a way that no space unusable to the program's next malloc is ever left, the program will always have the potential of exhausting resources even without leaking memory.

    This is why there are all kinds of malloc() substitutes for C, including several with garbage collection. If the program runs for long enough, the vanilla malloc() in most C libraries is simply not good enough.

    --
    It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
    1. Re:Even when... by tepples · · Score: 1

      Unless the chunk you allocate is exactly the same size as the chunk last deallocated, there will be a region of memory that cannot be used. [...] This is why there are all kinds of malloc() substitutes for C, including several with garbage collection.

      I've read about one malloc() replacement that intentionally wastes memory now to save memory later. It splits the heap into several sub-heaps where each allocation is rounded up to a power of 2 bytes in size.

    2. Re:Even when... by BrotherBeal · · Score: 1

      You're looking for this, I believe.

      Buddy Memory Allocation

      --
      I'm disabling ads until because I choose not to reward redesigns that are less usable than "view source".
  48. bring out your dead... by macbeth66 · · Score: 1

    What's that smell? Its like something died.

  49. JRE by Anonymous Coward · · Score: 1, Insightful

    So, not only is it slow to start up, requires a lifetime of XML Hell, and bowing down to the architecture astronauts (remember kids -- it is not a good java program unless you can spot three design patterns for every 15 lines of code!), now they are going to make you pay for the remaining bits to work?

    I am glad I stuck with C++.

  50. Hate to say, I told you so... by tech_fixer · · Score: 1, Interesting

    I said this would happen: http://slashdot.org/comments.pl?sid=1240121&cid=28039069

    Oracle gives away stuff, and then charges for the good features or forbids usage 'till paid. Else, the Oracle Police will come around...

    Good thing they are not part of the BSA, are they? I dont remember, my memory slips... Darn garbage collector, if I only were allowed to use the new one I wouldnt have memory problems!

    Thanks for nothing, Oracle!

    1. Re:Hate to say, I told you so... by mahaman · · Score: 1

      I wouldn't brag about being the one giving them the idea.
      Way to go, genius!

      --
      Mea navis aëricumbens anguillis abundat.
  51. Pick up my garbage weekly by omnichad · · Score: 1

    I already get garbage collection as a paid service. I just set the bags out there, and they pick them right up.

  52. Re:RIP Java..we hardly knew ye. by K.+S.+Kyosuke · · Score: 1

    The truly cool and hip embedded systems run Forth, the one OS that fits an IDE where other systems would not cramp even a bootloader. :-)

    --
    Ezekiel 23:20
  53. It's in OpenJDK too by arthurp · · Score: 5, Informative

    G1 is in OpenJDK and JDK7 as well as the new JDK6. So it's open source. So fear not. I think that as people have mentioned below they are simply trying to protect themselves from people turning on this feature in a production environment and then bitching to them about it.

  54. Re:RIP Java..we hardly knew ye. by Muad'Dave · · Score: 1

    Hardly. Embedded systems can run J2ME fairly well. Remember the DiVX system from Circuit City? That was implemented in Java (write once, run anywhere!) running on a small JVM ported to the processor of the host DVD player. It was easier to port the JVM to the CPU than the app.

    --
    Tiller's Rule: Never use a word in written form that you've only heard and never read. You will end up looking foolish.
  55. Re:RIP Java..we hardly knew ye. by Anonymous Coward · · Score: 0

    It had no good debugger, no usable UI interface

    I think the UI interface of the ATM machine where you enter your PIN number runs Java.

    Hmm.. how much RAM memory would the Java JVM use when I enter my PIN number? And does it support NIC cards?

  56. To View Comment Subjects by kumanopuusan · · Score: 4, Informative

    Just click on the "change" button after the summary and the comment subjects display correctly. Whatever the problem is with the cached story pages, comments.pl is fine.

    --
    Use of the words "good", "bad" or "evil" is almost invariably the result of oversimplification.
    1. Re:To View Comment Subjects by roscivs · · Score: 1

      Thank you!!! That's been bugging me for days (or whenever it started).

      --
      ~ roscivs
    2. Re:To View Comment Subjects by Anonymous Coward · · Score: 0

      Thanks, that works! Highlighting each comment title to read it was getting a bit old :/

    3. Re:To View Comment Subjects by Unoti · · Score: 2, Interesting

      Thanks for this tip!

      Not being able to read the headers and moderator points made me realize just how much it influences how I read slashdot, which is interesting and unnerving...

  57. ABANDON SHIP!!!! by Anonymous Coward · · Score: 0

    eom.

  58. technical details of G1 by dirtyhippie · · Score: 1

    I have a question unrelated to this fuss. How exactly does G1 work, and why is it expected to be "better" (no credit for answers that just say the current java GC is crap).

  59. Hybrid counting-tracing collector? by tepples · · Score: 1

    Garbage collection in Java does NOT use reference counting. Although there are various GC implementations, they are all tracing collectors.

    Would it violate the Java spec to use reference counting most of the time and then use tracing only once reference counting starts to miss cyclically linked garbage? Python does something similar.

    1. Re:Hybrid counting-tracing collector? by HappySmileMan · · Score: 1

      The spec doesn't say HOW it should be done AFAIK, just that it must be done.

    2. Re:Hybrid counting-tracing collector? by nahdude812 · · Score: 1

      Actually I believe in 1.6 it does something along these lines in addition to complete GC's.

      As I understand it, there are three generations of memory: New, Tenured, and Permanent. When objects are initially created they go into the New generation. A thread is constantly sweeping through New and cleaning up what it can. When an object has been in New for 40 or so sweeps it moves to Tenured.

      Tenured is only cleaned up during a full (locking) GC, and this can be scheduled to run on an interval (1 minute is fairly common), triggered to run at certain memory thresholds (may cause problems if your base memory crosses that threshold), or at the application's request (though the Java spec specifically declines to guarantee the request will be honored immediately - but all modern Java environments do so).

      Permanent generation is not GC'd at all; objects referenced by the runtime which will be resident for as long as the runtime is end up in this space (though the specifics elude me).

  60. Can Java garbage-collect other resources? by tepples · · Score: 1

    Java hides the details of memory allocation from the programmer. Objects, strings, etc use memory. When they are first used, Java makes sure that the appropriate amounts of memory are allocated for the item in question. When these items are no longer in use, the garbage collector finds them and frees the memory so that it can be used for other parts of the application.

    So how does it manage resources other than memory? C++ has RAII (not to be confused with RIAA), a pattern of associating resources other than memory to objects. For example, once an open file object in C++ is destroyed[1], the object's destructor automatically closes the corresponding file handle. Is there a way to get a JVM to call finalizers somewhat predictably, or are Java programmers supposed to manage open files, sockets, etc. as carefully as C programmers manage memory?

    [1] This can happen when delete is called on an object held by pointer or when an object held by value falls out of scope.

    1. Re:Can Java garbage-collect other resources? by Kitsuneymg · · Score: 1

      If a java class locks some resource (FileInputStream locks the actual file referred to by a java.io.File object) then it will contain a close() or disconnect() etc function that releases the lock. FileInputStream will call close() during finalization if the programmer hasn't yet. The idiom is: FileInputStream fis = null;
      try {
      fis = new FileInputStream(myFile);
      ...
      } catch(IOException e) {
      ...
      } finally {
      if(fis!=null) fis.close();
      }

  61. Re:suprised???? by Anonymous Coward · · Score: 0

    Sure, that sounded funny.... the problem is, I've worked with C#, former Sun's Java, and Oracle's Java (ie OAS 10g instead of Tomcat, JDeveloper instead of Eclipse). Sun's Java was the coolest, let's guess which, of C# and ASP .Net or Java under OAS 10g, is cooler... and which is costier.
    I'm switching back to C#, on the meanwhile, I, for one, wellcome our new eat-and-resell-everything corporate overlords !

  62. Cya Java by nurb432 · · Score: 1

    Who else didn't expect this to start happening, with all of SUN's OSS work?

    Im not a fan of Java, but even I think this is a bad direction to head. But hey, its oracle, what else would they do?

    --
    ---- Booth was a patriot ----
  63. Compilers targeting microcontrollers? by tepples · · Score: 1

    I see it in the same way it's worth our time to use compilers to write assembly code. Yes people can do it better but some really skilled people can make a computer do it well enough.

    Unless you're targeting an 8-bit CPU, such as a microcontroller or one of those TV game systems based on an NES-style chipset. I don't know of any good optimizing compilers that target such CPUs. Do they exist?

    1. Re:Compilers targeting microcontrollers? by AmaDaden · · Score: 1

      From what I've seen they do. It's just that they tend to run a C and ASM mix and the chips they are written for are not around long enough and not used enough for people to want to bleed every ounce of power out of them with a perfect compiler. You need tend to need ASM to use special chip features and that gums up the optimizer. On this note some chips are designed to run Java http://en.wikipedia.org/wiki/Squawk_virtual_machine.

      But in general, you're right. You still need ASM for somethings (Microcontrollers) just as you are better off using C instead of Java for somethings(Operating Systems). It's just a matter of the right tool for the right job.

  64. Why aren't all video games in managed languages? by tepples · · Score: 1

    If ~95% of C programmers moved to [Java and C#], we'd get less buggy faster running software.

    Then why are a lot of major label video games still written in C, other than Java games using the MIDP API for phones and C# games using the XNA API for Xbox Live Community Games? Would, say, Quake III run faster if it were rewritten in C#?

  65. what's wrong with you guys? by Anonymous Coward · · Score: 0

    You guys are talking about this as if Java was doomed.

    Instead, it's just the free version lacking an extra feature that's not even proven yet. What does G1 do better than the old garbage collector?

    It's like saying that your car sucks now because somebody is selling big spoilers and you don't want to buy them.

  66. Not quite true by Colin+Smith · · Score: 1

    The Garbage Collector is the software the Developers blame after the Systems Administrators blame the developers for writing software which causes servers with 32Gb of RAM to run out of memory and crash.

    HTH

     

    --
    Deleted
  67. Time and memory constraints by tepples · · Score: 1

    Garbage collection is usually faster than manual allocation -- see Urban Performance Legends, Revisited

    But in a game or a media player, can the JVM guarantee to me that the garbage collector will finish before I have to draw a new frame or decode the next chunk of audio? And how well can a JVM, an app, and its resources fit into the 4 MB RAM of a handheld device?

    1. Re:Time and memory constraints by TheRaven64 · · Score: 1

      Are you still living in 1998? Pretty much all modern GCs are concurrent. I think EMACS Lisp is about the only thing still shipping with a stop-the-world GC.

      --
      I am TheRaven on Soylent News
    2. Re:Time and memory constraints by Mr2001 · · Score: 1

      But in a game or a media player, can the JVM guarantee to me that the garbage collector will finish before I have to draw a new frame or decode the next chunk of audio? And how well can a JVM, an app, and its resources fit into the 4 MB RAM of a handheld device?

      4 MB? Check the date on your calendar. ;)

      Java apps run fairly well, even for games and multimedia, on the other kind of G1 (which has significantly more than 4 MB of RAM). They run on the Dalvik VM, not an actual JVM, but they're still written in Java and garbage collected.

      When high performance is needed, the solution is usually to reuse objects to avoid creating garbage in the first place.

      --
      Visual IRC: Fast. Powerful. Free.
  68. Re:suprised???? by multi+io · · Score: 1

    One could argue that once Sun/Oracle Java have sufficiently abandoned their free/OSS Java licensing and made themselves indistinguishable from MS .NET in this regard, the licensing issue no longer works in favor of the Java camp, and thus you might just as well choose your dev environment based on technical merits only, which may lead to different decisions than before.

  69. New stuff tends to cost by davecb · · Score: 1

    Sun used to charge for stuff until the capital cost of it was paid off, then make it either free or just charge for maintenance. And, of course, only in the case of commercial use.

    This looks similar, except that the new thing is part of an old thing...

    --dave (biased, you understand) c-b

    --
    davecb@spamcop.net
  70. And this is wrong how? by Anonymous Coward · · Score: 0

    What is the issue here? Why shouldn't they get some value in return for providing value?

    I don't work for free, and chances are you don't either. It is amusing, in a dark way, to see the level of entitlement that is expected around here. Just because something is downloadable - be it Java or music or movies - doesn't mean that you can appropriate it for free. And for you bearded, unbathed, GNU-tard zealots out there, by free I mean free as in "free deodorant." Might want to check that one out.

  71. Forgetting to close() vs. forgetting to delete? by tepples · · Score: 1

    If a java class locks some resource (FileInputStream locks the actual file referred to by a java.io.File object) then it will contain a close() or disconnect() etc function that releases the lock.

    Then how is forgetting to close() an object in Java any better than forgetting to delete an object in C++? That's one advantage of the reference counting GC in Python compared to the pure tracing GC in most JVMs: you get more predictable calls to the equivalent of finalize(). Python 2.5 and later also has a neat with keyword, which automatically writes the equivalent of a Java finally clause for you.

    1. Re:Forgetting to close() vs. forgetting to delete? by alannon · · Score: 1

      The difference is that Java -will- close() the resource -if- the object does get finalized and GCed. At least for FileInputStreams and Sockets (I think).

      There is no (non-deprecated) way of guaranteeing that a finalizer will ever actually be run, though. Generally speaking, finalizers should only be used as a backup 'safety-net' when an object holds resources that should be cleaned up. When it does, it should log a warning if it finds its resource not already cleaned up. Finalizers are not destructors, and woe be to any developer that uses them as such.
      C# also has a 'with' keyword, in conjunction with, I believe, the ICloseable interface. I find it to be a handy piece of syntactic sugar and do wish that Java would offer it. Oh well.

  72. slowly takes another sip of the koolaid... by revlayle · · Score: 1

    ...and this is why i use .net for my development. yes, the OS is not free, and the GOOD .net dev tools are not free. But the entire engine and framework are a giveaway beyond that and consistent... no weird licensing stuff with using the framework.

    1. Re:slowly takes another sip of the koolaid... by toriver · · Score: 1

      Yeah, GPL (the license covering OpenJDK) is sooo weird.

  73. And Bill Gates gets his wish by GomezAdams · · Score: 1

    This signals the beginning of the end of Java. I will no longer use or support Java that has now become essentially closed source or will be soon. Gates hates Java and this is the start of the death spiral from being one of the most popular languages to being marginalized. Soon that wretched Visual Whatever will be more prominent and that will be that for Java. I'm still sticking to Perl and JavaScript for now for web apps. But as I said... goodbye to Java (Topcat, Websphere and Weblogic too) and Sun can just go fade into the sunset.

    --
    Too lazy to create a sig...
    1. Re:And Bill Gates gets his wish by Anonymous Coward · · Score: 0

      I will no longer use or support Java that has now become essentially closed source or will be soon.

      You moron. Java is far from closed source, it's GPL. Did you even know that for many years it was closed source, until Sun opened it up? If you had bothered to read anything more than Slashdot's incredibly biased summary, you'd know that anybody can enable this feature with a couple of command line flags, for free. It's experimental and Sun will only provide support to paying customers. Is that really so horribly wrong? Is Sun now a member of an evil empire that will enslave your children and force them to only use Windows?

      Topcat

      It's "Tomcat". Do you know anything about what you're talking about?

    2. Re:And Bill Gates gets his wish by jjohnson · · Score: 1

      Hyperventilate much?

      --
      Anyone who loves or hates any language, platform, or manufacturer, doesn't know what they're talking about.
  74. Wait, this is great news! by mordejai · · Score: 1

    Especially considering I'm a Senior .NET developer...

  75. Re:Why aren't all video games in managed languages by styrotech · · Score: 1

    Most software isn't actually games. Shocking, I know.

    And who really cares if a game crashes anyway?

  76. it's FOSS so what's the issue? DIY! by Device666 · · Score: 1

    The open source community will be annoyed by not having a cool garbage collector for their open source Java. This probably means that some talented slashdotter will see the challenge of building an open, coole and better garbage collector.

  77. Re:Why aren't all video games in managed languages by tepples · · Score: 1

    And who really cares if a game crashes anyway?

    The arcade operator cares, as a staff member has to walk over to the machine and power-cycle it. I've seen this happen on the In the Groove machine at Putt-Putt in Fort Wayne, Indiana. And the player cares about staying connected to an online game.

  78. Better than the JCE experience by duncan+bayne · · Score: 1

    Well, at least users won't have to download a ZIP and extract several JARs into the JVM path in order to have it work. Not that I'm bitter about JCE or anything.

  79. Re:RIP Java..we hardly knew ye. by binarylarry · · Score: 1

    Or a better example, remember Bluray? or the PS3? Java runs there too.

    --
    Mod me down, my New Earth Global Warmingist friends!
  80. Re:.Net ROCKS!!! by cptnapalm · · Score: 1

    You have convinced me!!! Please send me a link for OpenBSD on UltraSparc as I can't seem to find it on Google...

  81. Re:suprised???? by Anonymous Coward · · Score: 0

    *cough*Windows ME*cough*

  82. Car Analogy by El_Oscuro · · Score: 1

    Here is one based on an old hot-rodding maxim: Java, Oracle, Good. Pick 2.

    --
    "Be grateful for what you have. You may never know when you may lose it."
  83. JS's real roots are in Self and Scheme by mr_stinky_britches · · Score: 1

    Javascript is much closer to Ruby than it is Java (but the built in objects aren't generally as rich, and people scream and whine about the prototype based object system).

    I'm going to have to call you on this, because last time I checked, I recall JavaScript being closer to some other languages (of the functional paradigm, IIRC).

    From the Wikishidia article on JavaScript:

    JavaScript is a scripting language used to enable programmatic access to objects within other applications. It is primarily used in the form of client-side JavaScript for the development of dynamic websites. JavaScript is a dialect of the ECMAScript standard and is characterized as a dynamic, weakly typed, prototype-based language with first-class functions. JavaScript was influenced by many languages and was designed to look like Java, but to be easier for non-programmers to work with.

    JavaScript, despite the name, is essentially unrelated to the Java programming language even though the two do have superficial similarities. Both languages use syntaxes influenced by that of C syntax, and JavaScript copies many Java names and naming conventions. The language's name is the result of a co-marketing deal between Netscape and Sun, in exchange for Netscape bundling Sun's Java runtime with their then-dominant browser. The key design principles within JavaScript are inherited from the Self and Scheme programming languages.

    (Emphasis mine, added for clarity/ease of reading)

    And for the record, I dislike wikipedia as much as the next guy, but the core fact remains:
    The real roots of JavaScript are from the Self and Scheme programming languages!

    --
    Censorship is obscene. Patriotism is bigotry. Faith is a vice. Slashdot 2.0 sucks.
    1. Re:JS's real roots are in Self and Scheme by maxume · · Score: 1

      So between Ruby and Java, which one is closer to Scheme, in your opinion?

      (As an aside, I don't really see what anything you posted has to do with the part of my post that you quoted; it certainly doesn't contradict it)

      --
      Nerd rage is the funniest rage.
    2. Re:JS's real roots are in Self and Scheme by TheRaven64 · · Score: 1

      The grandparent is correct. JavaScript is Self semantics with Java-like syntax. Ruby is Smalltalk semantics with Perl-like syntax (yes, apparently someone thought that was a good idea). Ruby, Smalltalk, Self, and JavaScript are all members of the Smalltalk family. So is Java, but a much more distant member.

      --
      I am TheRaven on Soylent News
    3. Re:JS's real roots are in Self and Scheme by mr_stinky_britches · · Score: 1

      Thanks for clearing that up!

      --
      Censorship is obscene. Patriotism is bigotry. Faith is a vice. Slashdot 2.0 sucks.
    4. Re:JS's real roots are in Self and Scheme by mr_stinky_britches · · Score: 1

      (obviously I didn't know about the actual similarities with Java)

      --
      Censorship is obscene. Patriotism is bigotry. Faith is a vice. Slashdot 2.0 sucks.
  84. Re:Why aren't all video games in managed languages by publiclurker · · Score: 1

    Anyone here old enough to remember the video game Beezer? That game had a programming bug where, if you were a fairly good player, you could cause the game to hang every time. I used to get free games every day until the arcade employees got together and figured out what was happening.

  85. Not quite.. by Anonymous Coward · · Score: 0

    In Java, the only kind of memory you can allocate is "objects"... so he was accurate about that part.

    Also, "used" means something else and is generally undecidable. "referenced" is a weaker condition and is in fact what garbage collectors use to decide if an object is "dead" or not (i.e. can safely be collected).

    1. Re:Not quite.. by nog_lorp · · Score: 1

      Of course. But while you are at it... the only kind of memory that gets garbage collected is heap memory, so why not mention that?

      Oh wait... "As a non-programmer". When you are explaining things for lay-people you don't need to include every technical detail...

  86. Irrelevant by hackus · · Score: 3, Insightful

    The entire Java Stack has long since been opened up. The community essentially owns it now. What Oracle does with "Java" I could care less.

    Anything that is worth while to build design and construct/maintain Java applications and VM's is all open source.

    If they want to fork and become irrelevant that is there choice.

    -Hack

    --
    Got Geometrodynamics? Awe, too hard to figure out? Too bad.
    1. Re:Irrelevant by z121212mlmiac · · Score: 1

      But the only Java VM installed on most Windows users' machines is the Oracle version. There's an extra distribution step, just like with the different versions and implementations of .NET.

  87. Re:Why aren't all video games in managed languages by BikeHelmet · · Score: 1

    Most commercial games seem to be written primarily in C/LUA.

    The engine is mostly C/C++, but every part of it has tight bindings to LUA for the regular non-programmer game-designers.

    I mean, there's literally thousands of games using LUA, which I agree is more than Java, and probably more than C#.

    Regarding your Quake 3 statement - no, it'd be slower in C#; but it might not be slower in Java.

    Quake2 ported to java ran very fast even on last generation hardware and JVMs. I'm curious how well it would run with a newer JVM. I remember someone testing it on a weak machine(I think it was a 300mhz P2 laptop?); he found that although memory usage was higher, it actually had a higher framerate, indicating that its CPU usage was probably lower.

  88. Oracle=for profit by Anonymous Coward · · Score: 0

    Oracle is very much a for-profit company. The CXO, the boss, everyone wants money. Lots n lots of money! More money! Gimmee more! More! Lots more! There is a reason why MySQL has already forked. If Oracle can do this to Java, what do you think about a software application (a database!) that competes with their main product? You don't have to think hard, nor for a long time. Java has started down the slippery slope. Give it away? No! It shall be replaced with Perl/Python/Ruby, although the first two are the most generic and application agnostic (IMHO). Java as a language is now becoming smaller. Its best days were before Microsoft abandoned it. It suffered, but continued on. Sun saw Java as one of those really great, run-anywhere languages that didn't need to be recompiled. It was always slow (byte code yadda yadda too). Now that Oracle has it, the bell is tolling for Java. First you have to buy. Next you will have to spend a lot. Then patches will cause version splits between those who paid for new versions versus those who paid for old. The community of users becomes fragmented, and much smaller. The writing on the wall becomes much more clear to more people. Finally the user base shrinks enough that Oracle decides death is better than maintenance. Timeline? 6-10 years. If they get stupid and fast, 6 years. The slow death will take 10 years.

  89. now that the java-haters have cleared out by recharged95 · · Score: 3, Interesting
    So basically what we're talking here is:
    • Use Sun's JDK and want support (i.e. you don't figure out the solution)? Pay for it.
    • Use openJDK and want support (ie.. you figure it out)? Have fun.

    .

    Sounds like any other typical OSS business model from Ubuntu, Novell, RedHat, IBM, and even Microsoft.

  90. So... by longbot · · Score: 1

    Does this mean no more 400K apps that eat 120MB of memory while running?

    --
    I don't suffer from insanity, I enjoy every minute of it! --Longbottle
  91. For the record: by soldoutactivist · · Score: 1

    I've always disliked Java. And ruby. Javascript/Actionscript are based on ECMAscript, not Java. Maybe Java is based on ECMAScript, but knowing that would mean I spent enough time with the language beyond realizing it was a pile of crap.

    --
    The downside of being killed is the upside of being dead.
    1. Re:For the record: by Anonymous Coward · · Score: 0

      Javascript/Actionscript are based on ECMAscript

      That's backwards. Take JavaScript as released, have some obscure standards body rubber stamp it and write a clumsy specification for it. That's all ECMAScript is.

      not Java.

      That's just wrong. What part of "ECMAScript syntax intentionally resembles Java syntax" did you not understand?

    2. Re:For the record: by Vintermann · · Score: 1

      Since you know so little about Java (based on ECMAscript? get real!), your dislike of it can hardly be based on anything reasonable.

      --
      xkcd is not in the sudoers file. This incident will be reported.
  92. IMHO... by Anonymous Coward · · Score: 0

    OK...G1 is an experimental feature, but the release notes states CLEARLY that 'Although G1 is available for use in this release, note that production use of G1 is only permitted where a Java support contract has been purchased.'

    Since obviously Oracle should monetize Java, it's getting clear, day by day, that Java's future will be the same MySQL had when Sun bought it. They will be releasing to the community experimental, not up-to-date versions, and let pass a lot of months until we get a good version. In other words: THEY WILL KILL JAVA! But, obviously, like MySQL, a lot of forks will appear, and round and round we go. This is really sad, considering the importance of Java on business and opensource world.

    I'm not being sensationalist like many people maybe thinking reading this post, but unfortunately, companies like Oracle, will never understand the true opensource world facilities and how to make money at the same time supporting them correctly.

    Shame on you, Oracle!

  93. That actually kind of happend... by Anonymous Coward · · Score: 0

    Have a look at whatever you find here:
    http://www.google.com/search?q=naples+garbage+site%3Abbc.co.uk
    Reality more bizarre than fiction and all that.

    1. Re:That actually kind of happend... by Anonymous Coward · · Score: 0

      Obviously, you're not from the US, where it happens everyday to hundreds of small businesses.

  94. The Oracle Stamp!! by rawjeev · · Score: 1

    If At all this is true then, screwing-up-of-java has just begun. We ditched our plans to use berkeleydb precisely for similar reasons after Oracle took over.

    --
    Live Life Raw
  95. Refridgerator analogy by SlothDead · · Score: 0

    Here's an analogy for what a garbage collector does:

    Vocabulary:
    People: program
    Food: data object
    Refridgerator: memory

    Let's say you live together with some friends and you share a refrigerator with them. No-garbage-collector programming languages are like this: Everyone has to keep track of what belongs to him and throw out his rotten food. If someone accidentally forgets one of his food items it will rot in there forever. If this happens more often the refridgerator will be filled with garbage and you can't use it for real food any more. That's called a memory leak.

    Garbage collection works like this:
    1. Ask everyone to mark the food they know belongs to them.
    2. Throw out every unmarked food.
    (3. remove the markings, so they won't cause troubles the next time you do a garbage collection)

  96. You can help stop it happening! by bigsteve@dstc · · Score: 1

    If you are a Java developer and you are concerned that open Java will die, you can do something about it by joining one of the open source java platform projects. For example JNode: http://jnode.org/ is building a Java based operating system that runs on a bare metal PC (x86 or x86_64).

  97. The 'Oracle Touch' comment is absurd by Anonymous Coward · · Score: 0

    I'm sure you folks are all having a fine time with the Garbage Collector discussion which, while interesting, has nothing to do with the substance of the original post.

    When one large publicly-held company (the "purchaser", like Oracle Corporation in this case) announces the purchase of another large publicly-held company (like Sun Microsystems in this case), a long period of time elapses before the purchaser takes operational control of the of the other company. During this time, regulatory approvals are obtained and lots of other technicalities are addressed. And during this period, both companies are forbidden by law to explicitly cooperate with the other. Now, I'm not so naive that I think this would prevent all cooperation in cases where it is really significant. But the idea that somebody at either Oracle or Sun would engage in illegal shenanigans over a triviality like this GC feature is just absurdly silly. These companies both routinely do deals involving millions of dollars. How much money is at stake over this GC issue? $9.98? You think somebody in a high-paying management position at either one of these companies would break the law by colluding over this $9.98, or whatever the real number is? Get real. These are big boys, not the babies who debate this stuff on /. and make all the ".net rocks" comments. When Oracle takes control of Sun, you can start flaming Oracle for the way it manages Java. In the meantime you have an opportunity to grow up and get a clue.

    1. Re:The 'Oracle Touch' comment is absurd by Anonymous Coward · · Score: 0

      What makes you think the "Java SE for Business" royalties are only going to be $10, rather than several orders of magnitude higher?

  98. Linux UNIX by jimfrost · · Score: 3, Insightful
    Linux > Unix.

    Other than cost, I'm curious as to what you are measuring.

    It's not performance. Solaris 10 on a PC outperforms Linux when stressed, sometimes by huge margins. It's not a complete blow-out with modern kernels, like it was in the 2.4 days, but it's still significant -- and there are corners where it really still is a complete blow-out (like: What does fsync() do?).

    It's not stability. Again, Solaris 10 is much less likely to crash or go all wonky when stressed, and AIX is similarly robust. And again there are corners here that can have large impact on reliability of applications (e.g. I recall some annoyances with direct io, although the specifics are escaping me at 3am).

    It's not core features, by and large Linux lags the commercial UNIXen in that arena (e.g. Dtrace), which isn't really surprising since Linux is effectively a clone.

    Having said that, there are certainly UNIXen that do not stand up so well to Linux (*cough* HP/UX *cough*), but there certainly exist UNIXen that are generally superior.

    Of course, a lot depends on what you're doing with the system. If I need to push the system as hard as possible then I want Solaris if it is an option. If I am looking for general usability I find Linux preferable. The differences in the latter case are often minor (like the -c argument to "script") but taken en-masse they make for a more pleasant experience.

    That's the way I see things today. I am not at all sure we won't see Linux pull into the lead over time -- it is getting better and better with age, and most UNIX systems appear to be seeing improvement stagnation. (And that may well be universal soon: What are the odds that Solaris doesn't see its R&D budget chopped under Oracle?) In summary I would generally prefer to do development on Linux, but want production on Solaris. Best of both worlds, at least today. It may be telling, though, that on my personal server systems I run Linux even when I am concerned about performance -- the ongoing administration is significantly easier it you pick the right Linux distribution, and it isn't picky about hardware like Solaris is, and the tool suite is free as in beer without any extra effort.

    Except on the desktop. There MacOS is supreme IMO. All the goodness of UNIX, plus stellar UI and commercial applications. I dunno how it does in stress situations (almost nobody buys Apple servers) but it's a great desktop system.

    --
    jim frost
    jimf@frostbytes.com
  99. wonderful! by Weezul · · Score: 1

    Java sucks mightily. So any move towards killing Java off is good news. :)

    --
    The Christian religion has been and still is the principal enemy of moral progress in the world. -- Bertrand Russell
  100. Sourcesafe is a lousy benchmark by jimfrost · · Score: 1
    Sourcesafe is horrible; it's not reasonable to take the worst of the commercial world and compare it to the best of the free software world. Instead, compare git to a decent commercial system, e.g. Perforce.

    I note that I can't personally compare git to Perforce, although from quick Google checks it looks like the two are roughly comparable with Perforce winning out in some key areas (to me, at least) like native Windows support and GUI, to say nothing of documentation. In any case git is not clearly superior even technically according to numerous comparisons I found.

    --
    jim frost
    jimf@frostbytes.com
    1. Re:Sourcesafe is a lousy benchmark by Lennie · · Score: 1

      "Perforce is a client/server system. The server manages a central database and a master repository of file versions."

      "Git is a free distributed revision control"

      To get a cruel comparison and an idea of what distributed is useful for, you should possible watch this video by Linus himself:

      http://www.youtube.com/watch?v=4XpnKHJAok8

      distributed is really really useful.

      --
      New things are always on the horizon
    2. Re:Sourcesafe is a lousy benchmark by jimfrost · · Score: 1
      I don't disagree that git has some significant advantages here, although I do think that practically speaking they're not that dramatic. I'm always on the Internet when I'm developing[1], so there is little practical difference between the distributed and client/server models.

      (By the way, I hadn't known about this video and I appreciate the pointer; sometime when I have an hour to spare I'll watch the whole thing.)

      I think cheap branching is more interesting; Perforce branching is too expensive IMO. (I note that there are commercial products that are good in this area, too, like AccuRev.)

      The two places I'd be worried a lot about git are in merge management (how easy is conflict resolution?) and scalability. I know git has trouble with the latter, and I suspect it isn't all that great at the former. I have regularly been impressed with how well Perforce manages automatic merges with minimal conflicts that need to be resolved. In a highly active codebase it's hard to overstate the value of reducing the number of merge conflicts that have to be handled manually.

      Aaanyway this was just a long-winded way of saying that I still don't think there is a clear winner.

      --
      jim frost
      jimf@frostbytes.com
    3. Re:Sourcesafe is a lousy benchmark by Lennie · · Score: 1

      "In a highly active codebase it's hard to overstate the value of reducing the number of merge conflicts that have to be handled manually."

      Euh, this is used for the Linux kernel development.

      From an article in 2008 (http://ldn.linuxfoundation.org/how-participate-linux-community):

      at a rate approaching 1,000 changes ("patches," or "changesets") per day.

      And I've seen number (although I can't find them right now) that kernel development rate increases over time.

      Merges is actually the one thing Linus cared most about when he created git.

      --
      New things are always on the horizon
    4. Re:Sourcesafe is a lousy benchmark by dcam · · Score: 1

      Comparing perforce to git is a poor comparison. git is a distributed VCS. If you want a commercial equivalent to git, look at bitkeeper. svn and cvs are better comparsions to source safe.

      --
      meh
  101. GCC versus commercial compilers by jimfrost · · Score: 1
    I'll second this. There are a lot of things to like about gcc, but highly performant code is not one of them. This is especially true once you get off of x86 targets.

    Gcc was never intended to be a particularly good compiler in this respect, although it did beat out the AT&T cc quite handily when it was introduced ... much to the surprise of Stallman, as I recall. Of course, that was a particularly stupid compiler and virtually all of the commercial UNIX providers replaced it with better stuff.

    Having said that, I think it's the rare case these days where the difference matters (on the platforms where gcc is pretty good anyway, it's terrible on some of them) and gcc still sees active development whereas there doesn't seem to be a whole lot of effort going into commercial compiler development nowadays (with the notable exception of Microsoft).

    --
    jim frost
    jimf@frostbytes.com
  102. Apache versus whatever by jimfrost · · Score: 1
    Ahh, I've been pointing out that other commercial vs open source comparisons here are generally being done against inferior products, or the writer is just confused, but Apache is one case where I think the open source product is best-of-breed in so many ways.

    IIS does have some things going for it, in particular it's a lot easier to set up and you gotta love the integration with the development tools, but Apache is certainly faster and more robust and isn't limited by the lousy performance of Windows and has a whole lot more extension options. There is a good reason why there really aren't any viable competitors on UNIX.

    So ... kudos, you identified a case where open source truly does beat the competition.

    --
    jim frost
    jimf@frostbytes.com
    1. Re:Apache versus whatever by jimfrost · · Score: 1
      Replying to myself is probably bad form, but it occurs to me that Tomcat is similar, and JBoss too although the latter is a little harder for me to consider truly open source. For sure I'd rather use these products than WebSphere or WebLogic. I am not nearly so enamored with the whole development cycle versus Microsoft's tools though; Eclipse has a whole lot of strikes against it in my book.

      Even so it seems to me, now that I'm thinking about it, that there are a lot of cases in web development where the open source stuff is pretty darn nice. Spring framework, for instance ... although this lagged behind ATG's Dynamo, which has a startlingly similar design, by quite a few years.

      --
      jim frost
      jimf@frostbytes.com
    2. Re:Apache versus whatever by Lennie · · Score: 1

      As a guy who handles webservers in a "production enviroment", I'd just like to say the Windows process model is the problem. Threads are much cheaper than processes on Windows. I think the Linux guys actually do it the right way, processes should be cheap, threads are not as important. This is an old design decision from when Windows was just doing desktop, I guess. Or someone believed some academic that threads are the next big thing or something. I don't know, but having code running on a server in seperate processes, which go away after a while instead of threads in one process, is such a much better model for stability. Because we all know people make mistakes, one of them could mean it crashes the process or leaks memory. With seperate processes you just don't have that problem. Having just the core like with lighttpd as just one process is ok, because it just does one thing and one thing right. It uses seperate processes for running php for example, which get reused for a while or can be seperately killed if something goes wrong.

      Because of the process model on Windows, even Apache uses a pool of threads their, which has the same problems. That's the real reason why Apache on Linux is better then IIS on Windows. Stability and ease of problem resolution. The IIS devs, I guess, also figured this out and created application pools because of this, but I still don't see as much "recycling" (as they call it). Maybe this is because of the whole object-orientated development model they usually use, it's what makes startup times slow, it's the same problems you see with Java. Java-programs also need to load many seperated things and they take up memory and that memory is hardly ever reclaimed.

      Having seperate processes is also good for security, when you want to confine some code which deals with outside input.

      Even IE now is trying to use a multi-process model, like Chrome, because of these kinds of things. IE has so far mostly failed at doing so because again startup performance of processes is so slow. And you see it, every time you open a new tab.

      --
      New things are always on the horizon
  103. Mod parent up! by Anonymous Coward · · Score: 0

    I think first post would be a sprint event, and the anti-microsoft rant would be long distance.

    As for "Goatse hurdling", I'll leave that open for discussion.

  104. There is also the problem of finalization order. by master_p · · Score: 1

    In Java, finalizers run in random order, and therefore cause a great problem for resource management. C++'s deterministic destruction is much better for resource management.

  105. Java is faster than C++. by ge0ffrey · · Score: 0, Troll

    Java is faster then C++ for any non trivial use case. This is because of 2 reasons:
    - It compiles more natively then C++: C++ is compiled for just "Windows", while Java is hotspot compiled at runtime (where necessary, after a startup delay) to "Windows XP SP3 Intel processor".
    - A garbage collector is faster for non-trivial use cases then malloc because it can free entire chunks of memory at once. When someone walks into your living room with muddy shoes, it's more efficient to mop the entire room then it is to clean only the footprints with a toothbrush.

    As a planning solving programmer, I 've seen this in practice.
    Planning problems are problems that run for hours and do virtually no IO, they simple take up all the CPU power and evaluate an exponential of billions solutions.

    Real-world use case performance competitions prove that Java implementations are faster then C++ implementations:
    - Terrabyte sort benchmark: http://sortbenchmark.org/
    - International timetabling competition: http://www.cs.qub.ac.uk/itc2007/

    Java does have downsides over C++: it has a terrible warmup time and it loves to grab and hold lots of RAM, because garbage collectors work faster with more RAM. So in use cases like gedit/kate/jedit where startup time is more important than performance, I'd stick with C++.

    1. Re:Java is faster than C++. by Spacelem · · Score: 1

      I don't use Java, but my supervisor uses it when he needs nice and interactive applications (although given his physics origins, he usually uses Fortran for really high performance). I wrote a simulation in C++ that models the spread of disease among a set of populations, and allows things like migration and culling. These simulations can take a very long time to run, although the memory requirements are quite low.

      I don't really have the time to recode my simulation, but I'm tempted to try, just to see how Java compares with C++.

      Note that my coding style is very C, rather than C++, and I used C++ because I found it better at handling variable length, multidimensional arrays, and for its overloading of functions. I don't really know how I'd start jamming objects into the simulation for Java's sake, so it would probably remain pretty much the same style (my supervisor says in his experience Java is much faster when you leave out the objects). Cue pitchforks and torches from OOP fans.

  106. Re:Linux UNIX by turgid · · Score: 2, Insightful

    Solaris is a specific case of original, commercial unix which went open source a few years ago.

    Back in the '90s, when Linux distributions started to get really popular, the Linux kernel and the distributions overtook many of the old commercial unices (e.g. SCO Unix, AIX, IRIX...) and effectively killed them.

    Linux was cheaper (free), the user-land was more user-friendly (GNU tools, GNOME, KDE...), and truly cross-platform.

    Linux's and GNU's openness and freedom was and is the key to its success. There are now millions of people around the world proficient in Linux/Unix who wouldn't have been for this very reason. There are people like me who made it all the way to being a Software Engineer simply by having a Linux system in the home to learn on.

    Solaris is still ahead by a long way on high-end technical features like ZFS and is quite possibly the only commercial unix that has a future now.

    I have 3 Solaris 11 UltraSPARC boxes in my house just now: a SunBlade 100 and two Ultra 80s (4 CPU).

  107. "Run everywhere" by jimfrost · · Score: 1
    Write once, run anywhere = very cool. Always backwards compatible = very cool.

    Hah, we always harped on Sun for that statement. We said it was "write once, debug everywhere." Not so much for server software, with a few notable exceptions where OS differences easily showed through the Java APIs, but UI development was certainly not "run anywhere." (Not that C++ was better by a long shot, but at least when you did it in C++ there was no expectation from your boss that it might actually work.)

    As for "always backward compatible" ... you must be joking, or inexperienced. I don't think there was a single significant JDK release from 1995 to 2004, when I was focused almost exclusively on Java, where I didn't have to fix a bunch of stuff. Swing in particular tended to find new and irritating ways to not work with existing code. Again server code wasn't nearly as bad, but I think that's because it tended to touch a lot fewer core libraries. I don't recall anything that was difficult to fix, usually just tweaks here and there, but I assure you I got familiar with System.getProperty("java.version").

    I see that one of the follow-on comments claims that this is due to poor coding, but I didn't find that to be the case. I saw behavioral differences in libraries that were sometimes inexplicable, although more often it was that they fixed bugs in the libraries. There were a lot of bugs outside of the core classes, especially in stuff like Swing and JavaMail. I never had to write a lot of version-specific code, but it certainly happened often enough that you couldn't haphazardly take an upgrade of the runtime system. You could pretty much count on finding a couple of issues.

    Anyway this shouldn't be taken as a damnation of Java, which is worlds better than everything else I've used in both respects (although I have limited experience; for instance, I have never tried Smalltalk), just a note that it's not all sweetness and good in these respects.

    --
    jim frost
    jimf@frostbytes.com
    1. Re:"Run everywhere" by szundi · · Score: 1

      We've been using java quite deeply on a project. We never tested it on any other platform than Ubuntu linux and Windows XP, and I can tell you never had any problem with our application. We just took seriously the notes in the documentation speaking about usage of the classes and cross-platform programming concerns. Java is not perfect but has its advantages.

  108. No, *you* try it... by Anonymous Coward · · Score: 0

    we cannot afford to.

  109. Nintendo DS by tepples · · Score: 1

    4 MB? Check the date on your calendar. ;)

    Fourth quarter 2004: Nintendo DS first released worldwide. RAM: 4 MB; VRAM: 656 KB.
    First quarter 2009: DS still sells over 5 million systems per quarter, let alone games.

  110. Re:Linux UNIX by jimfrost · · Score: 1
    I don't disagree with any of what you said except that AIX is a long way from dead. It's still quite popular, much to my chagrin.

    I was going to argue that Linux' low cost was the key to its early success, but the more I thought about it the more I believed that it wasn't low cost alone that did it -- or even that it was the most free. It wasn't the most free, and still isn't; that crown goes to BSD no matter how you slice it, whose license is the next best thing to public domain.

    I know Stallman likes to tout the "freedom" aspect of the code, but really the GPL works more like a traditional patent cross-licensing agreement, where parties share each others' technology because otherwise they wouldn't be able to ship a product at all, rather than being truly unlimited.

    The GPL takes this to the extreme, forcing unlimited cross-licensing of any derivative work ... not only to a select few who can buy into the club, but anyone who has any desire at all to be involved.

    This avoids the software version of the Tragedy of the Commons, which BSD has always seen: Lots of products use(d) BSD, but because everyone's changes were proprietary they were almost always kept in-house. BSD development therefore got little advantage from commercial development and the pace of its improvement has been slow to say the least. (It was further hampered, very significantly IMO, by a bad case of NIH in the core maintainers.)

    The fact that commercial entities, who had the motivations and money to do major work, had to share their Linux improvements certainly led to major advances that have created a feedback cycle whose power is obvious at this point. This cycle continues not because the software is free as in freedom, but because it is not -- it comes at the cost of technology cross-licensing.

    --
    jim frost
    jimf@frostbytes.com
  111. Re:Linux UNIX by turgid · · Score: 1

    The fact that commercial entities, who had the motivations and money to do major work, had to share their Linux improvements certainly led to major advances that have created a feedback cycle whose power is obvious at this point. This cycle continues not because the software is free as in freedom, but because it is not -- it comes at the cost of technology cross-licensing.

    Absolutely. You hit the nail on the head. The real freedom is for the end-user in GNU software, as opposed to BSD where it is freedom for the developer.

    It's been wildly successful. Linux's success (the kernel and distributions) is testament to that. The thing is, there are still people out there who don't get it :-)

  112. Re:Linux UNIX by jimfrost · · Score: 1
    I don't think that there are many end users who give a whit about the freeness of the code beyond free-as-in-beer. I'd welcome examples to show that I'm wrong, but my experience is that they care about what it costs and not about code availability.

    That free-as-in-beer and forced code contribution work hand in hand to benefit the end user is unquestionable, but I don't know many who make that an overriding (positive) concern for picking one product versus another.

    --
    jim frost
    jimf@frostbytes.com
  113. Seriously JavaScript? by twoHats · · Score: 1

    JavaScript is an abomination on the order of GW BASIC.

  114. KYAGB Java! by woboyle · · Score: 1

    Say goodbye to Java. This is sounding its death-knell. Time to move the Eclipse project to some other software platform I think (if only that were feasible). :-(

    --
    Sometimes, real fast is almost as good as real-time.
  115. G1 by guliverk · · Score: 1

    G1 must be usefull...

    --
    JMule user : http://www.jmule.org
  116. Wrong reading? by Anonymous Coward · · Score: 0

    I found that the note is not right!

    The release notes does not state: "Although G1 is available for use in this release, note that production use of G1 is only permitted where a Java support contract has been purchased."

    Indeed, it states "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, it is not recommended for production, because it is an early release. Nothing to do with contract permission.

    False catch :)