Advertisement

Is Java struggling?

Started by April 16, 2012 06:44 PM
21 comments, last by Dmytry 12 years, 5 months ago
I believe there are about 2 billion Java mobile devices out there (J2ME), as well as the Android flavour of Java on top of that, Android being the largest platform after S40 (S40 being a platform that uses J2ME anyway).

Even if we restrict to traditional non-mobile uses of Java
  • , I don't see any evidence of a decline.

  • I do find it a bit sad that, given Java's originally intent of being write once run anywhere, we now have three incompatible flavours of Java, which I believe aren't even source compatible due to different libraries. Ironically even C++ can be more portable between desktops and mobiles like Android and Symbian if you use a toolkit like Qt. But still, as a language, Java is still perfectly viable.
  • http://erebusrpg.sourceforge.net/ - Erebus, Open Source RPG for Windows/Linux/Android
    http://conquests.sourceforge.net/ - Conquests, Open Source Civ-like Game for Windows/Linux


    I got an email today with the following

    [font=garamond,serif]· 3-5 years of UNIX experience[/font]
    [font=garamond,serif]· Experience in standard lifecycle development methodology[/font]
    [font=garamond,serif]· Will be hands on and required to cross train java developers to learn c++[/font]

    [font=garamond,serif]I'm not sure of the company, but it looks like another company coming back to C++ after wandering around for awhile. [/font]


    [font=garamond,serif]Brian[/font]
    [font=garamond,serif]Ebenezer Enterprises[/font]
    [font=garamond,serif]http://webEbenezer.net[/font]

    So you got an email about a job posting looking for Java and C++ developers, and you got "Java is struggling" from that? Because one posting is looking to cross train Java and C++ developers, you seriously came to that conclusion?

    And do you really manually type "Brian Ebenezer Enterprises http://webEbenezer.net" into your posts? (this isn't an attack... it's just... weird when people manually type a signature... seeing as there's a signature option on your profile...)
    [size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
    Advertisement

    So you got an email about a job posting looking for Java and C++ developers, and you got "Java is struggling" from that? Because one posting is looking to cross train Java and C++ developers, you seriously came to that conclusion?
    [


    I wondered based on the part about training people with Java experience to learn C++. In the past it was the other way around!
    Garbage collection isn't about whether or not you are capable of cleaning up after yourself; especially when the primary non-garbage collected language allows you to redefine everything that lets you clean up after yourself. After all, you don't drive all your garbage to the dump/recycling center despite probably being perfectly capable.[/quote]
    The analogy would work except that taking my trash to the end of my street is more efficient that driving it to the nearest recycling center, whereas automatic garbage collection is in general less efficient that manual memory management (not that there's a huge gap, GC's are getting better but it's still unacceptable to have an app randomly freeze for two seconds like I constantly see in java apps) since you know exactly what needs to be deleted at any given time and don't need to rely on more or less advanced heuristics to work it out for you.

    I see your point though, and it also depends how the OS handles memory management itself. There's a lot of variables involved but in general GC's are just one more incentive for poor programming design and crappy performance. Perhaps if people understood garbage collection is not a feature but a tool to be used only when needed it would be better.

    “If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”


    The analogy would work except that taking my trash to the end of my street is more efficient that driving it to the nearest recycling center
    [/quote]

    If we are going to use that analogy, garbage collection would be like having a robot that is constantly watching for trash in your house, pick it up, and eat it -- which would be more efficient than having to look through your house for trashes manually, pick it up, put it in the bin, and taking it out to street.

    not that there's a huge gap, GC's are getting better but it's still unacceptable to have an app randomly freeze for two seconds like I constantly see in java apps)[/quote]

    Where did you see this? Having been using Java professionally for the past 6 years, working across multitude of devices from 200KB Nokia cellphones to 8GB PCs, I have never seen a Java app freezes for 2 seconds because of GC. With the exception of one Samsung cellphone (one, out of 1000 cellphones out there I have worked on), but that's because of poor JVM implementation. Not Java's fault, not certainly GC's fault, but Samsung's fault.



    since you know exactly what needs to be deleted at any given time and don't need to rely on more or less advanced heuristics to work it out for you.
    [/quote]

    GC is not just about deleting your unused objects. As a matter of fact, I wouldn't call it a garbage collector anymore, but more like a "memory manager". It handles memory fragmentation for you.



    There's a lot of variables involved but in general GC's are just one more incentive for poor programming design and crappy performance. Perhaps if people understood garbage collection is not a feature but a tool to be used only when needed it would be better.
    [/quote]

    It is a tool, and it is needed all the time, because if you wait until your 4GB memory is full then garbage collect it, then I'd probably see that 2 seconds hiccups. GC doesn't just sit there and run until it's needed. It's constantly working -- not just erasing your stuff, but the JVM's stuff, other people's stuff. What are you going to do if you find out that three-D engine you bought for $10K turns out having a memory leak when used in certain ways, and you are running close to the deadline? Call and get angry and demand a fix in a day? Not happening in the real world.

    From Java... to C++?
    Portability is going to be seriously fun.
    I still recall last time I shared some work with a "native" Java programmer. No [font=courier new,courier,monospace]delete[/font]. Never. That was good. The solution? Use a garbage collected language. Ok...
    Funnily, the absence of [font=courier new,courier,monospace]delete[/font]s in C++ code would normally indicate the code is very high quality, and is not written by someone stuck in C mindset.

    I haven't used Java in a couple of years. I dislike it because it's weak (in expressive power) while being frustratingly verbose and cluttered. I know it has a number of strengths, most importantly its ecosystem and userbase. And I have the impression that it is one of the best languages to minimize the damage a low-skilled programmer can do in a project. Give me either a more expressive and productive language, or a special-purpose one.
    Fortunately it looks like the Java ecosystem now has options, e.g. Clojure and Scala, so you don't necessarily have to suffer Java itself to take advantage of the ecosystem.
    Advertisement

    Funnily, the absence of [font=courier new,courier,monospace]delete[/font]s in C++ code would normally indicate the code is very high quality, and is not written by someone stuck in C mindset.


    I take it that means that someone is actually using the SC++L properly as opposed to hand-crafting all of their own memory management.

    Beginner in Game Development?  Read here. And read here.

     


    The analogy would work except that taking my trash to the end of my street is more efficient that driving it to the nearest recycling center, whereas automatic garbage collection is in general less efficient that manual memory management (not that there's a huge gap, GC's are getting better but it's still unacceptable to have an app randomly freeze for two seconds like I constantly see in java apps) since you know exactly what needs to be deleted at any given time and don't need to rely on more or less advanced heuristics to work it out for you.

    I see your point though, and it also depends how the OS handles memory management itself. There's a lot of variables involved but in general GC's are just one more incentive for poor programming design and crappy performance. Perhaps if people understood garbage collection is not a feature but a tool to be used only when needed it would be better.

    I'm with allnite on this one.

    I've worked on and off with Java since 1996.

    I've never seen a properly written app "randomly freeze for two seconds" for garbage collection, not even in the beginning of the language, not even on the old slow Nokias.

    That said, I have seen bad programmers. I have seen stupidly-written apps that leak resources at an incredible rate --- 'leak' should probably be replaced with 'flood' --- where the app produces so much garbage that there is a noticeable cleanup time. I have also seen stupidly-written apps that force the GC to run during the middle of their heavy work cycle. I have seen stupidly-written apps where individual objects have massive amounts of resources to clean up yet provide no way method such as dispose() to free up their resources at a more convenient time.

    None of those are the fault of the language, and you can see similar effects in any language by committing similar stupid mistakes. I've seen similar problems in C++ where collections grow to massive sizes and then are destroyed, or where programmers ignore rules of lazy construction and lazy destruction and end up creating very expensive temporaries that grind the app to a halt.

    Left to run on it's own garbage collectors run at a low priority in the background and do not interfere with your work. In my experience they have BETTER performance than memory cleanup in C++ since C++ must run the cleanup in the middle of processing, yet garbage collectors run it later during idle times.


    I'm currently working on yet-another-expansion for Sims 3. The game is written in C#, which uses the same style garbage collection as Java. The game has been a massive seller for three years yet there are no complaints that the app will "randomly freeze for two seconds" for garbage collection.


    I could list off a dozen other major AAA titles written in garbage collected languages. There are probably millions of apps for phones and devices ranging from older BREW apps to modern Andorid apps. And we can look at the major corporations relying on Java EE to run major servers and backends. None of these suffer from the problems you describe.



    Your claim about "poor design and crappy performance" are completely false in the real world.

    Bad programmers can produce bad code in any language, don't blame the language for the bad programmer's mistakes.

    [quote name='Krohm' timestamp='1334645733' post='4932042']
    From Java... to C++?
    Portability is going to be seriously fun.
    I still recall last time I shared some work with a "native" Java programmer. No delete. Never. That was good. The solution? Use a garbage collected language. Ok...
    Funnily, the absence of deletes in C++ code would normally indicate the code is very high quality, and is not written by someone stuck in C mindset.[/quote]
    Good revive.

    The runtime surely agrees with you. Running out of address space in less than half an hour (IA32) is surely a very good quality indicator. Of course we can hide ourself behind nice concepts and terms it does not change reality: in the end someone must use delete. Maybe a library, maybe some compiler construct but someone has to use it. It's not like memory releases don't happen just because we don't see them in code... but again I trust the runtime and the runtime appeared to not like it.


    I've never seen a properly written app "randomly freeze for two seconds" for garbage collection, not even in the beginning of the language, not even on the old slow Nokias.

    That said, I have seen bad programmers. I have seen stupidly-written apps that leak resources at an incredible rate --- 'leak' should probably be replaced with 'flood' --- where the app produces so much garbage that there is a noticeable cleanup time. I have also seen stupidly-written apps that force the GC to run during the middle of their heavy work cycle. I have seen stupidly-written apps where individual objects have massive amounts of resources to clean up yet provide no way method such as dispose() to free up their resources at a more convenient time.
    100% agreed!

    Previously "Krohm"


    I still recall last time I shared some work with a "native" Java programmer. No delete. Never. That was good. The solution? Use a garbage collected language. Ok...

    I can't stand garbage collection. Is it really that hard to clean up after yourself? If you can't match up allocation/deallocation pairs perfectly then your code design failed and you need to rethink it. But that's just a pet peeve of mine about a specific feature, can't say anything about Java itself. I still hear from it everywhere so I assume it's still well alive. And apparently Java is everywhere "in my car" and "in my fridge" and "in my smoke detector" so I guess whenever I feel Java is about to die I can just cheer myself up by looking at any of those items (or cheer myself down knowing Java isn't actually powering any of those, lol)
    [/quote]

    Well, the issue with garbage collection is that it does not mean automatic deallocation of items that you don't need allocated. People create memory leaks in garbage collected languages all the time. Here's example:
    http://developers.slashdot.org/story/07/11/17/0552247/c-memory-leak-torpedoed-princetons-darpa-chances

    Now, there's the semantical discussion as of how it is 'not memory leak' if you can still walk through the pointers, but as long as you don't have the code that actually will access the data, that's the data sitting here which will never be accessed, which programmer is probably unaware of, and which will lead to necessity of reboots. Every single feature of a memory leak.

    Other issue is that garbage collected languages often also go like 'yay finally we can use heap for everything' and the books and example code teaches very heap-heavy way of doing things. Simple example: you can have some sort of game bot class that has members like position, velocity, etc etc, which are vectors. The typical way of writing this in Java will have those members all allocated separately on the heap. You should use final keyword to avoid that, AFAIK, but few people do this. Hence very heap-heavy code.

    This topic is closed to new replies.

    Advertisement