Slashdot Mirror


Help crack the Java 1.6 Classfile Verifier

pdoubleya writes "As part of the development of Mustang (Java 1.6), Sun is developing a new, smaller and faster classfile verifier which they want your help in trying to break. As Sun VP Graham Hamilton puts it in his blog entry, "As part of Mustang we will be delivering a whole new classfile verifier implementation based on an entirely new verification approach. The classfile verifier is the very heart of the whole Java sandbox model, so replacing both the implementation and the basic verification model is a Really Big Deal.... The new verifier is faster and smaller than the classic verifier, but at the same time it doesn't have the ten years of reassuring shakedown history that we have with the classic verifier." You can read about the new verifier on Gilad Bracha's blog, and join the new Crack the Verifier initiative to if you can break it. Read all about the Crack the Verifier - Challenge."

276 comments

  1. Great Editing, Hemos! by repruhsent · · Score: 1, Funny

    and join the new Crack the Verifier initiative to if you can break it.

    I'm going to if I can break it right now!

  2. Only an Attaboy? by elgee · · Score: 2, Insightful

    No cold hard cash or equivalent for "cracking the verifier?"

    I guess it could lead to more pay in some cases.

    1. Re:Only an Attaboy? by shiznatix · · Score: 3, Insightful

      Begin able to show proof that you cracked, or helped crack, the Java verifier would be a excellent addon to your resume.

    2. Re:Only an Attaboy? by elgee · · Score: 1

      Begin able to show proof that you cracked, or helped crack, the Java verifier would be a excellent addon to your resume.

      I know. I was just thinking of that recent thing reported in /. about a contest in Romania, I believe it was, where the winner got 1000 German beers. As in Free Beer.

    3. Re:Only an Attaboy? by Anonymous Coward · · Score: 0

      Or your arrest warrant.

    4. Re:Only an Attaboy? by url80 · · Score: 0
      This should be a good challenge for Distributed.Net.

      They could also post a bounty for the breaking of this on:

      The Bounty Network

    5. Re:Only an Attaboy? by nadadogg · · Score: 1

      Was there any point to posting a link to your personal site, or just blatant advertising? I mean, you've got it under your username, in your sig, and yet you still feel the need to post it in the body of your reply?

      --
      i use linux and windows oh god how can i have an opinion
  3. Take Java seriously by rexguo · · Score: 4, Interesting

    Before those who go on to dismiss Java for various reasons (no matter how ignorant they are), take a look at the presentation given by Google at this year's JavaZone conference on how Google is using Java internally at extreme scales. Among them are AdWords and GMail.

    --
    www.rexguo.com - Technologist + Designer
    1. Re:Take Java seriously by Cthefuture · · Score: 1, Interesting

      What I don't understand is exactly what advantage is Java providing on the server-side. Do you really need cross-platform bytecode at that level?

      Is it just because of the extensive Java API's? That seems unfortunate because you could have the same API's in a native compiled language and get much better performance. If it's a safety/security issue then again you could build the same thing in a native compiled language, sandbox and all. Native compiled languages are just as portable (or even more portable) as Java. The main problem is having to recompile for each platform, but on a static server that is no big deal.

      To me it just seems like a huge waste to have the massive Java environment running bytecode on a static platform.

      As a language Java is certainly not easier to use than the higher-level languages like PHP, Perl, Ruby, etc. It's very verbose and complicated (relatively speaking). I can understand using scripting languages, it's Java that doesn't make any sense.

      I mean really, is it just because Java provides a lot of easy to use API's?

      --
      The ratio of people to cake is too big
    2. Re:Take Java seriously by Anonymous Coward · · Score: 0

      Man, you should have asked this few years ago :)

    3. Re:Take Java seriously by Naikrovek · · Score: 5, Insightful

      I don't think Java is as slow as you think it is. It is very fast lately, and it is actually giving C a run for its money in some respects. It is *definitely* not the slug everyone thinks it is.

      They're probably using Java because its not as slow as its reputation, and its becoming a commodity language in the enterprise lately. My corporate overlords have dictated the use of Java (IBMs WebSphere) for all current and future enterprise development, and most of us developers couldn't be happier. Everywhere I do contracting work for lately also uses Java. Java Is A Great Language(TM), especially since 5.0.

      There used to be a time when I believed that all techies had agreed that Java was slow and bloated, but once I stopped reading Slashdot comments so religiously I began to see some truth. It isn't slow, it isn't bloated, and it isn't something I expect the Slashdot crowd (that I'm a founding member of) to understand anytime soon.

    4. Re:Take Java seriously by bzzzt · · Score: 2, Insightful
      Cross-platform byte code enables you to deploy the same application on your PC or Mac workstation and have it function exactly the same as on a 64-processor Ultra server. It also means your application is "future-proof". Deploy it now on a 32-bits machine, later on a 64-bits machine without recompiling AND run it at speeds comparable to native code.

      Also, the language is easily picked up, simple to write and the API's are quite sane compared to a lot of other languages.

    5. Re:Take Java seriously by Anonymous Coward · · Score: 3, Interesting

      Java may not be "slow" any more, but it's an INSANE memory hog. Part of this is because the heap NEVER shrinks - as you allocate more memory, the heap just grows and grows until it reaches the heap limit (which can be user-set). The other part is because you need to load in large numbers of "support" classes, along with the virtual machine itself, just to get to something as simple as "Hello World".

      Now, I need to explain that "heap NEVER shrinks" bit, because people are going to hop in and start talking about the garbage collector. Well, yes. The garbage collector does indeed free memory. HOWEVER, it only returns the memory to the Java VM heap, NEVER to the operating system.

      So, simple real-world example. Java VM starts with 8MB heap. Your application allocates 40MB worth of objects, increasing the total heap size to 64MB. Java now has 24MB "free" memory within the VM, and 40MB used. You can determine this in code using Runtime.freeMemory() to get the memory free in the heap, and Runtime.maxMemory() to get the maximum memory the heap has available.

      Your program then "releases" 38MB worth of that data as unneeded. Eventually the GC collects that. Now you have only 2MB used, but the maximum heap size (as determined by Runtime.maxMemory()) REMAINS at 64MB. So now Java has 62MB "free" within the VM. Even if your program never uses more than 8MB after that, Java will ALWAYS keep the 64MB heap. It will NEVER shrink it.

      This is fine in server setups, but it absolutely blows for client apps, where it's not unusual for a certain process to require a lot of memory, and then be ready to release it back to the OS.

      Ultimately, on client apps, this winds up causing swapping, as chunks of unused VM heap get swapped out in favor of applications that actually need the memory they allocate. Swapping = slow.

      You could call this behavior a "memory leak" but it's almost certainly by design.

      Java may not be slow, but it's definitely bloated.

    6. Re:Take Java seriously by DarkTempes · · Score: 1

      when most people think of java they think APPLETS.

      well, applets have had a very very bad history due to the whole MSJVM and crappy browser plugins and such.

      and thus, when people think of java, they think, hey, those slow cruddy applet things.

    7. Re:Take Java seriously by srussell · · Score: 2, Insightful
      I don't think Java is as slow as you think it is.

      It depends on what you mean by "slow." If you're talking about long running processes, then no, it isn't slow at all; in fact, it is quite fast. If you're talking about short-running processes, then the JVM startup time overshadows any commendable performance.

      Ruby is much, much slower than Java when it comes to raw computational power, but I still use it when I'm writing non-server process apps, simply because it starts up so much more quickly.

      My main complaint about Java, though, is that it is a memory hog. If I recall correctly, MacOS's answer to Java's startup lag is to pre-load a VM, which makes executing Java apps quite quick. However, the last thing I want is Java running in the background when I'm not using it, hogging my system resources.

      The memory and startup issue is why I think you don't see a whole lot of Java apps, and when you do see them, they're far less popular (on average) than native apps -- even native apps that are less capable than the Java version. The obvious exception to this (that proves the rule) is Eclipse, which has won enormous mindshare even among non-Java developers.

      --- SER

    8. Re:Take Java seriously by Cthefuture · · Score: 0, Flamebait

      I'm sorry... but what??? I guess there is no sense arguing this because I'm already getting bizarre answers.

      Cross-platform byte code enables you to deploy the same application on your PC or Mac workstation and have it function exactly the same as on a 64-processor Ultra server. It also means your application is "future-proof". Deploy it now on a 32-bits machine, later on a 64-bits machine without recompiling AND run it at speeds comparable to native code.

      My question is specifically about server-side Java. We all know Java failed on the desktop. "Future-proof"? That doesn't make any sense, most likely at some point that code will need to be updated or changed or something requiring a recompile. New API's come and go. Because it's on a static server that's no big deal. No big deal for a compiled language either. Do you expect to just compile your application once and never touch it again? No bugs? No updates for future technology? "Future-proof"? There is no such thing.

      Believe it or not I can write 64-bit native applications as well.

      Also, the language is easily picked up, simple to write and the API's are quite sane compared to a lot of other languages.

      Now this was what my question was about. However, like I said, there is no reason you couldn't have a nice API in a native language.

      --
      The ratio of people to cake is too big
    9. Re:Take Java seriously by bbn · · Score: 3, Informative

      You realise that the C malloc/free calls are just the same right? It never releases memory back to the OS.

      The only difference in this regard, is that java might alloc extra memory from the OS, when it could have run the garbage collector and reused some memory instead.

      Very few programs actually ever release memory back to the OS.

    10. Re:Take Java seriously by Cthefuture · · Score: 0

      Giving C a run for its money in some repects is not the same as running as fast as C. I know Java is pretty fast now but that's not my main concern. My main concern is the massive overhead involved with installing the runtime everywhere you need it.

      Also being forced to use the garbage collector has a ton of overhead. If you have to create and destroy millions of objects quickly the Java VM will bloat out and kill the machine (an exageration but you get my point).

      Java just has a lot of overhead and complexity that doesn't need to be there (I'm speaking of the massive and complex runtime environment).

      Your attitude resembles what happens when your whole environment is Microsoft. Sure, everything seems great and everything works together nicely... That is, assuming the whole environment is Microsoft and everything is preinstalled and running for you. This attitude ignores the larger picture. The same is true with Java. If all you do is Java and you're surrounded by it and everything already has it installed and it's working then you think life is great. Or maybe everything is running on a server. The problem is that you are living in a bubble. As soon as you step out of that you start hitting problems.

      --
      The ratio of people to cake is too big
    11. Re:Take Java seriously by jaywee · · Score: 3, Informative

      That depends on libc implementation. glibc for example uses mmap() for bigger allocations - therefore is able to return the freed memory to the OS.

    12. Re:Take Java seriously by LarsWestergren · · Score: 2, Insightful

      What I don't understand is exactly what advantage is Java providing on the server-side. Do you really need cross-platform bytecode at that level?

      Certainly. Being cross-platform is always a big plus, didn't you read the Slashdot article about the large British retail chain that switched over all their POS terminals to Linux? They could do that thanks to Java. Of course, it is not COMPLETE platform independence, you are of course tied to the Java platform. You gain hardware and OS independence though, good enough for most.

      As a language Java is certainly not easier to use than the higher-level languages like PHP, Perl, Ruby, etc. It's very verbose and complicated (relatively speaking). I can understand using scripting languages, it's Java that doesn't make any sense.

      I mean really, is it just because Java provides a lot of easy to use API's?


      Speaking from my own experience, the number one advantage Java has is that it is maintainable. The strict typing and verbose exception handling is annoying if you just want to get something done quick. However, if you have a large team of programmers (of varying skill levels) and a large code base, you start to appreciate that the language tries to force good programming practice, and that a lot of bugs are caught not at runtime but at compile time (or even as you are typing if you use a tool like Eclipse). This is a lot more important than raw performance, since a lot more time is spent on maintaining a product than building it in the first place (90% is number often cited).

      Someone on Slashdot in a post way back said it drove him mad in Java to always have to declare "what he was going to do" in advance, and what he wanted to do if something went wrong -
      "Now I am going to open a connection"
      "Now I'm opening a connection"
      "If error type one happens then..."
      "If error type two happens then..."
      and claimed that we don't do that in real life. Someone else pointed out a counter example - in the military and other large teams that does critical work they DO work like that. If a large ship is approaching a harbour, they don't just run in and hope nothing is in the way,
      they ask
      "Harbour, permission to dock?"
      "Deck team, all clear?"
      "Engine team, all clear?"
      "Ok, commencing docking..."

      Of course, there is still a lot of garbage written in java, I just think it is somewhat simpler to spot in advance. I.e. someone is catching general Exceptions and ignoring them all over the place, is using a lot of static methods, etc...

      --

      Being bitter is drinking poison and hoping someone else will die

    13. Re:Take Java seriously by justsomebody · · Score: 3, Interesting

      While I agree with you on all accounts I can't help but comment you.

      Both Java and .Net have the same problem. Sloppy memory. As long as you don't use a lot of atomic memory blocks with higher load on machine where it runs, everything is ok and just as you said it. I tested both on the same tests and always fallen in the same problem. No direct memory control, GC waited until it was too late, and everything started to crawl. GC somehow avoids doing work if software is taking most of the CPU, it is also the same reason why Java beats C or C++ on speed tests (Every speed test where they try to proove that Java or .Net is faster than C or C++) uses allocation and freeing of memory in some loop. And while both C and C++ actualy do free memory, Java and .Net just mark that as garbage and wait for GC to clean up the mess which doesn't happen if load is too high. Just take any test where Java was faster and test loop to make 2^32 instead of 1000 or 10000 calls. This way you will actualy use more memory than you actualy have with allocations.

      p.s. Not bashing, just saying results of my testing. If you can suggest some approach, do that, but so far not even one person suggested something I haven't tried yet. Both Java or .Net would be a real gift for me if only I could use them for my needs.

      --
      Signature Pro version 1.13.2-3 release 83.5 beta3try7 after-breakfast edition
    14. Re:Take Java seriously by felix_lucian · · Score: 1

      Actualy memory allocation/dealocation can be faster in java that in C.
      Also, memory fragmentation is a non issue with modern GC wich is not to be said about C.

      read this : http://www-128.ibm.com/developerworks/java/library /j-jtp09275.html?ca=dgr-jw22JavaUrbanLegends

    15. Re:Take Java seriously by (A)*(B)!0_- · · Score: 1
      "However, like I said, there is no reason you couldn't have a nice API in a native language."
      What happens when your hardware changes and that nice API isn't available for your new hardware?
    16. Re:Take Java seriously by Anonymous Coward · · Score: 0

      That's some shitty malloc you have there in that case. Mine certainly does.

    17. Re:Take Java seriously by tyldis · · Score: 1

      If it's not dog slow could you please help Cisco?
      Their admin tool is built on Java and brings a 3GHz machine with 512MB RAM to a standstill.
      Also, the developers of Azureus needs your help, their app is also dog slow and eats whatever memory it can find.

      I could find more apps for you, but whenever I try a Java application I shudder because it is unresponsive and hogging resources. It *could* of course be clueless developers, but the problem seems too widespread to me.

    18. Re:Take Java seriously by jiushao · · Score: 4, Funny
      It depends on what you mean by "slow." If you're talking about long running processes, then no, it isn't slow at all; in fact, it is quite fast. If you're talking about short-running processes, then the JVM startup time overshadows any commendable performance.

      Yeah, it is a shame, if only Sun would do something like writing a new faster classfile verifier.

    19. Re:Take Java seriously by SnapShot · · Score: 2, Insightful

      On a server-side environment, the "massive overhead involved with installing the runtime everywhere" is pretty much a non-issue. It's like complaining that you can't write Ruby or Perl apps because Ruby and Perl aren't installed on every client machine. In the end, when you are doing these kind of applications, the only thing the client needs is a browsers and an internet connection.

      If you're doing stand-along applications that need to be installed locally on a client then perhaps you have a point. On the other hand, it is easy enough to package the correct version of the JRE on your install CD and have you application use that.

      The company I works for uses Java for basically one reason: J2EE. Fast enterprise applications that are developed very, very quickly and are delivered as HTML pages to the client's browser. JVM startup times are a non-issue since the application server is pretty much running all of the time. Memory is a non-issue since we know how much memory is available on the server and plan accordingly. It's not like someone is going to startup MS Office on the the back-up Sun server and start complaining about lack of resources. I'm guess we could do the same thing with C or Perl or some other CGI system, but Java has proven itself to be a stable development environment that is fairly safe (in terms of memory, security, and tolerance towards "newbie" programmers) so why change?

      Personally, I want to experiment with Ruby on Rails to try and get a hands-on comparison since I've heard nothing but good things about both the language and the enterprise evironment. But, there is a bit of inertia with any development. Right now, at least, it is much easier to hire J2EE developers than Ruby on Rails developers.

      --
      Waltz, nymph, for quick jigs vex Bud.
    20. Re:Take Java seriously by Myolp · · Score: 2, Interesting
      Perhaps it's because there are a ton of good Java developers available, compared to the amount of C/C++ developers. But it could also be because Java is acutally faster at things like memory allocation. I also believe that the large amount of ready-to-use and stable software components available makes a difference when choosing Java for your server application. Then there are the large number of standards built on Java, like J2EE or J2ME, that allows you to focus on the application-specifics in your project and ignore all boiler-plate code necessary if you would have choosen C++ (for instance). There are also several very , very good IDEs for Java with features you won't find in IDEs for other languages.

      I guess there are more reasons than these, but those were the ones that came to mind at the moment.

    21. Re:Take Java seriously by Anonymous Coward · · Score: 1

      The "nice API" we are speaking of is written in the language we are speaking of. To use it on new hardware you just recompile on that hardware.

      I mean, even Java isn't 100% portable. The VM and much of the API's and runtime have to be ported and recompiled natively for every single platform.

    22. Re:Take Java seriously by 955301 · · Score: 2, Interesting


      Yes you do. The advantages of being able to develop on my local linux notebook and deploy to a Solaris cluster should not be overlooked simploy because it's important at dev time, not production time. Recompiling on another platform means retesting on that other platform. I'd rather run my unit and integration tests off the production & staging environments, load test in staging and no testing in production. This way unit and integration can be part of my build process (http://maven.apache.org/ and not something I have to redo on the final production hardware.

      And your overlooking the JIT as well.

      --
      You are checking your backups, aren't you?
    23. Re:Take Java seriously by dastrike · · Score: 2, Insightful
      "What happens when your hardware changes and that nice API isn't available for your new hardware?"

      What happens when your hardware changes and that nice Java Runtime Environment isn't available for your new hardware?

      --
      while true; do eject; eject -t; done
    24. Re:Take Java seriously by VisualStim · · Score: 1

      There used to be a time when I believed that all techies had agreed that Java was slow and bloated, but once I stopped reading Slashdot comments so religiously I began to see some truth. It isn't slow, it isn't bloated, and it isn't something I expect the Slashdot crowd (that I'm a founding member of) to understand anytime soon.

      I'm beginning to see the usefullness of Java on the server. However ...

      How many Java applications can I run on my desktop machine at once? How many C/C++ applications can I run on my desktop machine at once?

      "Slow" and "bloated" need a basis for comparison. If the basis is Java 1.0, sure. If the basis is desktop applications in C/C++, well ...

    25. Re:Take Java seriously by cluening · · Score: 1

      I suspect that the wannabe nature of a huge number of slashdot readers is part of the problem with this "myth". _Most_ people only experience Java in their web browser or in stand-alone GUI apps. In many cases, these things really are slow, as could probably be expected: your application has to pass through several layers of virtual machine and windowing libraries before it can draw to the screen. Doing real work with Java, requiring writing your own app in an efficient way, isn't really bad. This involves actually getting your hands dirty though. This is likely too hard for too many of our fellow readers.

      Of course, I still laugh whenever I hear somebody give a talk about high-performance computing with Java...

      (Bring on the posts saying "But look at this one specific example! It scientifically proves that Jaba is 300x slower than teh C++!!1!")

      --
      Posted from the wireless couch.
    26. Re:Take Java seriously by AKAImBatman · · Score: 5, Interesting

      The reasons to use Java on the server are quite simple. The combination of factors that attracted developers to Java in the first place make them want to use it on the server. Those factors are:

      1. Cross-platform capability - Many companies still prefer to deploy applications on large Sun, IBM, or Linux (name your brand) servers. However, these companies would also like to give their developers Windows desktops so they can interact with the rest of the company. (Who most likely uses MS Office/Outlook.) As long as you avoid explicit path names, it is quite easy (and common!) to develop on a Windows machines but deploy on a Unix or Unix-like machine.

      2. Automatic Memory Management - So your server is running along, and suddenly someone generates an unexpected error. In Java you can sleep soundly because even the worst programmer would have a hard time doing anything to completely take down the application. If you use a language that allows direct memory management, you have a good chance of that new guy coding a General Protection Fault/Segfault. The result is that your entire system coredumps when you least expect it.

      3. Security - While Java is able to control the Security of the ENTIRE JVM through its security framework, most companies are happy with the lack of buffer overruns, code injection techniques, and other common attacks. That's not to say that a poor programmer can't put a security hole in the application wide enough to drive a Mack truck through, but at least you can rely on the underlying system not to betray you.

      4. Flexibility - The Java server side frameworks are exceedingly flexible in their designs. For example, the servlet framework allows you to plug in your own custom server page technology. I have seen many a programmer (including myself) implement something like Reports by simply linking the ".rpt" extension to a custom servlet. The servlet then loads the requested configuration file and executes it. Very nice.

      Another example is servlet filters. Need a security framework added in a hurry? Just add a filter servlet! It will execute before the rest of the code, allowing you to check the variables and security permissions to ensure that the client isn't trying any funny business.

      5. API - When Java was first introduced, it absolutely creamed all the competing languages in the richness of its bundled API. As time has worn on, this has changed. However, Java still enjoys a sizable lead over even C/C++ with features such as Type IV (tested cross-platform, pure Java) JDBC database drivers. Unlike ODBC, many of these drivers have been tuned for excellent performance. Similarly, there are free APIs for handling Office Documents, PDF Creation/Editing, SOAP/XML-RPC communications, Object-Relational mapping, Image Management/Creation/Editing, CORBA, XML Databases, XSL-T, etc. While these APIs are all available for C/C++, there are significant cross-platform issues with many of them, as well as a lack of common "pluggable" APIs that allow for one API to many implementations.

      Other languages have a hit/miss score with these sorts of features, often not providing these features, providing only a small subset, or only being available in an expensive commercial package.

      6. Dynamic Loading - While C/C++ can manage dynamic loading of shared objects, it's a very difficult thing to implement. Java does it out of the box, with a full reflection API and interface support, thus allowing such wonderful code as Beans, Servlets, Pluggable Drivers, self-organizing code, and a host of other features that other systems can't compete with.

      (If you don't believe me, try adding support for a feature in PHP sometime. "It's so simple! Just install the SO and recompile PHP!" Meh.)

      7. Performance - This may sound like an odd thing to say, but the performance of Java is a key selling feature. Java server applications may execute more slowly than one written in C/C++ (just as C/C++ may execute more slowly than

    27. Re:Take Java seriously by 0kComputer · · Score: 0

      It is very fast lately, and it is actually giving C a run for its money in some respects.

      And what respects are those? Virtual Memory consumption? Give me a break, you obviously have no clue what you're talking about. The performance of managed languages will never match those of native c/c++, thats just the way it is. Managed languages speed advantages are in development time/maintainability.

      --
      Top 10 Reasons To Procrastinate
      10.
    28. Re:Take Java seriously by FatherOfONe · · Score: 2, Insightful

      I will try and summarize your main point. You don't like Java because the JVM for each platform can be upwards of 100MB and you don't like garbage collection over handling the cleanup of objects yourself in code.

      To the first point. Do you develop software? I do and it sucks big time if you code for Windows. You currently have to worry about DLL issues and what service packs are installed and what the heck Microsoft is going to throw at you in the next "hotfix". You say that you want to code for Linux? Well do you want to make an RPM, shell script, YAST, Yum or Apt get? What version of libraries are they running? Do you want to include "everything" just in case they don't have the correct libraries you think they will need? Or do you just want to make the user go through something like "RPM Hell". Do you want to target a Macintosh? Well good luck there! What platform are you going for? OSX on X86 or OSX on PPC or are you going to produce "fat" binaries? I find it a bit easier to just have the user install a 1.4 JVM for their platform.

      Now Java is by no means the silver bullet of programming, you still have some small library issues, however getting an application to run on multiple versions of Windows, Linux, Solaris, OSX, and just about everything else is very easy compared to what else is out there. I will actually say that there is no reason for Java in one core situation. That is if the whole world runs the latest patched version of Windows. Then, and only then does Java loose one of it's major strengths. However, as you mentioned in your post that place doesn't exist, or if a company tries to inforce those strick standards they are "broken" within a couple of years.

      Now as far as garbage collection. I somewhat agree with your point, but I would say that I have created close to a million objects in a few seconds and distroyed them (let garbage collection run) and the program has run fine. I will say that it uses up a rather large amount of memory, but that wasn't your complaint and in my case it didn't matter.

      I do wish that Java would do a couple of things better. One is to provide a good tool for JSF development (WYSIWYG) Studio Creator beta does not cut it! It needs some serious work. MyEclipse also doesn't quite cut it. I would also like to see AJAX support in JSF. I also wish that they would simplify developing web services a bit and perhaps their security layout as well. Much later down my list would be to address any performance/memory issues. I guess I would also wish for one more thing, and that would be to make EJB 3 very similar to hibernate (I believe that this is the case).

      --
      The more I learn about science, the more my faith in God increases.
    29. Re:Take Java seriously by zootm · · Score: 2, Insightful

      I'd like to add "type safety" in there, but then I'm a programming language geek at the best of times.

    30. Re:Take Java seriously by xtracto · · Score: 1

      ...The strict typing and verbose exception handling is annoying if you just want to get something done quick. [...] you start to appreciate that the language tries to force good programming practice, and that a lot of bugs are caught not at runtime but at compile time (or even as you are typing if you use a tool like Eclipse). This is a lot more important than raw performance, since a lot more time is spent on maintaining a product than building it in the first place (90% is number often cited).

      Just a small comment, all those properties you mention are part of the Java specificaction language, it is trivial to create a native-compiled language that uses exactly the same Java specification (the same BNF). All those properties have nothing to do with the virtual-machine oriented nature of Java which makes it slower than the native compiled languages.

      and that a lot of bugs are caught not at runtime but at compile time (or even as you are typing if you use a tool like Eclipse

      If you want some similar functionality for a compiled based language (C/C++) try using the CDT plugin for Eclipse.

      --
      Ubuntu is an African word meaning 'I can't configure Debian'
    31. Re:Take Java seriously by icebattle · · Score: 5, Informative
      Have you tried running your app with -XX:+UseParNewGC -XX:+UseConcMarkSweepGC?

      This will allow the vm to do small amounts of gc whenever it has a chance, as opposed to wating until an allocation request will fail and then running through the entire heap.

      Our app runs 24/7 and while the markets are open and 10meg+ of raw data is coming down the line every second, we can't allow the app to take a timeout for a gc run. The app runs in 256meg, too.

    32. Re:Take Java seriously by Hard_Code · · Score: 1

      Sure this is a problem, but isn't it also a problem with traditional 'malloc'? From what I've seen, malloc gets pretty pathological under high load also, does it not? Eagerly reclaiming memory may not actually be as good as it sounds. Even with traditional explicit memory reclamation, you aren't ever *really* reclaiming the memory yourself. It has to first jump through whatever the malloc strategy is, and then the operating systems virtual memory and cache subsystems, all of which may choose to do arbitrary things. In /general/ I'd say that amortized over time, allocating and freeing memory in bulk, like say, a GC does, is optimal for throughput if not latency. If anything, it is not GC's fault, but perhaps the fault of whatever is causing such large memory allocations to begin with (e.g. the language or libraries or VM design).

      --

      It's 10 PM. Do you know if you're un-American?
    33. Re:Take Java seriously by Anonymous Coward · · Score: 1, Informative

      Java /is/ a natively compiled language, or rather it can be. I suppose the politically-correct-for-Slashdot complier to mention is GCJ, but personally I use the excellent Excelsior JET. Great performance, reasonable footprint, much faster development than C++, more scalable than Perl/Python/etc.

    34. Re:Take Java seriously by 21mhz · · Score: 2, Informative

      if only Sun would do something like writing a new faster classfile verifier.

      They do: since (1.)5.0, JRE classes come preloaded in a shareable file.

      --
      My exception safety is -fno-exceptions.
    35. Re:Take Java seriously by Politburo · · Score: 1

      It doesn't really matter that Java never releases the memory, assuming the amounts aren't obscene. In your example, when the heap grows to 64 MB, we can assume that some pages are swapped from RAM to HD to make room for the larger heap as it is being used. After the memory is used and re-allocated to the VM's free memory, the OS will swap other application's pages back into memory as needed. The VM free memory, allocated by the OS, will swap to HD. It will then sit on the HD until it is needed again. In your scenario, this is never.. so it just sits on the HD. What's the problem? While it would be nice if the VM released the memory to the OS, the swapping takes place no matter what.

    36. Re:Take Java seriously by Anonymous Coward · · Score: 0

      I just ran a test myself. I wrote a GUI application with server and DB backend in 1/10th the time of C/C++, it has no memory leaks and has almost no bugs. It is also deployed effortlessly with Java Webstart to any common OS for hundereds of users.

      I could go on, but I think your argument is looking pointless already.

    37. Re:Take Java seriously by jilles · · Score: 1

      Your argument is effectively countered by this excellent article on why java memory management is actually faster than the way it is handled in C/C++: http://www-128.ibm.com/developerworks/java/library /j-jtp09275.html?ca=dgr-lnxw07JavaUrbanLegends

      In short, memory allocation in Java is faster (measured in cpu cycles used) and it can use both stack and heap based memory allocation (unlike the urban myth that Java can't do that). Additionally, for short lived objects, garbage collection is essentially free (unlike calling free() in C++). Of course you can do clever stuff in C like not actually using malloc and free but most programmers default to not doing except for some very specific cases. In other words, most of the time Java is actually faster for both allocation and deallocation of memory.

      People like you run into trouble when they manually call the garbage collector (bad idea, can cause severe performance issues) or when they misconfigure the garbage collector (e.g. if you are running a server with multiple cpus and multiple gigabytes of memory). Also a big issue is C programmers trying to program Java like it is C and making wrong assumptions about the cost of certain code and the impact of certain optimizations (e.g. pooling is actually bad for performance in some cases).

      The only real problem that Java has with respect to memory management is that java programmers tend to use lots of memory when writing their software. You don't have to do that but using the default APIs and recommended practices in e.g. the java tutorial and many books on this matter you will probably end up using substantial amounts of memory. Many Java programs continually create and destroy large amounts of small objects. If you'd do that in C/C++ you would really notice this. In Java you hardly notice this at all because it allocates and deallocates in a much smarter way.

      I don't know what 'personal tests' you have been performing. Up front I'd say you may have been measuring the wrong things the wrong way and have been drawing the wrong conclusions based on what your results. The JVM is a highly complex piece of software and very difficult to benchmark properly. Doing so requires that you know

      --

      Jilles
    38. Re:Take Java seriously by MSBob · · Score: 1
      I think you're a bit behind the curve. Managed languages can analyze runtime profile and perform optimizations that can't be performed on native code. High level concepts like escape analysis and lock elision come to mind.

      But hey, never let the facts get in the way of your argument.

      --
      Your pizza just the way you ought to have it.
    39. Re:Take Java seriously by Anonymous Coward · · Score: 0

      There is nothing preventing a C programmer from using the same type of memory allocation and deallocation system and it would probably be even faster than the Java stuff (no slower at a minimum). In other words: You can run a garbage collector in C also. Duh.

      What's stupid about that IBM article is that at some level you have to call into the OS to get or release memory. There is no way to change that. Even the Java VM is calling some form of malloc/free at some level. They just do it in chunks and have their own allocator on top of that. This is wasteful in certain situtations. You can do the same damn thing in C/C++ or just about any other native language.

      At least you have a choice in C/C++ so you can optimize the system for your needs. Java gives you no choice and if it's too slow then tough crap.

    40. Re:Take Java seriously by MemoryDragon · · Score: 1

      Actually natively compiled languages in the server sides case are not really that much faster, but you are around 10 times as fast in development times as you would be in C++, besides that you get stuff like clustering scaling up to mainfraime level, clustered caches, excellent orm mappers etc... out of the box. There is a reason why Java is used heavily on the server side nowadays, it is scalability, fast development times, stability, and huge excellent libraries for everything under the sun.

    41. Re:Take Java seriously by Elm+Tree · · Score: 1

      But look at this one specific example! It scientifically proves that Jaba is 300x slower than teh C++!!1!

      - You did ask for it after all.

    42. Re:Take Java seriously by MemoryDragon · · Score: 1

      You forgot to mention one thing, there is a maximum heap size, every java program has to adhere to, it is depending on the VM between 32 and 64MB, and you can adjust it with the -Xmx param. It is true, the heap never shrinks but in reality it also does not grow!

    43. Re:Take Java seriously by MemoryDragon · · Score: 1

      Check outExade for jsf development much better in this regard than MyEclipse. As for ejb3, it is very close to Hibernate but more cleaned up and really good. There already is a good tool which covers the ORM part of EJB3 (the BO part is equally stunningly good) it is called jsr200 an you can download it from the Eclipse site.

    44. Re:Take Java seriously by Halo- · · Score: 2, Insightful
      I'm not bashing Java, but I don't completely agree with your statement that:

      Cross-platform byte code enables you to deploy the same application on your PC or Mac workstation and have it function exactly the same as on a 64-processor Ultra server. It also means your application is "future-proof". Deploy it now on a 32-bits machine, later on a 64-bits machine without recompiling AND run it at speeds comparable to native code.

      While this is theoretically true for byte code, in Java isn't not something you can depend on. I write Java code for a living, and our test team still has to test our product on every platform and OS we claim support for. Even the same version of the same vendor's JVM will have little OS-specific quirks which can add up to big problems if ignored.

      More importantly, "write once, run anywhere" really should be qualified as "write once, run anywhere the exact same JVM is installed and a decent script/command/launcher exists to properly start your application with all the flags, classpaths, memory management, and other configuration needed for this platform"

      This may seem sorta nit-picky but I spend a great deal of my time figuring out why a certain behavior only occurs on a certain platform. Usually it's because to do anything useful, you can only abstract the underlying operating system so far. For example, the way that Windows creates and manages a file is very different than the why most Unix systems do. An application which downloads a file from the network and overwrites an existing file often needs special handling on Windows because Windows sometimes will deny access to a file (if it thinks it is in use), or not synch the descriptors when you expect it to. This isn't either Java or Window's "fault" it's just the way things work.

      However, I do agree that Java is a good language and makes a lot more "sense" from an API perspective than most other languages. Writing programs in C/C++ now seems very tedious to me. All the stuff I used to worry about without thinking about (buffer sizes, memory allocation, finding functions/libraries) in C/C++ which aren't issues in Java amazes me.

    45. Re:Take Java seriously by swillden · · Score: 5, Informative

      Java will ALWAYS keep the 64MB heap. It will NEVER shrink it.

      Who cares? This is completely irrelevant, as long as the JVM marks the pages it's not using as discardable, which modern JVMs on modern OSes do.

      You have to remember that all memory is virtual. I can allocate a 1GB array, but as long as I never actually touch the pages (making them "dirty"), no storage, whether RAM or disk, is ever used. When the JVM allocates its 64MB, that virtual memory is initially all "clean" and therefore consumes no RAM. As it's used, it gets dirtied and physical RAM gets mapped to it... but when a garbage allocation occurs, both the Sun and IBM JVMs mark the now-unused pages as clean, allowing the OS to reuse them at will. Effectively, they no longer consume any space.

      Even if the JVMs didn't mark the pages as clean, the impact of the JVM holding onto the 64MB wouldn't be that significant. The allocated, dirtied but now-unused memory will simply get swapped out to disk, allowing those pages of RAM to be used by other applications.

      With a decent OS, it really doesn't matter if an app holds onto some memory that it's not using, especially if it has the decency to tell the OS that it's not actually using it.

      That said, there is a "problem" here, it's just not the one you're pointing out. The problem, if you want to call it that, arises from the generational, copying, compacting garbage collector used by modern VMs. Now, don't get me wrong, this GC is very cool. It's significantly more efficient than typical malloc/free memory management, *and* it eliminates some major classes of memory leaks (programmers can still leak memory with GC, but it's harder).

      Without getting into the details, although GC is safer and more efficient in terms of CPU cycles, and although on average it doesn't use a great deal more memory than manual allocation would use (particularly since many performance-sensitive manual allocation apps end up managing their own memory pools in order to avoid the run-time cost of malloc() and free()), GC does tend to increase the number of memory pages that get touched over time.

      Why? Two reasons. First, suppose the application allocates a small chunk of memory, uses it, frees it, allocates another small chunk (about the same size), and then uses and frees it. Most malloc()/free() implementations will tend to return the same chunk of memory for both allocations. Repeating the process a thousand times (which isn't all that uncommon) will probably only dirty a single page of memory. With the sort of garbage collector used by current JVMs, every one of those allocations will return a different chunk of memory, and many pages will therefore be dirtied. In terms of CPU cycles, GC wins big, because, rather than a thousand small frees, there is one big one. And allocation is up to two orders of magnitude faster. It may sound like the GC approach is going to use a lot more memory, on average, but it's not that bad because of the tendency of malloc/free-managed heaps to become fragmented. On average, GC implementations don't have many more pages in use than malloc/free implementations, and may actually have less, but the GC allocators tend to "roam" across the pages.

      Second, the "copying" nature of the GC. The main thing that makes generational, copying GC-based memory management so fast it that it never has to deal with fragmentation. To describe it in an oversimplified way: Every now and then, the GC relocates all of the in-use objects into a nice, compact block. That makes allocation fast, and tends to reduce the number of pages in active use, but it increases the number of pages that get dirtied and therefore require actual RAM to be provided by the OS. The copying also has a cost in CPU cycles, but it's small relative to the cost of managing and searching free lists, which is what malloc/free implementations have to do.

      Theoretically, as the GC copies objects and marks the pages where they used to live as discardable, the OS coul

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    46. Re:Take Java seriously by ultranova · · Score: 1

      It depends on what you mean by "slow." If you're talking about long running processes, then no, it isn't slow at all; in fact, it is quite fast. If you're talking about short-running processes, then the JVM startup time overshadows any commendable performance.

      My quick, very scientific experiment with a wristwatch and an animation library test application I've written had java start, from pressing enter into the sprites begin bouncing in the window, in 5 seconds. This was with a 1GHz Duron, lots of free memory, and Sun JDK1.5, which had not been started before since last reboot (so no part of it was in disk cache). The application contained a about 10 classes and interfaces. Given that, I can't see the startup time as being a significant issue.

      This applet has an RSS of 23M (and a total VM size of 268M), so memory is still an issue. However, it is not a showstopper for a foreground application (but it would be for a background one).

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    47. Re:Take Java seriously by U96 · · Score: 0, Offtopic

      Nice troll!

      --

      "I thought they were the dominant species..."
    48. Re:Take Java seriously by MenTaLguY · · Score: 1

      I hate to break it to you, but five seconds for an application that small on hardware like that is a long time...

      --

      DNA just wants to be free...
    49. Re:Take Java seriously by 0xABADC0DA · · Score: 1

      Every speed test where they try to proove that Java or .Net is faster than C or C++ uses allocation and freeing of memory in some loop. Just take any test where Java was faster and test loop to make 2^32 instead of 1000 or 10000 calls.

      Wrong. Java typically wins the FFT microbenchmarks where there is *zero* memory allocation. Making the test run over and over actually improves Java's performance. Typically in microbenchmarks that involve memory, Java recognizes that the objects are short-lived and deletes them with almost no work involved. It's not that the GC isn't running at the end, because if you do -verbose:gc you'll see it runs hundreds of times in these tests (ie so it could only make 1/100th of a difference by not runnning at the end). But for most naive microbenchmarks you really want to be comparing Java "new" to C's stack-based variables.

      Take for example the 'language shootout'. Java does poorly because a) they try to correct for startup time by running the test with 0 iterations, but this means Java won't even load classes used inside the actual test. b) the tests are rigged, for example in one string processing test the C version uses a byte[256] ascii-only lookup table compared to Java using unicode for 3 method calls and iirc 2 if statements (ie, it's not even remotely comparable). c) so that long-running languages complete they use a low the number of iterations, which magnifies the errors measuring startup time which are not taken into account (profiling, loading classes, etc); they should measure bandwidth for x seconds not time to do x iterations, but even the easy way of just varying the iteractions until it completes in close to a given time is apparently too hard.

      If you actually create a program that does the same code (no cheating using lookup tables in C and not Java, do the bounds checks in C) you'll see Java is *much* faster than the equivalent C. So it's not so much about Java being slow as being a really fast, safe version of C.

    50. Re:Take Java seriously by TheRaven64 · · Score: 4, Interesting
      I would refer you to some research done around a decade ago, which involved running a MIPS emulator on a MIPS machine. The emulator was doing dynamic optimisation, and got around a 10% speed increase over the same code running directly on the hardware.

      A Java VM does some things that are simply not possible with C. To inline a C function, you need the source for both - this leads to some really ugly things like putting simple functions in headers, which should be reserved for interface definitions, not implementation details. The Java VM will inline functions on the fly. This can potentially give a huge performance boost - I got almost a 50% speed increase on some C code I was recently writing by shuffling things around to allow the compiler to inline some common functions.

      The other advantage of higher-level languages is that they provide more semantic information to the optimiser. Consider the trivial example of autovectorisation. In C, if you want to do an operation on a vector, you will usually iterate over every element and perform the operation. The compiler then needs to check that there are no dependencies between loop iterations, which can be non-trivial. In a language like FORTRAN or Smalltalk, you can simply perform an operation on a vector type. The compiler then just needs to check if the operation you are trying to perform corresponds to one or more vector unit instructions, and substitute these in to your code. This is much easier to do.

      C is a fairly easy language to write optimised code in for any CPU up to and including a 386. For anything more modern, you will find yourself fighting a language which is simply not designed to deal with parallelism - and compiler writers find themselves fighting even harder.

      --
      I am TheRaven on Soylent News
    51. Re:Take Java seriously by Anonymous Coward · · Score: 0

      You realise that the C malloc/free calls are just the same right? It never releases memory back to the OS.

      How do you know what my library does if you don't even know which one I'm using? It's possible that they map directly to the OS's memory management API.

      In fact, in day to day work, I program for semi-embedded systems. If free didn't really release memory, there would be serious problems. With 300k of memory and the possibility of multiple applications loaded, OS-level free memory is gold.

      Don't give me this bullshit unless you're going to lay out exactly which implementations you're talking about.

    52. Re:Take Java seriously by slapout · · Score: 1

      Maybe it's so that it doesn't matter what the server is. They could be running Linux. Then the could decided to run Sun instead. Or maybe try Windows (just kidding :-)
      The point is if a server goes down, just throw another one up (that can run Java) and you don't have to worry about it.

      --
      Coder's Stone: The programming language quick ref for iPad
    53. Re:Take Java seriously by ultranova · · Score: 1

      Also being forced to use the garbage collector has a ton of overhead. If you have to create and destroy millions of objects quickly the Java VM will bloat out and kill the machine (an exageration but you get my point).

      Hmm.

      public class Dummy {
      public static void main(String[] args) {
      int i;
      int x;
      Object o;

      x = 0;
      for (i = 0; i < 100000000; i++) {
      o = new Object();
      x += o.hashCode();
      }
      System.out.println(Integer.toStr ing(x));
      }
      }

      The hashcodes are summed up and printed to make sure that the object allocations can't possibly be optimized away by any ultra-smart optimizer.

      Nope, still running. Took about 40 seconds to run. Didn't notice any massive swapping; top shows a RSS steady at 13M. Or did you mean that you run out of memory if you allocate millions of objects at once ?

      Anyway, I ran again with GC logging on (-Xloggc:filename), and it showed that there's about 30-40 garbage collections each second, each lasting about 0.00044 seconds. Which means that the system is using about 1.76 percent of its time for garbage collection, in an application that does almost nothing but creates objects.

      So, I'd say that either you are exaggerating pretty heavily, or you need to get more memory ;).

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    54. Re:Take Java seriously by cluening · · Score: 1

      Woo! I was afraid nobody would do that. My day is complete!

      --
      Posted from the wireless couch.
    55. Re:Take Java seriously by Coryoth · · Score: 1

      The strict typing and verbose exception handling is annoying if you just want to get something done quick. However, if you have a large team of programmers (of varying skill levels) and a large code base, you start to appreciate that the language tries to force good programming practice, and that a lot of bugs are caught not at runtime but at compile time...This is a lot more important than raw performance, since a lot more time is spent on maintaining a product than building it in the first place (90% is number often cited).

      If you feel that's the case then I suggest you consider what else you can do beyond just static types to force good programming practice and catch more bugs at compile (or verification) time. Adding some basic annotations to your code specifying, for example, preconditions and postconditions for methods, and invariant properties for classes, forces good programming practices and catches even more bugs at compile time, and can certainly make maintnenance easier.

      If you're writing production code (as opposed to doing rapid prototyping) then really you ought to have a clear idea of what you intend a method to do before you write it. Given good semantics (and such thigns do exist) it isn't hard to encode those intentions formally into pre and post conditions on the method. You already do this to some extent with static types: you specify a type signature for the method; we're only really talking about having some slightly more explicit assertions about what the method does. If you're willing to do that then you automatically have much better documentation of your methods, and means to verify said documentation against the actual code you've written (by formalising the documentation), which is both good programming practice, and good for maintainability. Even better, because of the formalised statement of what the method is supposed to do, you can do some static verification akin to static type checking and catch more errors earlier.

      If you like Java than check out JML which is an annotation language for Java that allows for this sort of thing. There are extra tools you can get (like ESC/Java and others) to do further static checks based on those annotations, the annotations themselves automatically get included in the JavaDocs for better documentation, and you can use the annotations to automatically generate unit tests and a testing harness for your code. That's a lot of easy wins for the little extra work of being a little bit more specific than just static types.

      Jedidiah.

    56. Re:Take Java seriously by justsomebody · · Score: 1

      Thanks, if you read my post again you can see that I know that there is a case where I could be wrong. That is why countering might be bad word to use. More like explanation;) So, here it is again: "Yes, I know I (or my mistakes) could be the problem here"

      People like you run into trouble when they manually call the garbage collector (bad idea, can cause severe performance issues) or when they misconfigure the garbage collector (e.g. if you are running a server with multiple cpus and multiple gigabytes of memory). Also a big issue is C programmers trying to program Java like it is C and making wrong assumptions about the cost of certain code and the impact of certain optimizations (e.g. pooling is actually bad for performance in some cases).

      Might be some truth in that, although I tried my best to go by the books and articles. But I can say this, that if I leave it out to GC then performace is really bad (same goes for C++ GC).

      The only real problem that Java has with respect to memory management is that java programmers tend to use lots of memory when writing their software. You don't have to do that but using the default APIs and recommended practices in e.g. the java tutorial and many books on this matter you will probably end up using substantial amounts of memory. Many Java programs continually create and destroy large amounts of small objects. If you'd do that in C/C++ you would really notice this. In Java you hardly notice this at all because it allocates and deallocates in a much smarter way.

      As I already said I tried by the books. And using base Java only, no additional packages.

      I don't know what 'personal tests' you have been performing. Up front I'd say you may have been measuring the wrong things the wrong way and have been drawing the wrong conclusions based on what your results. The JVM is a highly complex piece of software and very difficult to benchmark properly. Doing so requires that you know

      Actualy exactly the same job I had already done in C++. I tried to rewrite (and not line by line, but completely new one) the same job in Java (and then in .Net too), because I would benefit if it would work out and I had some time to spare.

      Job consisted out of few separate apps (can't afford to make one app, have to separate them, because sometimes they do not reside on the same computer). All apps work multithreaded.
      A lot of memory blocks of various size, but one block (where various data builds and as long as it builds it can't be freed, since job must complete first then being processed or dropped, somewhat like transactions) could go up to 150MB.
      Trouble is that I can't predict how many blocks and how big will reside in memory at once and swapping data to disk is not possible.

      Anyway, thanks again. But, to speak the truth, I won't consider Java now for a long time (which means I won't be testing it), not that I have something against Java, I simply have no time to waste anymore (I'm in a middle of the project right now) there was a time but Java failed and if that is because of Java or me, result is the same.

      --
      Signature Pro version 1.13.2-3 release 83.5 beta3try7 after-breakfast edition
    57. Re:Take Java seriously by Kent+Recal · · Score: 1

      Yup, about 1s would be acceptable. 5s is "noticable lag".

    58. Re:Take Java seriously by Billly+Gates · · Score: 1

      Like the other poster mentioned, speed is not an issue on a j2ee server. It's sql access times that equal the main bottleneck.

      A j2ee http server is much faster than a regular http server running cgi scripts. The reason for this is that a java http server uses teh same engine for the java code and not a call to a seperate userspace program. In contrast Cgi scripts need to be passed to and from the http server. This could add up in a busy server with alot of hits with dynamic content.

      The exceptions to this are asp and php because they are used in html itself and execute inside the http engine.

      Java is also used because it has a great api that is deep, mature, and well rounded. There are classes for pretty much everything and it comes with lots of features. They are well written and mature unlike php which quality varies drastically on what you use. Java has great networking performance and security and is supurb for ecommerce applitions. Many companies also develop software for java servlets that make deploying and creating a java commerce site easy.

      So if your a busy looking to minimize downtime, need security, need performance to handle alot of hits, and support for commerce and credit card payment clases than Java is your language.

    59. Re:Take Java seriously by vingilot · · Score: 1

      Both Java and .Net have the same problem. Sloppy memory. [...] No direct memory control, GC waited until it was too late, and everything started to crawl.

      I would hardly call it sloppy: Read this article on tuning GC ergonomics. Object allocation/deallocation is highly organized and much of it can be tuned.

      With the default Throughput collector full gc does not happend until the young generation is full. So your application may not fill the young generation; Additionally, collection in the young generation is parallel so memory reclaimation can implictly take advantage of multiple processors.

      The example you give where allocation/deallocation happens in a loop over 2^32 iteration can be made to run by knowing something about how/whats being allocated. With smaller objects you could decrease the size of the young generation to make incremental collections faster. With variable size object you could set and adaptive resize policy for the tenured/young generation size-- this would allow the heap to grow and shrink as needed (this can make GC faster since it may have to collect on a smaller space). You can also increase the amount of GC can consume; sometimes gc can be too timid and allow memory allocation to get out of control, resulting in a heap that grows too big for GC to collect in a reasonable amount of time.

      That said there are still times when it would be nice to have direct memory access, but there are always to get around this (such as JNI and managing your own memory/reusing objects).

    60. Re:Take Java seriously by bbn · · Score: 4, Insightful

      You can say the same thing about the parent comment about java memory management. The J2ME for mobilephones does indead free the memory. Funny how java for embedded systems uses the same strategy eh? J2ME works with very little memory. A Nokia 3410 only has 64 KB memory for the java games.

      The parent post was obviously talking about ordinary client applications running on PC under either Windows, Linux, Mac or something simelar.

      On such a system, malloc cannot map directly to the OS API, because the OS will only allocate full pages at a time. So if you want 40 bytes of memory, the OS would give you 1 KB (or whatever the page size is).

      This also means that if you allocate 2x40 bytes, then free the first 40 bytes block, malloc can not free the page. It is simply not possible, since it would have to free the whole page.

      Some J2ME implementations can defragment the memory in this situation, to be able to release memory back to the OS. That is impossible with a C program, where direct pointers to memory is allowed.

      For large blocks you can of course go directly to the OS.

    61. Re:Take Java seriously by justsomebody · · Score: 1

      Sure this is a problem, but isn't it also a problem with traditional 'malloc'? From what I've seen, malloc gets pretty pathological under high load also, does it not? Eagerly reclaiming memory may not actually be as good as it sounds.

      Agreed, but at the same time optimizing memory (de)/allocation is possible. Had to do that in C++ too. Had to set up completely controlled environment. Problem was I couldn't do that in Java.

      Even with traditional explicit memory reclamation, you aren't ever *really* reclaiming the memory yourself. It has to first jump through whatever the malloc strategy is, and then the operating systems virtual memory and cache subsystems, all of which may choose to do arbitrary things. In /general/ I'd say that amortized over time, allocating and freeing memory in bulk, like say, a GC does, is optimal for throughput if not latency.

      Same opinion. But automatic controlled environments can act correctly (and maybe even better) only in predicted occasions (and that would 98% probably) same as any auto-thing, as long as designer predicted those parameters system mostly works. Trouble is that I need those 2%.

      If anything, it is not GC's fault, but perhaps the fault of whatever is causing such large memory allocations to begin with (e.g. the language or libraries or VM design).

      Actualy it is nature of the job you're processing that controls this factor;)

      --
      Signature Pro version 1.13.2-3 release 83.5 beta3try7 after-breakfast edition
    62. Re:Take Java seriously by justsomebody · · Score: 1

      If you read my answers below you can see that I can't use that. But hey, thanks anyway. Unfortunatelly for me it was a special case where any auto-solution failed.

      --
      Signature Pro version 1.13.2-3 release 83.5 beta3try7 after-breakfast edition
    63. Re:Take Java seriously by justsomebody · · Score: 1

      Yep, that answered few questions of mine. Thanks.

      The example you give where allocation/deallocation happens in a loop over 2^32 iteration can be made to run by knowing something about how/whats being allocated. With smaller objects you could decrease the size of the young generation to make incremental collections faster. With variable size object you could set and adaptive resize policy for the tenured/young generation size-- this would allow the heap to grow and shrink as needed (this can make GC faster since it may have to collect on a smaller space). You can also increase the amount of GC can consume; sometimes gc can be too timid and allow memory allocation to get out of control, resulting in a heap that grows too big for GC to collect in a reasonable amount of time.

      Same thing would be to alloc once and just reuse that block everytime wouldn't it? That was how I solved my problems. Having for example
      loop
          allocation
          work
          deallocation
      end loop

      does take a pretty stupid coder to write it like that (if data type was known). I think we both agree on that;)

      That said there are still times when it would be nice to have direct memory access

      And that is why I went back. It is much easier to write specialized GC for your needs, than hoping somebody predicted what you need.

      --
      Signature Pro version 1.13.2-3 release 83.5 beta3try7 after-breakfast edition
    64. Re:Take Java seriously by Hard_Code · · Score: 3, Informative

      And given the escape analysis that is apparently going to be implemented in the next version of Java, it looks like a large chunk of the class of problem you propose (many small allocations/deallocations causing "roaming") may be able to be eliminated. The VM will know when some references never "escape" a certain context/scope, and adjust memory management accordingly. One common scenario, and source of many "temporary" objects, will be automatic/local variables in methods, which can be stack-allocated, eliminating this problem.

      --

      It's 10 PM. Do you know if you're un-American?
    65. Re:Take Java seriously by jilles · · Score: 2, Insightful

      You sound like you are a decent programmer. However, the type of problem you describe is not exactly a standard thing: multithreaded, lots of disk IO, lots of memory used. Doing this right in Java (or any other environment) requires some knowledge about how things work. In your post you make it clear you do not have more than a rough understanding of how garbage collecting is implemented in Java or indeed the ins and outs of optimizing Java's behaviour in this respect. That's pretty essential stuff for this kind of thing.

      I think the key problem with your Java implementation is not that it is written in Java but that it's design is based on some wrong assumptions about how things work in Java. For example IO quickly becomes a bottleneck, did you use the nio classes? Did you run a profiler to find out where the bottlenecks were? Maybe there's some synchronization issues? There could be a whole lot of things wrong. Optimization in Java is possible, just like in C. And just like in C it requires that you understand the technology.

      I'm not suggesting you should do things in Java but merely that you should be a bit more careful to blame technology for things that may also be attributed to your lack of knowledge. It isn't Java that failed here, but you and indeed the end result is the same.

      --

      Jilles
    66. Re:Take Java seriously by Mithrandir · · Score: 1

      The HP Dynamo project is probably what you are refering to. It was done on PA-RISC, not MIPS. The performance increases of running native code (ie C/C++) inside a VM was in the order of 20-30%. A quick google brought up the Ars Technica article on it, but there's plenty more.

      --
      Life is complete only for brief intervals in between toys or projects -- John Dalton
    67. Re:Take Java seriously by Felonious+Ham · · Score: 3, Insightful

      I'd also add that the pool of Java developers is pretty substantial, making it easier to staff a project than say PHP or Ruby.

    68. Re:Take Java seriously by Anonymous Coward · · Score: 0

      Java Is A Great Language(TM), especially since 5.0. [...] it isn't something I expect the Slashdot crowd (that I'm a founding member of) to understand anytime soon.

      Java is a Language For the Masses. Compared to using a Language For Smart People, it seems awkward, verbose, and weak. It makes me several times less productive than a higher-level language. No, I don't think I'll understand it any time soon.

      I'm not even talking about fancy things like Lisp macros -- Java doesn't even have *closures* yet. Why is it worthy of my time?

    69. Re:Take Java seriously by LizardKing · · Score: 1

      More importantly, "write once, run anywhere" really should be qualified as "write once, run anywhere the exact same JVM is installed and a decent script/command/launcher exists to properly start your application with all the flags, classpaths, memory management, and other configuration needed for this platform"

      With all due respect, I feel you need to read up on how to package your applications better. If that fails I think you need to look at the quality of your code. I have a 200000 line Java codebase which, thanks to an MVC architecture, builds into a web application and a number of standalone applications (some are GUI tools, others are daemons). Thanks to a decent Ant build system along with a good understanding of Jar files, Log4J and webstart, I can deploy onto Windows, MacOS X and Solaris. No platform dependent tweaks at all, and no plaform specific problems encountered.

    70. Re:Take Java seriously by egeorge · · Score: 1

      There is another distinction between Java and C-esque apps (at least in a unix-like environment). In general, because of the startup overhead for the JVM, Java apps are designed to be longer-running than their native compiled counterparts. Observe the trend towards deploying things into an "appserver" environment or other daemon-oriented framework. Because of this, the ramifications of not releasing memory back to the OS are a little different. It is often a larger penalty in the case of Java than it is in the case of short-lived C processes. That said, I should mention that I am a huge proponent of Java, and think quibling over megabytes of RAM is counterproductive. My personal opinion is that the productivity gains of Java far outweigh these minor distinctions heap management policies.

    71. Re:Take Java seriously by Decaff · · Score: 1

      What I don't understand is exactly what advantage is Java providing on the server-side. Do you really need cross-platform bytecode at that level?

      Yes. It is a real advantage. I can build a J2EE application package (a WAR) file and deploy on an application server such as Tomcat and not care what the server OS is at all. This is great for things like mixed-OS clusters, as all you need a single codebase and a single binary deployment.

      Is it just because of the extensive Java API's? That seems unfortunate because you could have the same API's in a native compiled language and get much better performance.

      The better performance argument is a myth. Java performs extremely well server-side.

      Native compiled languages are just as portable (or even more portable) as Java.

      No they aren't - at least not in my experience. There are major issues such as word endian-ness and size to be taken account.

      The main problem is having to recompile for each platform, but on a static server that is no big deal.

      It is a big deal. Cross-compiling a large program can take a while, then each version has to be tested on each platform. Compare to Java where developers routinely code and test on Windows or Linux/Unix and then deploy on the other platform with no problems.

      To me it just seems like a huge waste to have the massive Java environment running bytecode on a static platform.

      Java environments generally don't run bytecode. They run mostly native code. The pure bytecode is there at the deployment stage. As the program runs the JVM generates optimised native code based on profiling of the application. This can in principle be more efficient that one-shot compiling. The only benefit of pre-compiled applications is quick start-up time, but that does not matter server-side when code on application servers (unlike code in CGI scripts) can be continually running for days or even weeks.

    72. Re:Take Java seriously by greg_barton · · Score: 1

      I second the suggestion others have made of trying NIO. It could solve two of your problems (GC woes and IO woes) using direct memory mapping.

    73. Re:Take Java seriously by (startx) · · Score: 1

      You realise that the C malloc/free calls are just the same right? It never releases memory back to the OS.

      Not true in OpenBSD.

    74. Re:Take Java seriously by msuzio · · Score: 2, Interesting

      Thank you. "Wannabe" is just the right term. It really burns my ass when someone who is ignorant (and I mean that in the truest sense of the word -- they might not be stupid, but they obviously do not actually know what they are talking about) just spits out the standard "Java is teh suX0r!!!! It is sl0w!!!!" stuff.

      *rolls eyes*

      LISP weenies and C++ gurus can knock Java. They've earned the right to do so. Anyone who has written code for one of the "scripting languages" people position as competitors to Java (they aren't, just different tools for different jobs) can knock Java, because they've shown they understand the compromises and internals of designing a language. ...but if you've sorta kinda read a book on Perl, or you think PHP "r0xors" because your favorite Counterstrike fansite uses it for the forum system, or you think Java is slow because an applet of Jake waving ran slow in Netscape 3.0 in 1996, you might not quite be qualified to offer an opinion on this subject.

    75. Re:Take Java seriously by hr+raattgift · · Score: 1, Informative

      GC systems in a similar steady state tend to roam all over their heap, touching lots of pages. This can cause the OS to keep more physical pages mapped to the process's virtual memory space, even though the process isn't actually using more memory.

      Not necessarily. Modern GCs tend to take advantage of the generational hypothesis which suggests that most objects die young. One can code with generational GC with fast handling of deaths in the "nursery" of recently-created objects in mind.

      A typical generational GC with two generations of old objects and a nursery works like this.

      You maintain four pointers:

      G1, the top of the oldest generation.
      G0, the top of the 2nd oldest generation.
      FREE, the top of the nursery.
      CEIL, which limits the size of the heap.

      At initialization, the first two of these all point to the bottom of the heap.
      CEIL will point to a memory location half way between the bottom and the top of the heap, or higher.

      Set FREE to CEIL, so we begin allocating in of the top of the heap.

      When we allocate an object, we simply increment FREE.

      When FREE reaches the top of the heap, we collect the nursery.

      We do this by sliding down all live objects between FREE and the top of the heap to the area between G0 and CEIL.

      In a tracing GC system, live objects are those pointed to by the roots (registers, for example, or live stack frames) as well as objects in the older generations. We can optimize the identification of the latter by maintaining a write barrier on the older generations, which tells us whether a section (perhaps a page) in the older generation was touched since the last garbage collection. A page which hasn't been touched since the last gc cannot point to live objects in the nursery. A page which has been touched might point to live objects in the nursery, so we have to trace the pointers in the page as if they were roots.

      The slide-down relocation is usually done by copying the object and leaving behind a forwarding pointer. In the case of linked lists and the like, the lists are walked recursively, often breadth-first, although depth-first can give better locality of reference.

      During the migration of the live objects, we can increment G0 as we go, reusing the allocation mechanism, or we can adjust G0 after the slide-down relocations are finished. Either way, when we are done, we have expanded the area between G1 and G0, and no longer care what's above CEIL. If there is sufficient space between G0 and CEIL, we set FREE to CEIL and operate as usual.

      If we are tight on space between G0 and CEIL we can either expand the heap (and increase CEIL) or we can collect one or both of the older generations. Again, we identify live objects and slide them down to the earlier generation.

      In the case where we are creating lots of short-lived objects we are doing very little copying during the nursery collection -- we can end up effectively doing nothing but writing objects into the top of the heap then resetting the FREE pointer when we get there. If there are many more pages between CEIL and the top of the heap then yes we will be touching more pages than if we had a very disciplined explicit allocate-and-free mechanism. If our nursery is small, however, that is not the case.

      There are other ways of handling the nursery, including the Cheney on the MTA approach of using C's runtime stack (alloca() and friends) to store young objects. We still have to find and live objects when our nursery gets too large, but the C "return" reclaims all the dead ones. The implementation is straightforward for a continuation-passing-style language compiled into C, works well with small nursery sizes, and has been implemented in the Chicken implementation of Scheme.

      Optimizing the speed of nursery handling, and partitioning the

    76. Re:Take Java seriously by justsomebody · · Score: 1

      If this is what you suggest
      http://java.sun.com/j2se/1.4.2/docs/api/java/nio/p ackage-summary.html

      Yes, I tried it and I found no more Java advantage. Source became even more complex and harder to read than C++

      --
      Signature Pro version 1.13.2-3 release 83.5 beta3try7 after-breakfast edition
    77. Re:Take Java seriously by cameronpurdy · · Score: 1

      What I don't understand is exactly what advantage is Java providing on the server-side. Do you really need cross-platform bytecode at that level?

      No, of course not. Servers haven't run "cross-platform bytecode" in six or seven years now; that is simply the deployment format (a "portable executable" if you will). The moderns JVMs (several implementations, including from IBM, Sun and BEA) take that deployment format and convert it to machine code, either as they load it ("JIT") or as they run it ("profile-based optimization", a la Sun's HotSpot). The concept of portable formats is so universally accepted (e.g. XML, ZIP, HTML, etc.) as to require no defense. Java simply has a portable format for executable code. Performance has not been a major issue for a couple years now, and the scalability is unparalleled. We recently completed a test in which a Java cluster (Tangosol Coherence on x86/Linux) was processing over 1 BILLION clustered transactions per hour. Java now powers many of the equities and currency exchanges, trading systems, banking systems, travel systems, retail web sites, logistics systems, etc., often in HA scale-out configurations attaining a scaling factor approaching 1.0. Java is also huge in the PDA and cell phone markets. There are over a billion such Java-enabled devices out there. The version of Java for these devices is a bit cut down to say the least, meaning that (in most cases) you can't take a server app and run the code on a phone. Java has already entered the "real time" systems marketplace, using both Real Time Java (a bastardized Java that has hard real time guarantees) and some of the newer JVMs like jRockit that can provide soft real time guarantees (e.g. no GC pause over 15ms). Strangely enough, the only market that Java hasn't really penetrated is the desktop market -- which is where it originally started with all those ugly and slow applets! ;-) On the desktop, the combination of "difficult to make Java really beautiful" and "eats large amounts of memory per JVM" have kept Java from being a good choice for most application development. The big business apps on the desktop are often Java, but utilities, command line tools, etc. are almost never Java.

      Is it just because of the extensive Java API's? That seems unfortunate because you could have the same API's in a native compiled language and get much better performance.

      Obviously, a rich set of APIs helps. However, since Java is natively compiled (see above) there is no reason why it would be faster in a different language. Furthermore, most Java VMs use runtime profiling information to optimize the binary code even further, including massive amounts of inlining (that can de-inline dynamically if the optimization proves to be incorrect). The result is actually faster execution in a VM for large applications with lots of tiny methods and zillions of calls. Remember, "VM" does not mean interpreted; it simply means that the specification for execution guarantees are not bound to a single execution implementation.

      Native compiled languages are just as portable (or even more portable) as Java.

      It is an interesting argument, but it is not true. Our customers use the same binary on the Z and on 20 different Linux distros and Windows and OS400 and HPUX and MacOSX etc., and often within the same Tangosol cluster. Before Java, I used C/C++ extensively, and it was not portable without huge amounts of additional work (much of which had to be baked in up front).

      As a language Java is certainly not easier to use than the higher-level languages like PHP, Perl, Ruby, etc. It's very verbose and complicated (relatively speaking). I can understand using scripting languages, it's Java that doesn't make any sense.

      That is a reasonable and logical argument. The same is occurring today in the Java world. Ruby (jRuby) and Groovy and BeanShell are

    78. Re:Take Java seriously by kaffiene · · Score: 1

      It's *not* running bytecode.

      For christ's sake, have you Java haters *still* not understood that Java is compiled at run time?

    79. Re:Take Java seriously by justsomebody · · Score: 1

      Doing this right in Java (or any other environment) requires some knowledge about how things work

      As I said, mistake might be on my part, but solving this problem in C++ was a piece of cake.
      However, I found this problem and Java better to be left alone. I simply do not wish Java so much to devote my life to study Java. If 3 months (that counts only the active testing for my needs, not learning from beginning, I already knew enough Java basics to write apps from long ago when I was using Borland JBuilder 1) was not enough then it is better for me to stick where I belong, pushing one technology where it doesn't fit naturaly is not something I want to do in my life.

      There is no best hammer for every nail.
      That is why I stick with:
      - C, C++ and personaly modified freepascal for hardcore (whichever fits best to the job)
      - Lately C# for simple GUI things (I find C# aesthetics more pleasing than Java, while during my testing of both I only discovered that each has its own flaws (again read as: according to my expectations), but aesthetics were the only thing where C# won)
      - bash for system needs
      - a little of php and python for external scripts in my software

      Did you run a profiler to find out where the bottlenecks were?

      No need for that. Since I can't specify max mem (well as I learned today in one of the responses I can (at least in J5, link of documentation reffers to J5, but my Java testing ended 2-3 months before J5 was out) do that in runtime with Java, so solving my problem would probably need almost the same solution as C++) or cpu resources (I explained that in one of my replies, in c++ I solved this with simple IPC and all apps work as one) GC took everything for him self, everything started swapping which resulted in system crawl.

      Optimization in Java is possible, just like in C

      I know that;) Believe it or not sometimes I profile (:if you can call that profiling:) my bash scripts.

      did you use the nio classes

      Reason why I tried default Java was to avoid complex sources:) Using NIO is far less readable than C++ (that would be my personal opinion and my personal aesthetics)

      p.s. Both .Net and Java have very bad coverage (documents) of my problem, they try to redirect your coding to managed memory and managed resources. And if documentation is hard to find then documentation is just as good as non existing. Maybe that is why more people try'n'leave Java than try'n'stick.

      --
      Signature Pro version 1.13.2-3 release 83.5 beta3try7 after-breakfast edition
    80. Re:Take Java seriously by kaffiene · · Score: 1

      Exactly. Slashdot is a refuge for C coders with their heads in the sand regarding Java. I'm not dissing C - I love C. But Java is a shitload more capable than slashbots care to admit.

    81. Re:Take Java seriously by kaffiene · · Score: 1

      ashpe24p@RD-PAshford /cygdrive/c/peter/java/code
      $ time /cygdrive/c/Program\ Files/Java/jdk1.5.0_04/bin/java -cp . test
      done

      real 0m0.148s
      user 0m0.010s
      sys 0m0.010s

      Yup - that's AMAAAAZINGLY slow :o)

    82. Re:Take Java seriously by felix_lucian · · Score: 1

      man, the GC is smarter that you, Joe coder.

    83. Re:Take Java seriously by jilles · · Score: 1

      C++ is your hammer, good for you. If you'd spend as much time with Java as you apparently have with C++ you might have some different opinions about the whole thing. Three months to become an expert in anything is a very little time. I've been working with Java for nearly ten years and still I'm hardly an expert on memory management in Java. There's a lot to be learned on this subject.

      The GC and swapping are two things. If your machine starts to swap, you are using a lot of memory. The problem is that it is not being garbage collected because you are using it. The key to fixing such issues is not to hope for the garbage collector to fix your memory issues but to identify what objects are kept in memory, which of them are using too much memory and why they aren't garbage collected. Don't blame the garbage collector for poor program design.

      BTW. what I know of nio, it is clearly positioned as the solution for the type of app you were trying to create (IO intensive stuff & large memory buffers). And I agree, it's not a very pretty API and requires some study to get into. But it's understandable that you run into trouble trying to avoid using it while trying to implement something for which it was created in the first place.

      I also agree that you were probably better off using something you know well rather than to dive into new technology that requires a lot of study to be similarly effective.

      --

      Jilles
    84. Re:Take Java seriously by Jesus_666 · · Score: 2, Funny

      Yeah, the day that happens is the day Microsoft puts symlinks into NTFS.

      --
      USE HOT GRITS WITH STATUE OF NATALIE PORTMAN (NAKED AND PETRIFIED)
    85. Re:Take Java seriously by NoOneInParticular · · Score: 1

      IMO, type safety is really not a thing Java excels at. Yes, if you consider that Java in general only manipulates one type (object), then it is type safe, but in reality its type system is shoddy at best. The container classes are a huge gaping hole of typing nightmares, only shoddily patched with the new 1.5 Generics. And don't get me started on the overloading issue: by design Java has excluded itself from scientific computing.
      All in all: as a language, I don't think Java is particularly elegant, innovative or resourceful. As a platform, it's robust, fast and excellent at what its supposed to do. It's not really general purpose, but at its single purpose, business applications, it's very good and really takes over the flag from COBOL.

    86. Re:Take Java seriously by NoOneInParticular · · Score: 1
      About the language shootout: two remarks. You are free to enter your own Java implementation of a particular problem, so if you think the implementation is wrong, don't whine and enter your own stuff. Second, startup time is important for many small applications. Would you write wc in Java? I'm using java much less then I could, simply because the startup time of java often is longer than the total process time in, say, python. Especially for making small utility programs tied together through pipes, Java blows. People do write such programs as it is often clearer to create a couple of small apps with easy input-output behaviour than a largish monolithic app that does all but is a nightmare to instrument and maintain.

      But then again, for its main purpose, business server apps, it has no equal. Too bad it sucks for many things outside of that, as it has a nice feature set, but wasn't completely thought through.

    87. Re:Take Java seriously by Anonymous Coward · · Score: 0

      Do you want to include "everything" just in case they don't have the correct libraries you think they will need?

      That's the solution for shipping Java apps, isn't it? Given the propensity of everyone shipping libraries to change their APIs from one minor version to the next...

    88. Re:Take Java seriously by tigeba · · Score: 1

      My admittedly very unscientfic test. While perl is signifigantly faster, I think you would have to admit that the startup time difference between these four interpreters is fairly meaningless.

      $ time ruby hello.rb
      Hello, World Ruby

      real 0m0.120s
      user 0m0.077s
      sys 0m0.031s

      $ time python hello.py
      Hello, World Python

      real 0m0.126s
      user 0m0.093s
      sys 0m0.062s

      $ time java -cp . hello
      Hello, World Java

      real 0m0.127s
      user 0m0.015s
      sys 0m0.015s

      $ time perl hello.pl
      Hello World Perl
      real 0m0.047s
      user 0m0.062s
      sys 0m0.015s

    89. Re:Take Java seriously by justsomebody · · Score: 1

      I've been working with Java for nearly ten years and still I'm hardly an expert on memory management in Java. There's a lot to be learned on this subject.

      Well, if ten years is not enough for memory handling then my choice about leaving was correct. And you're not the first to say this. All the people I talked about this treat memory handling in Java or .Net like it would be something really complicated. In any other language this is just natural.

      C++ is your hammer, good for you. If you'd spend as much time with Java as you apparently have with C++ you might have some different opinions about the whole thing. Three months to become an expert in anything is a very little time.

      Who said anything about becoming expert? Did I ever??? I was using Java for about 3-4 years and then was a few years gap (used Java when it suited my needs). This would be the first job I would really apply Java commercialy and full app.

      Spending so much with C++? Nah, actualy I spend most last months with fpc. This project I'm working on will be made with fpc. Except that fpc had shortcommings and I had to implement preprocessor for pascal++ specs and few additions of mine. As such I can almost completely avoid memory handling (but it took 3 months to finally create version that touches fpc on very few points and can be applied against any fpc version until now) and I can rely on my own GC-like engine. Being able to control language specs made me possible to achieve the only thing I searched with Java and still retain simple low level hadling.

      Why I wanted Java or .Net in the first place? Sources are cleaner and less bug prone and not because Java or .Net would be something greater than the rest of the world. I don't know about you but I hate having mountains of sources and my self constantly searching where bug lies like I did until now
      But what I discovered is two options (and results):
      1. Source even less maintainable than C++ but app is effective; result = not what I was looking for
      2. Source is very nice and readable but app is not effective (for my needs); result = better to stick where I am, it works

      BTW. what I know of nio, it is clearly positioned as the solution for the type of app you were trying to create (IO intensive stuff & large memory buffers). And I agree, it's not a very pretty API and requires some study to get into. But it's understandable that you run into trouble trying to avoid using it while trying to implement something for which it was created in the first place.

      Well, again I specify. Having more readable source and being less error prone were the reasons why I was trying Java anyway. NIO fails at least first by a lot.

      Don't blame the garbage collector for poor program design.

      Since same approach from non-managed languages works like a charm, I can. They are just more suitable for this need and Java is no hammer for every nail (and you sound like it is, in your comment it is like "If it doesn't work then it is your fault", well if it does then it is butt ugly. Would that be my fault too? Remember my reasons why I even tried Java. It wasn't because C++, C or fpc wouldn't suit my needs. It was because I was searching for a nicer (more readable and less bug prone) way of implementation). As I said few times now, I dicredit Java for my OWN (and everytime I specify "my personal opinion") reasons and results in testing Java. And be that for no documentation on that topic or shortcommings of suited approach. Result will be the same.

      I somehow feel that you are offended. Well if you are I didn't intend to offend you, but I'll say it again, Java is nice but it is far from universal hammer for my taste.

      --
      Signature Pro version 1.13.2-3 release 83.5 beta3try7 after-breakfast edition
    90. Re:Take Java seriously by Anonymous Coward · · Score: 0

      Uh, ten years ago optimizers sucked ass. Therefore the code running directly on the hardware was not even close to being fully optimized. That's why they saw a speedup. The original code sucked. If they did the same comparison today the dynamic optimization would offer little to no benefit or more likely make the code slower.

    91. Re:Take Java seriously by zootm · · Score: 1

      Compared to C/C++ I mean, it's worlds ahead. Obviously many languages (in particular functional languages) are better.

    92. Re:Take Java seriously by Anonymous Coward · · Score: 0

      Fantastic, now replace the Object class with a class with some termination code, and measure how long it takes to 'destroy' those 100000000 instances when the method ends and objects falls out of scope.

    93. Re:Take Java seriously by MSBob · · Score: 1
      since I can't specify max mem (well as I learned today in one of the responses I can (at least in J5, link of documentation reffers to J5, but my Java testing ended 2-3 months before J5 was out)

      My goodness! You actually claim to have tried Java and did not find out about -Xmx switch? Honestly man, you cannot claim that you gave Java a fair try. If you had typed java -help followed by java -X you would have known. This switch has been available since at leat Java 1.2.

      When you have some free time, try Java again, this time without prejudices and really put some heart into it. Otherwise you really can't claim to have given it a fair try.

      --
      Your pizza just the way you ought to have it.
    94. Re:Take Java seriously by shutdown+-p+now · · Score: 1
      Java Is A Great Language(TM), especially since 5.0.
      Java is COBOL of our days. It does not automatically make it bad, of course, but as far as language design goes, it is rather deficient compared to the best we have (and interesting enough, was already deficient when it first appeared). Regarding its slowness, it is an interesting question. Yes, on one hand, when you do simple loops, math etc, there's really no reason why it should be slower than C (and it isn't). But heap-only allocation model and untyped containers (they're still untyped even with 5.0 generics - that pesky thing called "type erasure") are inevitably slower than C++ stack allocation and STL containers - and if you look at most code written in Java, you'll see that constructor calls, containers, and iterations over the latter appear much more often than math. And in that department, Java is really not significantly faster than, say, Perl or Python (nor it has any potential to be) - but at the same time does not have any advantages of the truly dynamic ("scripting") language.
    95. Re:Take Java seriously by shutdown+-p+now · · Score: 1
      Speaking from my own experience, the number one advantage Java has is that it is maintainable. The strict typing and verbose exception handling is annoying if you just want to get something done quick. However, if you have a large team of programmers (of varying skill levels) and a large code base, you start to appreciate that the language tries to force good programming practice, and that a lot of bugs are caught not at runtime but at compile time (or even as you are typing if you use a tool like Eclipse).
      Unfortunately, Java type system is nowhere near strict. Before generics were introduced in 5.0, it could not be called even remotely strict. These days, it sort of is, lagging slightly behind C++ (no const-ness constraints). But if you want to see a well-thought strict type system which actually works the way it was intended to, without dirty hacks (which casts invariably are), look at OCaml. A somewhat more practical (but still superior to Java) approach can be seen in Eiffel. Speaking of Eiffel, by the way - I've found that Design by Contract has much more to give in terms of forcing good programming practices, compared to strict typing (in fact, type constraints on method arguments & return value are just part of its contract - thus strict typing is, in a sense, a subset of DbC methodology).
    96. Re:Take Java seriously by Mnemia · · Score: 1

      Then you (or Sun, more likely) rewrite only the VM rather than all of your programs.

    97. Re:Take Java seriously by NoOneInParticular · · Score: 1

      If by worlds ahead you mean that the particular subset of 10% of the language features of C++ is 90% more easily and robustly used, then yes. However, the language as a whole is very limited in scope and extensibility of the language is non-existant. The VM is however excellent.

    98. Re:Take Java seriously by zootm · · Score: 1

      Scope and extensibility aren't really issues of type-safety, and if not handled well they're often more of a detriment to the language than a benefit.

      I'm tempted to say that limits to the scope of a language (again, this is something that functional languages tend to do better) are usually a good thing, since they promote consistency. With languages like C++, more rigid coding practices need to be put into place just to be fairly safe, let alone consistent.

    99. Re:Take Java seriously by NoOneInParticular · · Score: 1
      The static type system in Java is horribly broken. You do realize that everytime you cast something you are circumventing this type-system, don't you? Java is the most cast-heavy language I can imagine, and even something simple as covariant return types which eleminate a lot of casts has never made it into the language. In C++ world, a cast is generally seen as a way to circumvent errors in the type structure of the application, in Java there's no way around it.

      Then of course there is no support for parametric polymorphism (Java generics are not that, that's auto-casting, a quick hack on a broken system). Yes, C++'s implementation through templates is complex and relies much too much on overloading to be considered a 'nice' implementation of parametric polymorphism, but it is there, and it is extremely useful. In my experience parametric polymorphism is more elegant and more safe than inheritance. Inheritance (subclassing) has its place in the programmer's cookbook, but for most applications I've worked on, inheritance is actually useful for about 20-30% of the code. Much is algorithmic ('using' the classes, not defining more), and can be nicely made into libraries through parametric polymorphism.

    100. Re:Take Java seriously by 1110110001 · · Score: 1

      6. Dynamic Loading - While C/C++ can manage dynamic loading of shared objects, it's a very difficult thing to implement. Java does it out of the box, with a full reflection API and interface support, thus allowing such wonderful code as Beans, Servlets, Pluggable Drivers, self-organizing code, and a host of other features that other systems can't compete with.

      (If you don't believe me, try adding support for a feature in PHP sometime. "It's so simple! Just install the SO and recompile PHP!" Meh.)


      If reflection and interfaces are all you need for the magic PHP5 should do it fine. And why do I need to recompile PHP to load a SO? Just add an entry to the INI.

      b4n

    101. Re:Take Java seriously by zootm · · Score: 1

      Java's Generics are crippled because there was a specification that they be backwards-compatible, so they're implemented through erasure. Not ideal. C++'s templates are, to the best of my knowledge, Turing-complete, and are not a good implementation of parametric polymorphism, although they do make it possible. Generics are far safer than templates though.

      As for the casting thing, yes, I'm more than aware of that, it's un unfortunate consequence of that sort of language (with, as you point out, inheritance). Java's static typechecking is far better than that of C++, however, and that was my point. There's quite a few languages with far, far better systems still, but they are not really in widespread use in industry.

    102. Re:Take Java seriously by NoOneInParticular · · Score: 1

      I'm not sure that the static type-checking is better in Java than C++, care to give an example? Yes, in C++ it's much easier to break the type-system through static_cast and even reinterpret_cast, but that takes a conscious effort and is by design (C++ tends to get out of your way when you tell it you know what you're doing). As far as I know, the inheritance semantics for the Java subset of C++ is equivalent between Java and C++. But maybe I'm missing something (that, and the covariant return types ;)

    103. Re:Take Java seriously by AKAImBatman · · Score: 1

      Changing an INI still isn't good enough. In Java I have written programs that check for JAR files to be added to a particular directory, then load them dynamically. This is particularily popular in Servlet and J2EE applications as many servers have the ability to dynamically reload a WAR or Enterprise JAR at runtime (with zero system downtime). Any new libraries that you've packaged into the WAR or Enterprise JAR are automatically picked up during the reload.

      Another example is how JSP pages work. Instead of interpreting the page as PHP does, the page is inverted into a Java source file (i.e. all the "..." is turned into 'out.println("...")'), compiled, loaded, and executed at runtime. This is part of what gives JSP a significant performance advantage over PHP.

      But I am happy to hear that you no longer need to recompile. That was always a pain. :-)

    104. Re:Take Java seriously by zootm · · Score: 1

      Argh. I'm actually at work, far from the textbooks that led me to this conclusion, at present. I think the flexibility of C++ is part of the problem, however, the fact that it's possible to break the type system at will makes it less strong by default. Its reliance on pointers (which can obviously be worked around, but then, treating C++ as a programming "construction kit" is an approach that one can end up with very easily) is a pretty big problem too.

    105. Re:Take Java seriously by 1110110001 · · Score: 1

      You can load extensions at runtime in PHP with dl(). It just doesn't make sense. PHP and Java are different languages and that's why you shouldn't try to make things exactly the same. Your Java code keeps running after a request has ended. That's very different to PHP.

      PHP is request based. The code starts with the request and ends with it. The GC runs after the request (unused variables only get marked as such - the memory is freed, when the script ends, but can be reused while executing the script). Thus it buys you nothing to load or unload extensions via PHP. You can safely restart your webserver and won't lose any data or state as you've saved if in a DB or file or somewhereelse and it makes not difference for the scripts if the Webserver kept running or was just restarted.

      Of course you can also use libraries written in PHP like the PEAR stuff and include them ondemand. There's also a new "magic loader" via the __autoload() function in PHP5 that makes it easy to load just the code you need.

      PHP and Java are different. None of them is good or bad because of this. But you have to make things differently to get supported from the language.

      BTW an echo or print in PHP is the same as code outside of . It just looks different in "userspace" or PHP, but the opcodes generated are the same and both add content to the output buffer. What makes PHP slow is the recompiling everytime you call a script. But there are numerous opcode caches to avoid this. So the performance difference gets very small between JSP/Java and PHP. The bigger problem in webdevelopment are databases, or the network or a file storage.

      Choose the language you like, Java or PHP or Perl or Python or Ruby, ... If you use it right you'll have much fun with any of these languages.

      b4n

    106. Re:Take Java seriously by Anonymous Coward · · Score: 0

      You're out of date and out of touch with the current performance of the JVM. It is quite capable of matching (or even exceeding) the speed of native applications.

    107. Re:Take Java seriously by 0kComputer · · Score: 1

      man, the GC is smarter that you, Joe coder.

      Smarter that me? Oh the irony.

      --
      Top 10 Reasons To Procrastinate
      10.
    108. Re:Take Java seriously by Anonymous Coward · · Score: 0

      try pkt. pkt.sf.net

    109. Re:Take Java seriously by Anonymous Coward · · Score: 0

      Most malloc()/free() implementations will tend to return the same chunk of memory for both allocations. Repeating the process a thousand times (which isn't all that uncommon) will probably only dirty a single page of memory.

      Funny thing. One of the most touted features of OpenBSD 3.8 is the new mmap based malloc. It most certainly will *not* return the same page, as this predictability is a security weakness. Returning random pages makes exploits much more difficult because the offset is now an unknown.

      And as a result:
      On average, GC implementations don't have many more pages in use than malloc/free implementations, and may actually have less, but the GC allocators tend to "roam" across the pages.

      is, from a security point of view, actually a Good Thing (tm).

    110. Re:Take Java seriously by petermgreen · · Score: 1

      i was under the impression that the bytecode verifier was only used on untrusted code (e.g. browser 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
    111. Re:Take Java seriously by petermgreen · · Score: 1

      well with windows i can build an app with delphi and even if i elect not to use packages the resulting executable (for a small utility app or similar) is still small enough not to bother even modem users and it will run on pretty much any 32 bit version of windows.

      I haven't done much gui stuff for linux but i know for non-graphical apps free pascal can once again produce an executable that will run on pretty much any linux system.

      And java apps just seem more bloated in general both in how they respond themselves and the affect they have on system performance in general not to mention the fact that few modem users are going to sit through a JVM download unless they have absoloutey no choice.

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
    112. Re:Take Java seriously by petermgreen · · Score: 1

      yes java lacks the ability to put any form of structure or array on the stack and also lacks parameter passing by reference.

      so how do you propose to return more than a single primitive from a function without creating a temporary object on the heap?

      same goes for string handling. making a string an immutable class is pretty much the only reasonable thing to do given the basic environment of java but it means every string you generate and return is at least two more objects (the string itself and its internal array) and quite possiblly more thrown on the garbage pile.

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
    113. Re:Take Java seriously by Anonymous Coward · · Score: 0

      I'm all but completely positive modern JVMs return unused memory to the host operating system.

      The interplay between JVMs and virtual memory managers is being actively investigated. Read the paper Garbage Collection without Paging. The researchers are achieving huge performance boosts.

    114. Re:Take Java seriously by petermgreen · · Score: 1

      by erasure you mean the compiler turns them into non-generic classes and casts (which are always checked in java) at compile time right?

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
    115. Re:Take Java seriously by zootm · · Score: 1

      That's the gist of it, yeah. There's some notes on it here, it brings in a few limitations of its own.

    116. Re:Take Java seriously by petermgreen · · Score: 1

      hmm that page doesn't explain what covariance,contravariance and erasure are at all just rants a bit.

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
    117. Re:Take Java seriously by 0kComputer · · Score: 1

      But hey, never let the facts get in the way of your argument.
      Well, both the examples that you mentioned revolve around multi threaded applications. Maybe you're right in that regard, i don't know. My point is that managed applications will never rival the speed of an application that directly reads and writes from the computers heap. C++'s runtime optimization is perfomed at compile time, by the programmer, you can't beat that.

      --
      Top 10 Reasons To Procrastinate
      10.
    118. Re:Take Java seriously by jilles · · Score: 1

      Yes it's different than what you are used to and no you can't do most of the things you cite (a few you can actually). Most Java programmers don't see that as a problem. Programming Java simply works differently than programming C. If you apply your C skills to Java or your Java skills to C, you are very likely to write crappy software. Both languages require different approaches for solving the same problems.

      BTW. the StringBuffer class solves your problem quite effectively. The immutable String class exists because most of the time Strings actually are immutable. The distinction makes this explicit. The only time this becomes a problem is when people like you don't use a StringBuffer when they should.

      BTW2. the whole point of my previous post is that creating and destroying small objects has little or no consequences in a generational garbage collector. Creation works like this: increment pointer with bytes needed, return pointer. Deallocation works like this: move everything that should survive the garbage collector in the youngest generation to the next generation (typically very few objects because the first generation is for shortlived objects), set heap pointer of first generation back to its initial value. This hard to grasp for C programmers because in C these are relatively expensive operations.

      --

      Jilles
    119. Re:Take Java seriously by zootm · · Score: 1

      Yeah, I'd meant to say that was a small explanation of why the things were used, not why they're there. Erasure is explained in a small amount of detail here:

      Generics are implemented by type erasure: generic type information is present only at compile time, after which it is erased by the compiler. The main advantage of this approach is that it provides total interoperability between generic code and legacy code that uses non-parameterized types (which are technically known as raw types). The main disadvantages are that parameter type information is not available at run time, and that automatically generated casts may fail when interoperating with ill-behaved legacy code. There is, however, a way to achieve guaranteed run-time type safety for generic collections even when interoperating with ill-behaved legacy code.

      Covariance and contravariance are covered quite well here. The main thing is that Generics, unlike return types and (I think) arrays) are contravariant rather than covariant in Java's Generics (and I could be wrong about this, I'm just up and this is roughly what I remember), which confuses a lot of people and leads to various strange-looking constructs.

    120. Re:Take Java seriously by swillden · · Score: 1

      One of the most touted features of OpenBSD 3.8 is the new mmap based malloc. It most certainly will *not* return the same page, as this predictability is a security weakness.

      That's not quite right. For blocks smaller than a page, 3.8 still just carves chunks out of a previously-mmapped page, so for small repeated allocations, the program will likely get the same location. For larger ones, I suspect the kernel will often assign the same physical page, even though it has a randomized virtual address. I hope so, actually, since that will help maintain cache relevance.

      [That GC allocators will "roam" across the pages] is, from a security point of view, actually a Good Thing (tm).

      It's irrelevant, actually, because a GC allocator on 3.8 will allocate a few large blocks from the OS and then roam across them. The GC can't unmap the pages it doesn't need, because when it remaps them they will come back with different virtual addresses, and having contiguous blocks of memory is important to keeping the allocator simple (and fast).

      Perhaps a new GC could be designed to take advantage of the 3.8 scheme, requesting small groups of pages as needed and then unmapping them when they're no longer used. Frankly, the simplest way to do that would be to map them at specified addresses, discarding the randomization. I expect 3.8's mmap does have the ability to map to programmer-specified addresses, since MAP_FIXED is a POSIX requirement.

      In any case, buffer overflows in a JVM's heap are really not a concern. The JVM makes certain that they don't happen. That means it's the JVM implementation must be correct, but that's doable (and arguably done). This brings us right back to the topic of the article because the class verifier plays a very large role in making sure Java classes can't smash the heap.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    121. Re:Take Java seriously by srussell · · Score: 1
      The source:
      121 % cat test.java
      public class test {
      public static final void main( String[] args ) {
      System.out.println("Hey");
      }
      }
      122 % cat test.c
      #include <stdio.h>

      int main( int argc, char** argv ) {
      printf("Hey\n");
      }
      123 % cat test.rb
      puts "Hey"
      The results:
      117 % time java -cp . test
      Hey
      java -cp . test 0.08s user 0.01s system 48% cpu 0.183 total
      118 % time ./a.out
      Hey
      ./a.out 0.00s user 0.00s system 20% cpu 0.005 total
      119 % time ruby test.rb
      Hey
      ruby test.rb 0.00s user 0.00s system 7% cpu 0.101 total
      The breakdown:
      • Java used 2x as much CPU as C, and 6x as much CPU as Ruby
      • Java took twice as long as ruby, and 36 times as long as C
      That's with a trivial app, with almost no classes to load. The difference is much more noticable with even small applications. I have a to-do list manager written in Ruby, Java, and Haskell; this isn't a complex or large application, and Java is noticably and significantly slower than either the Ruby or Haskell version.

      Again, if there's any significant processing, Java's speed starts to make a difference; for any small one-off app, the startup lag is significant. All you've proven is that for sufficiently trivial applications on sufficiently fast computers, the difference isn't noticable.

    122. Re:Take Java seriously by ttfkam · · Score: 1

      Nope, it's used on all Java classes. You are thinking of the Java sandbox. Then again, the sandbox can be selectively used in non-applets as well.

      --

      - I don't need to go outside, my CRT tan'll do me just fine.
    123. Re:Take Java seriously by kaffiene · · Score: 1

      Bollocks. 0.15 Seconds is not a significant start up time, no matter how you spin it. It *is* significant for something you're calling repeatedly in a script, but insignificant for pretty much anything else.

    124. Re:Take Java seriously by NoOneInParticular · · Score: 1

      For both C++ and Java it is trivial to break the type system through casting. In Java it is even the 'preferred' way of using the typesystem (at least until 1.4). Few more weaknesses: the aforementioned covariant return types (meaning more casts in Java then C++), no const-correctness (meaning broken encapsulation in Java), and no way to guarentee non-nullness of 'references' (C++ references are non-null always). So as far as I can see, the C++ typesystem is significantly stronger than Java's as you can program with more guarentees, can actually encapsulate complex data and protect it from change, and you can specify in the language that something is not expected to be null (in Java you need Javadoc to actually document what is expected, the function signature is almost never enough).

    125. Re:Take Java seriously by zootm · · Score: 1

      Are C++ references actually always non-null? Don't most people use pointers to 0 for NULL, and define this in pre-processing?

      Going through the list though, covariant return types are possible in C++, and used, no? There's certainly an equivalent, although I have to say it's been a while since I've played with C++. Const-correctness I'm not sure what you're meaning, but I believe that that's what "final" is for?

      I'm finding this interesting, but I apologise that I've not much time to research stuff at present.

    126. Re:Take Java seriously by NoOneInParticular · · Score: 1
      I'm finding this interesting as well, so I'll just keep on going. Some clarifications

      References in C++:

      void f(Foo& foo) {
      /* foo is guarenteed to be non-null. It can still be invalid, but that should lead to a segmentation fault */
      foo.doSomething(); // dot notation
      }

      void f(Foo* foo) {
      /* foo can be 0 */
      foo->doSomething(); // arrow notation
      }

      The usual idiom is to use the pointer variant in two cases only: if handing over the null pointer is expected by the function, or (obsolete when using 'smart' pointers) when you want to take over the memory. Polymorphism works in both cases (but not with f(Foo foo)).

      Const-correctness. Final doesn't handle this at all for complex types. In C++ you can return 'const' references that will only allow you to call 'const' functions on these references. I.e., you can decide that you will give out some member data through a getter and be sure that the caller cannot change anything in the data. You can ensure this through arbitrary depths. No such thing in Java. Check:

      public class TST {

      private final int[] contents;

      public TST() {
      contents = new int[1];
      contents[0] = 1;
      }

      public final int[] getContents() { return contents; }

      final static public void main(String[] args) {
      TST t = new TST();
      int[] c = t.getContents();
      c[0] = 2; // now I've possibly screwed up the internal mechanics of the class. This can happen by whomever

      System.out.println("" + t.getContents()[0]);

      }

      }

      See how the caller can change the member data inside the TST class? As far as I know, there is no way that you can hand out a reference to a member, without at the same time giving up encapsulation of data. Serious issue. C++:

      class TST {
      vector<int> contents;
      public:
      const vector<int>& getContents() const { return contents; }
      }

      int main() {
      TST tst;
      const vector<int>& c = tst.getContents(); // gets the reference, cannot change
      c[0] = 2; // compile error;
      vector<int>& c = tst.getContents(); // will not compile, type error
      }

      (as a side-note, of course C++ has a way to circumvent its own mechanism: const_cast, but that one falls into the same 'frown' class as reinterpret-cast: something you should almost never use, but if you need it, you need it badly.)

      Finally, covariant return types, this is not possible in Java, right? Simple stuff such as inheriting the 'clone' member and returning the most specific type. This you can do in C++:

      class A { public: virtual A* clone(); }
      class B : public A { B* clone(); }

      And everywhere in your code where the compiler knows you're working with B, you don't need to cast.

    127. Re:Take Java seriously by zootm · · Score: 1

      For the record, if I get fired for doing this at work, I'm blaming you :D

      void f(Foo& foo) {
      /* foo is guarenteed to be non-null. It can still be invalid, but that should lead to a segmentation fault */
      foo.doSomething(); // dot notation
      }

      How is it being "invalid" different than it being null, in any functional sense, though? They both cause runtime errors when they're being accessed, Java just abstracts pointers.

      As for the second example, here's a Java class which should do the same as your C++ one:

      class TST {
      private Vector<Integer> contents;
      public void Vector<Integer> getContents() { return contents.clone(); }
      }

      Admittedly you need to create a new object to prevent modification, but on the other hand if you're using an object-based collection rather than an array (which is generally what you want to do) all the accessor methods would damage the integrity anyway. In general, I don't think Java breaks encapsulation in any serious way — if you want data to be unmodifiable, you just don't let it out. Java's more set towards using objects rather than primitives, in which case the contruct you mention isn't so useful, except in the case of immutable objects.

      As for the covariant return types thing, I'm fairly sure it's possible in C#, but I've not idea about Java, it's not something I've ever looked into (I'm currently coding C#, so the mindset gets kinda jarred back and forth).

    128. Re:Take Java seriously by NoOneInParticular · · Score: 1
      Back from work, and thread not archived yet.

      Invalid vs null. Null is valid and can be used to send a particular message, usually 'object doesn't exist'. Invalid is just a particular programming error that hasn't lead to a segmentation violation yet (viz. RuntimeException). C++ allows memory to become invalid (for a while), that's just the nature of the beast (and a runtime issue, not a typing one). The difference between C++ style references and Java references that a C++-style reference is guaranteed to be non-null is still there, and is still important. Java references: all the disadvantages of references (no pointer arithmetic) combined with the disadvantages of pointers (does this reference actually exist?) ;)

      As for cloning to protect encapsulated data. Doesn't really work in general. Suppose you have a big chunk of data (say 10 MB) in your class and callers need to inspect it in various ways, but shouldn't be able to change it. To actually encapsulate that data you are forced to make a deep clone of the object everytime someone calls a simple getter. This is impractical, and therefore in practically all Java code I've ever seen, getters are always simple functions that just hand out the object with the implicit meaning 'be nice to it, please'. However, this does break encapsulation. This is a big issue I have with Java.

      I hoped that with Java 5 they would've tackled it as in my experience const-correctness makes for much better self-documenting code, but then again, Java apparently is happy with programmers writing javadoc :(

  4. Microsoft should take this approach by craigmarshall · · Score: 2, Insightful

    I'm not sure how the MS beta process works, but I get the impression that it's not just a straightforward download but you need to sign up or something (passport?).

    I wonder what would happen if they junked the whole exclusive beta thing (which might get some of the more privacy-concerned, tech-savvy people on board? dunno - just a guess), and then actively encourage people to try and break the security? Surely that would produce better results than product x coming out, and then massive security problems follow for days, months and years afterwards.

    I'm not pretending that this would cure the world of buggy ms software, but it can't hurt, can it? They should be doing it with vista right now.

    Craig

  5. More on Gilad Bracha by tcopeland · · Score: 4, Informative

    If his name doesn't ring a bell, he's a Java guru who works for Sun and wrote the 2nd and 3rd editions of the Java Language Spec. A bunch of his papers are listed here.

    It's a relief that JDK 1.6 won't include any language changes (as far as I know?). Updating various parsers and whatnot to work with all the JDK 1.5 language changes was a big job, although some of the new features certainly are quite handy.

    1. Re:More on Gilad Bracha by Naikrovek · · Score: 2, Informative

      I believe Java 6 introduces java.io.Console, which provides several convenience methods when using the console, but other than that I don't know of any language changes.

    2. Re:More on Gilad Bracha by tcopeland · · Score: 1

      Cool, yup, right on, I should have said "syntax changes", like new keywords or whatever. At least, I don't think any have been introduced.

      On the other hand, most folks I know are still on JDK 1.4, so I wonder how many people will move to 1.6? I even still get PMD parsing bug reports and whatnot for JDK 1.3...

    3. Re:More on Gilad Bracha by owlstead · · Score: 1

      java.io.Console? That's an API change, not a language change. Language changes would be concerned with the syntax or semantics of Java constructs, not with something inside a package.

    4. Re:More on Gilad Bracha by Surt · · Score: 1

      java.io.Console is just a package. It doesn't require the compiler to handle anything differently, hence not a language change.

      --
      "Who is the Journal of Quantum Physics going to believe?" --Stephen Hawking
  6. "Extreme Scales" ? by DavidNWelton · · Score: 1

    That link doesn't work.

    In any case, the tools that impress me most are those that scale up, but scale down as well too. Google has the money and the brains to make anything work, more or less. What's more impressive to me is technology that lets Joe Schmoe get things up and running easily, and then still scale up reasonably well. I wrote a bit about it here: http://www.dedasys.com/articles/scalable_systems.h tml. Java scores just a bit better on this front than C and C++, because of the big standard library and GC, but it's a long way from perfect, and not as good, IMO, as scripting languages.

    1. Re:"Extreme Scales" ? by tcampb01 · · Score: 1

      Scripting languages are nice to throw some quick and easy stuff together -- but they don't scale. I've had customers who did all the possible optimization they could do to eek out the last bit of performance from their scripted (interactively interpreted - e.g. PERL). They switched to Java because Java (even without HotSpot) gives much better performance. WITH HotSpot it's as fast as binary compiled and linked languages like C. The 'ol "Java is slow" argument is ancient history and just isn't true anymore; hasn't been true for years.

    2. Re:"Extreme Scales" ? by rexguo · · Score: 1

      300+ million J2ME-capable phones out there shows that Java is indeed downward-scalable. Just today nVidia announced a tight-integration of OpenGL ES API with its GPUs for mobile phones.

      --
      www.rexguo.com - Technologist + Designer
    3. Re:"Extreme Scales" ? by Taladar · · Score: 1

      You may argue about the Java platform being better than scripting languages but in terms of developer-time-saving language features (not only the quick-and-dirty ones, the scaling ones too) scripting languages beat Java hands down. Perhaps Sun should try to add more languages to the Java Platform (more official ones, AFAIK there are a few unofficial compilers).

    4. Re:"Extreme Scales" ? by DavidNWelton · · Score: 1

      Hi,

      A few comments:

      "300+ million J2ME capable phones" shows that Sun has some savvy marketing people more than anything:-)

      I do have some experience with j2me - I wrote Hecl for it, and found that it's a fun environment to work with, modulo the inconsistencies between phone models. It's really different from 'normal' Java though - you have to do a lot of things differently, and you have a very limited version of the standard library.

      But in any case, my point was not really with regards to the embedded systems arena, but in terms of scaling down in human terms - being able to get more done faster without necessarily having the most capable developers out there.

    5. Re:"Extreme Scales" ? by Decaff · · Score: 1

      Perhaps Sun should try to add more languages to the Java Platform (more official ones, AFAIK there are a few unofficial compilers).

      Sun is doing exactly that. There is now a JSR (Java Specification Request) for a scripting language interface to Java that is going to be part of the next Java release. There are also two JSRs for scripting languages: Groovy and BeanShell.

  7. MS Anti spyware beta by Anonymous Coward · · Score: 2, Informative
    1. Re:MS Anti spyware beta by craigmarshall · · Score: 3, Insightful

      That's almost what I mean except everyone I know uses ad-aware and spybot S&D, so bugs in MS anti-spyware don't really have the same impact. Also - I can't see anywhere on that page inviting people to break the software, and I can't what security systems the software has that can be "broken into". I don't have lots of time at the moment, so I might have missed something.

      The most damaging problems I see and hear about are related to Windows and Internet Explorer. An open beta of those (I know about the IE7 beta) with encouraged breakage and bug-reporting could do some good. I wouldn't be surprised if you're breaking some license agreement or other (nope haven't read it - just guessing) by trying to trick IE7 or Vista into buffer overflows or whatever.

      Craig

  8. Why not prove it? by jivo · · Score: 1, Insightful

    I am a bit tired of the aproach "Let's just see if it works!". That aproach works well on an old car, but it does not work well on the linch-pin of one of the most important technologies today!

    Why not do what it takes: Prove that it will work, and prove that it cannot be broken!

    Could Java/SUN afford a major flaw in the Java sandbox/class loader...? I think not!

    1. Re:Why not prove it? by fairyliquidizer · · Score: 0

      ...How on earth are you going to prove that it cannot be broken? The only way to possibly prove this in any absolute sense would be to test it with every possible input (i.e. class) and see if it behaved as expected. As this is practically impossible you must target your testing. The problem with targeting testing is that different testers have different ideas of what may break the system so you need to have a decent sized population of testers in order to get any confidence in the results.

      The brute force method that you seam to be suggesting doesn't work, however neither does the opposite extreme of a small team of testers. Wider Beta style testing is necessary.

      The other type of proof method is to prove that the program is logically equivalent to it's spec however this just transfers the burden of accuracy from program to spec and the question becomes "could this spec be broken". It is usually easier to test a program than a spec though.

    2. Re:Why not prove it? by scarlac · · Score: 1, Insightful

      You hit a classic problem with all software. Software cannot be proven to work 100%. You should not try to prove it.
      Software is usually too complex to prove to be stable.

      Why do you think everyone run betas, alfas, preview releases, etc.?

    3. Re:Why not prove it? by Anonymous Coward · · Score: 0

      I think he was refering to the verifier algorithm. If it's correct, then it's a simple matter to ensure that the code implements that algorithm and is bug free (you can't prove that it's bug free, etc., but you can certainly prove that an algorithm does what it's supposed to do).

    4. Re:Why not prove it? by masklinn · · Score: 1
      You hit a classic problem with all software. Software cannot be proven to work 100%. You should not try to prove it.

      Yes they can, it's the mathematical proof of a software.

      It's tough, time consuming, very expensive and requires *the horror* the actual usage of mathematicians, but it is possible to prove a software.

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    5. Re:Why not prove it? by TrappedByMyself · · Score: 4, Insightful

      Why not do what it takes: Prove that it will work, and prove that it cannot be broken!

      Did you just walk out of an undergrad Computer Science class? ;)
      Popping in pre/postconditions and doing line-by-line proofs doesn't cut it for an application of this complexity. While that is an important part of a real process, it doesn't guarentee coverage. You still have to make assumptions about the environment, which is the gotcha. Testing and QA is all about the assumptions you make and the boundaries you set. With a complex application the number of factors grows so large, that you cannot have the resources to cover every possible test. You can grab the most common stuff, but really need to dump it to the community to get the real 'out of the box' thinking hitting it.

      --

      Help me take back Slashdot. When did 'News for Nerds' become 'FUD and Conspiracy Theories for Extremist Nutjobs'?
    6. Re:Why not prove it? by retinaburn · · Score: 1

      I don't see why you have a problem with this, it is exactly what they are doing. They are saying 'help us test it out so we know it doesnt have any major flaws.' They are in fact proving that it works, many hands make light work.

    7. Re:Why not prove it? by jrockway · · Score: 1

      Here's an article about proving software:

      http://www.spectrum.ieee.org/sep05/1454

      If you read that whole issue (Sep2005 IEEE Spectrum), you'll see that the industry realizes they can't afford shitty software anymore. Finally.

      --
      My other car is first.
    8. Re:Why not prove it? by jivo · · Score: 1

      Did you just walk out of an undergrad Computer Science class? ;)

      No - I have a colleague, that used to work for ESA. Proving that software really works as it's supposed to do, is something you do, when you cannot afford the consequence of failure (eg. loss of human life, or perhaps even worse: bad PR...).

      Now, my question for you folks: Could Java afford a failure in this area, or should SUN do what it takes?

    9. Re:Why not prove it? by fuzzy12345 · · Score: 3, Interesting
      Here's a flame to all the respondents to the parent post. They say (if I may paraphrase) "Code verification is hard. I want my MOOMMMMMY!" Well, it's certainly more difficult, in the short run, than the "throw it against the wall and see if it sticks" approach. But it has been done, it isn't as hard as the naysayers are making out, and it's one of those things that you don't improve at unless you try. Google VLISP for an example of a provably correct compiler.

      One thing's for sure: Improvements in software quality will be harder to come by if everybody's attitude continues to be "Bugs are inevitable. Formal proofs are beyond us. Let's keep doing it the old way."

      --

      Everybody's a libertarian 'till their neighbour's becomes a crack house.
    10. Re:Why not prove it? by bdcrazy · · Score: 1

      But proving the software on actual hardware with any possible number of things going on, and with hardware that may or may not contain bugs in its design is much more difficult, if not impossible in the sense it wouldn't be worth it.

      --
      Tonights forecast: Dark. Continued dark throughout most of the evening, with some widely-scattered light towards morning
    11. Re:Why not prove it? by TrappedByMyself · · Score: 1

      Yes they can, it's the mathematical proof of a software. It's tough, time consuming, very expensive and requires *the horror* the actual usage of mathematicians, but it is possible to prove a software.

      No you can't. You can get really close though.
      Mathematics is not a description of how things work, it is only a model of how things work. When you toss it at your code, you still need to make assumptions about the environment which you are proving in. Again, to do these proofs, you need to make a model of the application working in the real world. You can pound out proofs all day about your code, but they will be crap if your underlying assumptions are wrong.
      A really really good mathematician can make really really good assumptions and do a really really good verification of the software, but that is in no way a guarentee that the software is bug free.

      --

      Help me take back Slashdot. When did 'News for Nerds' become 'FUD and Conspiracy Theories for Extremist Nutjobs'?
    12. Re:Why not prove it? by jivo · · Score: 1

      Ok, I think I get your point: It cannot be proved that the class loader will not accept an illegal class. I agree to that part.

      My point is that the class loader (and the Java sandbox) must be bullet-proof, and that part should be proved to be correct. The class loader is a "first line of defence". What must be proved here is that the class loader cannot itself cannot be penetrated.

    13. Re:Why not prove it? by zootm · · Score: 1

      To the best of my knowledge, there's still not a exhaustive proof that Java is typesafe, let alone more complex proofs. The proofs are possible, yes, but they are incredibly time-consuming, and much of the time may not even catch the problems for which you look.

    14. Re:Why not prove it? by TrappedByMyself · · Score: 1

      No - I have a colleague, that used to work for ESA. Proving that software really works as it's supposed to do, is something you do, when you cannot afford the consequence of failure (eg. loss of human life, or perhaps even worse: bad PR...).

      Now, my question for you folks: Could Java afford a failure in this area, or should SUN do what it takes?


      I think you're really just trying to play the evil and incompetent big bisuness FUD card. How do you know Sun isn't doing this already? Also, you're still making the highly flawed assumption that proving that code works guarentees that it is bug free, and makes community testing irrelevent.
      In the applications you're talking about, the environment is highly controlled. Often the hardware and software are specially designed for the system. The software is usually embedded, and has very limited responsibilities and highly controlled inputs. In those cases, you can create a pretty good model of the system, and do pretty good proofs about the code. Its very expensive, but people can be confident about the process. Still not perfect, because again, the sceintists need to create model of the real world, and models are a finite description of an infinite thing.

      Now, going to Sun and Java, they have a highly uncontrolled environment. Their software needs to work securely on spyware infested Windows machines. They can't possible prove everything because they don't know all the influences on their software. Also, the proof process becomes much more complex multithreaded systems. Other threads or processes may change your invariants, which hoses your proof. Again, you can and should for important apps, still throw math at it, however, nothing elimates the usefulness of community testing.

      --

      Help me take back Slashdot. When did 'News for Nerds' become 'FUD and Conspiracy Theories for Extremist Nutjobs'?
    15. Re:Why not prove it? by Anonymous Coward · · Score: 0

      From your post it is obvious that you are at best vaguely familar with the topics you speak of.

    16. Re:Why not prove it? by TrappedByMyself · · Score: 1

      From your post it is obvious that you are at best vaguely familar with the topics you speak of.

      Well, to be honest, I really have no clue about the sort of systems that the ESA builds, so I was really stretching there. However, I'm not backing down on the argument that you cannot do a mathematical proof which guarantees that a complex piece of software is bug free. You can define a set of conditions and prove that the code works against those conditions, but you can never slap on the 100% bug free label.

      --

      Help me take back Slashdot. When did 'News for Nerds' become 'FUD and Conspiracy Theories for Extremist Nutjobs'?
    17. Re:Why not prove it? by arkanes · · Score: 1
      Some CompSci guru (Dijkstra?) once posted some code with the disclaimer that it may not work, as he had only proven it correct, not tested it.

      A proof is in no way protection against bugs - it simply is a proof of the algorithmic integrity of the software. It, of neccesity, doesn't account for any errors outside of the software algorithms (in libraries, the OS, the hardware) and any issues that may arise from those, and more importantly it doesn't actually show that your software actually makes any sense - it's absolutely possible to have proven correct software that does not in fact do the correct thing. The actual usefullness of mathematical proofs in producing bug-free, highly reliable software is somewhat questionable. If you choose to factor in cost-benefit analysis, it becomes *really* questionable.

    18. Re:Why not prove it? by arkanes · · Score: 1
      Of course you do it, but it's constrained so as to be pretty much useless. The worst buffer-overflowing 1st year C programmers calculator can be proved correct if you define it as working in an environment with restricted input. Mathematical proof of *software* is possible, though strenuous and expensive. Mathematical proofs of *systems* are not. Even the highly constrained environments the GP was talking about are verified via testing, not proofs.

      A proof simply verfies, mathematically, the algorithmic integrity of the software. It doesn't address any of the million other issues that can cause software failure. It's an extreme, expensive, limiting tool that's useful primarily in systems where you want the absolute highest reliability, including going well beyond the point of diminishing returns. Even when human life is at stake, that is very rarely done.

    19. Re:Why not prove it? by Coryoth · · Score: 1

      One thing's for sure: Improvements in software quality will be harder to come by if everybody's attitude continues to be "Bugs are inevitable. Formal proofs are beyond us. Let's keep doing it the old way."

      Actually I think the thing that needs to be realised is that verification is not some binary thing where you either do a full exhaustive proof of everything, or do nothing at all. There's a vast sliding scale and you can do as much or as little as you need to do for the given project. We already regularly do a certain amount of verification against a specification! Static types and type signatures for functions and methods are specifications for the method and compiling to see if you get any type errors is verification against that spec. You can be a little more detailed in your specification and maybe have proper pre and postconditions instead of just a type signature. There are tools to do extended static checks (beyond the basic type checks) based on such extra information. You can try and construct formal proofs based on a more detailed specification - you don't have to prove everything, you can just prove certain properties that are important. You can do a top down approach starting with a formal specification and produce the code by progressive refinement, verifying each step along the way. You can do as much or as little suits you.

      We need to realise that being rigorous about your code is not some "all or nothing" thing. If I write a word processor I probably won't care about specifying the GUI in much detail (if at all), but I might add some formal annotations to a few of the backend routines to, for instance, allow me to prove and verify that files won't ever be corrupted even if the program crashes, or that the print preview is guaranteed to produce an image of exactly what will be printed.

      Yes, bugs are inevitable to some extent, and complete formal verification can be more costly than the project requires. That doesn't absolve you from being able to make explicit formal assurances for certain aspects of the program that are important. Software in general would be far better if more software engineers bothered to learn enough about formal specification to use as much as they need in the areas where it is appropriate, rather than just writing off the whole concept as too hard.

      Jedidiah.

    20. Re:Why not prove it? by GileadGreene · · Score: 1
      Software cannot be proven to work 100%.

      No, it cannot.

      But that doesn't mean that all attempts at any kind of proof (either through testing or through formal deduction and inference) are a waste of time. It's not a question of "proving something 100%". It's a question of gaining sufficient confidence that the system will work as intended. How much is "sufficient"? That depends on the application. In some cases, testing is more than sufficient to build the necessary level of confidence. The key thing to keep in kind is that formal logical proofs are able to cover a much wider range of inputs than testing can possibly cover, so for high-confidence applications they start to make more sense. That doesn't necessarily mean that you have to logically prove the entire app, just the "critical" parts (while only testing the non-critical parts).

      As an aside, there's a good case to be made for logical proof actually being more cost-effective than testing - see, for example, this paper.

    21. Re:Why not prove it? by woolio · · Score: 1

      You make some good points... For some types of calculations/applications, generating formal proofs isn't too difficult.

      I have noticed that under some models, actually constructing the proofs (correctly) is more difficult than writing a correct program. Thus, the people who can do such proofs easily are probably less likely to screw up a small routine. (although such proofs may be highly valuable in regression tests).

      I don't know much about LISP, but my limit experience with formal techniques has shown to me that it is difficult to implement an *efficient* correct program that is *simple* to prove correctness. That is if the proof is easy (due to the language), then efficiency is often lacking. Conversely, languages that allow for specializated techniques often are less amenable to formal proofs (e.g. assembly). Functional languages sometimes allow for elegant programs but at the expense of (unnecessary) data copying.

      There is also another verification program that is seldom addressed. Pretend you wrote a function to calculate the arithmatic average of a list of numbers. You formally proved that your function is correct and that the result is indeed an arithmetic average. These proofs do not prevent the programmer from improperly applying this function in their application. For example, if the list of numbers was a list of rates, then the harmonic mean might be a more appropriate average. In other applications, the geometric mean might be more appropriate (e.g. average of a list of gain factors). Even for the same set of numbers, different means may be appropriate under different circumstances.

      No formal language will ever be able to ensure the semantic correctness of programs. For this reason, I feel some types of program errors and security breaches will be inevitable. I see formal techniques a helpful crutch, but not an be-all, end-all solution.

      The parent post does make a good point: There does need to a change in the way people write code.

      Has anyone browsed the Changelog for the most recent Linux kernel? I recall seeing a networking bug that existed since 2.1.x!!!! It is quite scary software has progressed to where it is now almost completely without formal verification!

  9. Aren't QA people supposed to get paid? by Jeff+Hornby · · Score: 0, Troll

    Sounds like a desperate attempt to save a few bucks by not hiring testers: release the software and "challenge" people to break it.

    I challenge Sun to hire a full development team including quality assurance and not put the onus on the community to find their bugs.

    --
    Why doesn't Slashdot ever get slashdotted?
    1. Re:Aren't QA people supposed to get paid? by Naikrovek · · Score: 4, Insightful

      the onus isn't on the community, the onus is on the developers and their QA team. This is just an attempt to get a few more eyeballs on the verifier in case something falls through. There's nothing wrong with that.

      Also it is an opportunity for someone to get recognition for breaking a new peice of software.

      It is important to get extra scrutiny on newly designed peices of software, for it is the new designs that usually break in the least expected ways.

    2. Re:Aren't QA people supposed to get paid? by Deinesh · · Score: 1

      This is above and beond what you can expect from QA. Hell this is above and beond what I would expect from a coder with a PHD in math. What Sun is looking for is h3x0r :D .

    3. Re:Aren't QA people supposed to get paid? by $RANDOMLUSER · · Score: 1

      Because Microsoft's testing procedure works so well, Sun should emulate it?

      --
      No folly is more costly than the folly of intolerant idealism. - Winston Churchill
  10. Re:Condition by Anonymous Coward · · Score: 2, Informative
  11. Re:Java is overrated by zootm · · Score: 1

    I can safely say that Java doesn't suck, but on the other hand, .NET is an extremely nice technology. Java is certainly lagging behind (and has been for some time) in terms of suitability to desktop applications, but it's a solid base and is extremely useful for just about everything else.

  12. dotNET is overrated by dascandy · · Score: 3, Informative

    It allows you to work faster and create more in a short while. It allows you to create abnormally slow programs that you can't even speed up with the willpower to do so, because of Windows internals. Those exact internals that Java won't touch with a stick.

    Java doesn't look like win32 because it isn't even trying to. It's trying to look platform-independant and the same on all platforms, with the option to skin it to any GUI you want. dotNET IS windows. There's no wonder that it looks a lot more like windows.

    I must strongly disagree on the OO implementation however, aside from it not supporting multiple inheritance, it's just good. Microsofts methodics are plain stupid, because for everything you want to do you have to specify it so explicitly my fingers still hurt last time I tried it.

    Compare:

    Java:
    public class xyz {
          int function() { // some function
          }
    }

    public class abc extends xyz {
          int function() { // different, automatic polymorphism
          }
    }

    C++:
    class xyz {
          public: virtual int function() { // some function
          };
          public: int functiontoo() { // some function too
          };
    };

    class abc : xyz {
          public: virtual int function() { // some other function! again automatic!
          };
          public: int functiontoo() { // some function too, not polymorphic!
          }:
    };

    C#: (might contain errors, been a while)
    public class xyz {
          public virtual int function() { // function
          }

          public int functiontoo() { // functiontoo
          }
    }

    public class abc : xyz {
          public override int function() { // override, kind of pointless...
          }

          public new int functiontoo() { // ... why new? that's reserved for memory allocation...
          }
    }

    My point is, .NET (in C#) requires you to make everything you want so explicit that I'm inclined to say that you're wasting time doing that more than you're gaining time due to other factors.

    Plus, I just don't like their idea of a good library. Rape the C++ STL, why don't ya. Either support c++ (and the STL), or don't support it at all.

    1. Re:dotNET is overrated by masklinn · · Score: 1
      I must strongly disagree on the OO implementation however, aside from it not supporting multiple inheritance, it's just good.

      Given the fact that C# does not support multiple inheritance either, you must really know quite a lot about it...

      Oh, and as far as implicit goes, you don't want C# nor Java, you want a dynamically strong typed language such as Python or Ruby, which both - on top of that - consider functions, classes and modules as perfectly regular first-class objects.

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    2. Re:dotNET is overrated by $RANDOMLUSER · · Score: 2, Funny
      I never got the joy of multiple inheritance, anyways.
      I mean:

      "It's a floor wax!"
      "It's a desert topping!"
      "No, it's both! New Schimmel is a floor wax and a desert topping!"
      (This is from early Saturday Night Live for the humor impaired)

      --
      No folly is more costly than the folly of intolerant idealism. - Winston Churchill
    3. Re:dotNET is overrated by flux · · Score: 1

      I think a new keyword for overriding is actually a good idea. Have you never had this happen to you?

      class Foo { ..
          virtual void foo(int a, std::string b) { std::cout << "Default implementation: " << a << b << std::endl; }
      };

      class Bar: public Foo {
          void foo(std::string a, int b) { std::cout << "Custom implementation: " << a << b << std::endl; }
      };
       
      ..and Bar::foo never gets called, and no warnings were issued by the compiler.

    4. Re:dotNET is overrated by Courageous · · Score: 1

      Well, I guess you're trying to be funny. But seriously, it's not about what's being abstracted. Rather, it's about borrowing implementation. Dynamic languages don't usually have 'multiple inheritance' in the classic sense, anyway. They use an approach called 'mixins', which varies in subtle and useful ways from the way that the static languages community is accustomed to thinking about it (has to do with dynamic dispatch...).

      Although, to be fair, you don't see much MI in Python in practice...

      C//

    5. Re:dotNET is overrated by smallguy78 · · Score: 2, Funny

      I believe the place that Java users discuss their religion (and the evils of that new satanic cult C#/.NET that is taking our jobs and women) is comp.lang.java.advocacy

      --
      Nothing costs nothing
    6. Re:dotNET is overrated by zootm · · Score: 2, Interesting

      C# makes a distinction between virtual and non-virtual methods (which is largely used for optimisation which is not available otherwise, as I understand it). The distinction between override (which seems a little unnecessary, but it's arguably better than ambiguity) and new stems from this.

      I wouldn't say there's a huge difference between C# and Java, certainly not of the kind you're trying to imply there is. C#'s syntax is a little closer to C++, not so much the Windows API.

    7. Re:dotNET is overrated by 21mhz · · Score: 1

      Tried to run this, did you?
      Your Bar::foo does override Foo::foo, the lack of virtual specifier notwithstanding.

      --
      My exception safety is -fno-exceptions.
    8. Re:dotNET is overrated by $RANDOMLUSER · · Score: 2, Interesting

      Actually, I was reasonably serious, I just said it silly-like. While I can see an object having multiple begaviors (in Java-speak implementing an interface or two); I cannot see an object having multiple states, which is what's really implied by MI. To me, an (non-trivial) object is about the data it contains, and/or the state it preserves. To say that a thing is both one thing and another (from a data standpoint) in the same breath, to me just smacks of bad design. Again, nothing wrong with having unrelated behaviors, just no unrelated data, please.

      --
      No folly is more costly than the folly of intolerant idealism. - Winston Churchill
    9. Re:dotNET is overrated by 21mhz · · Score: 1

      Oh, sorry, I didn't see the reversed parameters.
      Well, there may be cases when the developer meant this, however bad style it is.
      I guess it wasn't worth making it a special case in the inheritance/override rules, they are complicated enough already.

      --
      My exception safety is -fno-exceptions.
    10. Re:dotNET is overrated by Courageous · · Score: 1

      ...To say that a thing is both one thing and another...

      But who says that one is saying that? This seems like an abstraction issue, with you personally being unwilling to look at the problem from a different abstraction point of view.

      Perhaps you just want an object to have multiple behaviors, and get those behaviors for free? The recommendation here, from the typical representative of the Java crowd, is to say to just hand roll the dispatch. ...which is what's really implied by MI...

      Certainly dynamic languages only /appear/ to have MI. What they do is use /mixins/ instead. Think "dynamic dispatch". MI isn't all bad, you're just not exposed to an entire wing of it -- the effective wing.

      C//

    11. Re:dotNET is overrated by shutdown+-p+now · · Score: 1

      The problem with that is that in languages such as C++ and Java inheritance is the only convenient mechanism of code reuse (and things are made even worse by the fact that it doubles as a contract-enforcing mechanism in C++). If you introduce mixins or other similar concept, the need for MI largely goes away - see Ruby and Sather as two good examples (at the same time, it might be said that you still have MI, only done in such a way as to highlight its code-reusing purpose). Sather is, in my opinion, the language which got it right: strict separation between classes and interfaces; you can implement an interface, and an interface can extend another, but you can never inherit from a class (but you can 'include' it into yours). Take a look at it, it's a very interesting approach.

    12. Re:dotNET is overrated by dascandy · · Score: 1

      There are numerous ways to avoid that, although I must admit that it's an error that stems from not designing your target first, and implementing it later. Which is specifically what VS (and the entire .NET series) would like you to do, given the ease with which you can not design.

      I can honestly say, I program around 10 hours a day and I have been for the past 7 years and I have maybe had that only once. I can't even remember actually having that. Even plain forgetting to override it is more common in my place. Forgetfulness is something those constructs don't help with, just sloppyness and people trying to get stuff done really fast without cross-checking. I don't want my surgeon to take my only good leg in case of a car accident, because he didn't cross-check my leg condition with my patient status.

    13. Re:dotNET is overrated by TummyX · · Score: 1


      Microsofts methodics are plain stupid, because for everything you want to do you have to specify it so explicitly my fingers still hurt last time I tried it.


      Java:

      obj.SetValue(obj.GetValue() + 1);

      C#:

      obj.Value++;

      Java:

      public class C
      {
          private List listeners = new List();

          public void addOnSomeEvent(ActionEventListener l)
          {
                listeners.add(l);
          }

          public void removeOnSomeEvent(ActionEventListener l)
          {
                listeners.remove(l);
          }

          public void fireEvent(ActionEvent e)
          {
              for (Iterator = listeners.iterator(); iterator.hasNext();)
              {
                    ((ActionEventListener)iterator.next()).handleActio nEvent(e);
              }
          }
      }

      someobj.addOnSomeEvent(new ActionEventListener
      {
            public void handlActionEvent(ActionEvent)
            {
                  doStuff();
            }
      });

      C#

      public class C
      {
          public virtual event EventHandler SomeEvent;

          protected virtual void OnSomeEvent(EventArgs e)
          {
              if (SomeEvent != null) SomeEvent(e);
          }
      }

      new C().SomeEvent += delegate { doStuff(); };

      Yeah...I see what you mean

    14. Re:dotNET is overrated by flux · · Score: 1

      Well, I must admit that I can't remember when I've last hit the problem. But that's mostly because I've naturally double-checked with the interface, maybe even copy-pasted the definition, just to be sure it's right. (I suppose IDEs nowadays do that for you.)

      Keywords 'new' and 'override' in the method declaration may be helpful to the guy reading the code, and assuming types are being used with wisdom, it will reduce the need to jump to the definition of the parent class (which I suppose is just a click away anyway).

      During the development phase someone may modify the parent class declaration without realizing that there exists dependencies and thus render the code overriding it ineffective without the compiler blinking an eye.

      I personally see that the slight advantage of less verboseness (writing one word less) given by not using such keywords is smaller than the slight advantage of better documentation and better compiler feedback.

      (For the record: I haven't written a single line of C#, but many, many lines of C++.)

    15. Re:dotNET is overrated by dascandy · · Score: 1

      The world is larger than Java and C#, even in a Java thread.

    16. Re:dotNET is overrated by StrawberryFrog · · Score: 1

      My point is, .NET (in C#) requires you to make everything you want so explicit..

      Those code samples are incredibly similar. Try some lisp or python if you think that's a big language difference.

      The other poster had it right though, C#'s additional features like properties are generally syntactic sugar that make it slightly easier than java.

      And if you want a language that's not "explicit", go code in PHP, and may the lack of strong typing and variable declarations bite you. Knowing if you're overriding or not is a good idea.

      --

      My Karma: ran over your Dogma
      StrawberryFrog

  13. Re:Google by masklinn · · Score: 1

    Toplevel ISPs have issues, not google. It would probably require the whole intarweb to break down to down all of google's various servers.

    --
    "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
  14. Re:Don't believe the hype! by craigmarshall · · Score: 3, Interesting

    > C is portable, fast, very complex and since 35+ years the leading standard for professional OS and APP development.

    I agree that C is portable and fast, however I don't it can be called very complex.

    The smallest programming language manual I have ever owned (and I've owned quite a number), has to be "The C Programming Language", often hailed as the One True Reference to the language. How can it be that complex if the manual is less than half the size of most of my other manuals? I think languages (in general) have got more complex since then. The size of the .Net Framework is huge, there's no way that's simpler than the C standard library. Then you've got to think about reflection, inheritance, dozens of things that C just doesn't have.

    If what you mean is that C programs end up looking more complex, that's probably because C is used for systems programming. If you mean that you have to write more code to do it in C, then you may have a point, but I think C is actually one of the simpler languages. The closer to assembly you get, the simpler the language has to be.

    Craig

  15. Optimization and late binding by jfengel · · Score: 4, Insightful

    Another nice thing about the new classfile specification is that it's going to make certain new kinds of optimization possible. The more you can prove about what's on the stack at any given point, the more you can inline.

    Not only does inlining eliminate method call overhead, but it allows you to re-run the peephole optimizer, which can eliminate range checks, reduce redudant type checks, etc.

    The ultimate performance promise of Java is that it can do optimization very, very late in the process. Native libraries are basically black boxes in C/C++, and it's very hard to do that sort of inlining because most of the type information has been lost. Java may, someday, with sufficient ingenuity, rival or even beat C++ in performance, and it already does in certain limited areas.

    Of course C# has all of the same advantages, and even though it's more recent there are some areas where its performance beats Java. I'd love to see all the Microsoft reasearchers vs. all the Sun researchers coming up with increasingly brilliant ways to take advantage of the late binding to turn a performance hindrance into a benefit.

    1. Re:Optimization and late binding by Curt+Cox · · Score: 1

      That seems roughly accurate, although I'm not so sure the .NET equivalent of bytecodes retain as much information as their Java counterparts. This is really a function of implementation and not language. Compiled Java (like GCJ and its commercial predecessors) has been available for years. Running C in a VM isn't commonly done either, but is definitely possible. I'm sure you realize this, I just didn't want people to be mislead by your post.

    2. Re:Optimization and late binding by Hard_Code · · Score: 2, Interesting

      "Java may, someday, with sufficient ingenuity, rival or even beat C++ in performance"

      For long-running throughput-bound server processes, doesn't it already?

      --

      It's 10 PM. Do you know if you're un-American?
    3. Re:Optimization and late binding by pdbaby · · Score: 1

      .NET assemblies contain a bit more information in their bytecode than Java classes. Especially in the area of generics - the MSIL actually references List (whereas generics in java are just syntactic sugar in the compiler that eliminates casts). I don't know whether Java 1.5 adds extra instructions for foreach loops; MSIL has such instructions - which, to me, makes complete sense: the JIT might even be able to auto-extract thread-level parallelism in foreach loops, especially if they're operations that provably don't interact with the same variables (eg. a foreach loop on a hash that creates a new socket to the key's ip+port and sends the value)

      --
      Global symbol "$deity" requires explicit package name at line 2. - If only $scripture started "use strict;"
    4. Re:Optimization and late binding by Hugo+Graffiti · · Score: 1
      Another nice thing about the new classfile specification is that it's going to make certain new kinds of optimization possible. The more you can prove about what's on the stack at any given point, the more you can inline.

      No, it won't make any difference to the optimizations you can do. You already know what's on the stack at a given point, that's the point of the verifier: to make sure that at a given point in the bytecode you're always dealing with the same types on the stack. This is to prevent (eg) an integer being popped off the stack and treated like an object ref. The new classfile specification just makes it faster to verify because you no longer need to calculate all the possible execution paths and their resultant stack types.

      Also bear in mind that the really useful inlining takes place in JIT-compiled code by which time you've got rid of the notion of the bytecode operand stack anyway.

    5. Re:Optimization and late binding by zootm · · Score: 1

      For what it's worth, the reason that the Java implementation of generics is like this (using erasure) is because the researchers who developed it were told specifically it had to work with old versions of the JVM.

      Then Sun went and changed parts of the bytecode anyway, effectively making that (fairly serious) limitation pointless. Ah well.

    6. Re:Optimization and late binding by Decaff · · Score: 1

      Of course C# has all of the same advantages, and even though it's more recent there are some areas where its performance beats Java. I'd love to see all the Microsoft reasearchers vs. all the Sun researchers coming up with increasingly brilliant ways to take advantage of the late binding to turn a performance hindrance into a benefit.

      The beauty of the Java situation is that it is not just the Sun researchers doing this. It is also the IBM researchers, the HP researchers, the BEA researchers and the open source researchers.

  16. Java 1.5 by Craig+Ringer · · Score: 2, Interesting

    Java 1.5 introduced the two things that make me willing to consider Java as a practical language for real work (as opposed to a "safe to let untrained programmers run rampant, too bad about the 10000k LoC required to do anything" language). Those two things are collections and generics.

    I was forced to use Java 1.2 some time ago, and found it a horrific experience with my background in dynamic languages. Since then, I've learned C++ and got used to the pluses and minuses of static languages (both in the sense of "compiled" and in the sense of "statically typed"). Java also largely ceased to suck, so having to work on it again and finding that sort code that would've been hundreds and hundreds of repetitive lines can now be expressed using a short set of comparitors and a collections-based sort was ... refreshing.

    After Java 1.5, I can understand why they'd want to let things settle down for a while. It seems to me that they finally got all the really important stuff into the language.

    1. Re:Java 1.5 by wzzzzrd · · Score: 1

      Java 1.5 introduced the two things that make me willing to consider Java as a practical language for real work (as opposed to a "safe to let untrained programmers run rampant, too bad about the 10000k LoC required to do anything" language). Those two things are collections and generics.

      sorry, but collections have been around since 1.2, see the api doc.

      I was forced to use Java 1.2 some time ago [...] Java also largely ceased to suck, so having to work on it again and finding that sort code that would've been hundreds and hundreds of repetitive lines can now be expressed using a short set of comparitors and a collections-based sort was ... refreshing.

      uhm, let me get this straight: you think that with java 1.2 you've had to write hundreds of lines of sort code? again, this is wrong, ie so says the api doc.

      i think the big change you talk about took place from version 1.1 to version 1.2. 1.5 adds generics, foreach, autoboxing and what not.

      so for the records: java 1.1 and below: applet crap. java 1.2 and above: java.

      --
      On second thought, let's not go to Camelot. It is a silly place.
    2. Re:Java 1.5 by Craig+Ringer · · Score: 1

      Whoops, you're quite right.

      I guess a third thing changed in the interim - a good five years of programming experience that I didn't have when forced to use 1.2 . I may be a crap programmer now, but man I was awful then. I should also note that I was forced to use 1.2 /for applets/ which might be no small part of my remembered loathing.

      It's a bit sad, actually, given that the languages I'd been using prior to that had sort comparitors, lambda functions, etc so I should really have found the related features in Java. *curses*.

      Nonetheless, Generics are also a big deal for me since I do much of my work in C++ now. No templates? *sob*. Problem solved by Java 1.5 (at least well enough for most template uses that aren't arguably abuse of the template system for complile-time metaprogramming).

    3. Re:Java 1.5 by slashdotnickname · · Score: 0, Flamebait

      Java 1.5 introduced the two things that make me willing to consider Java as a practical language for real work. Those two things are collections and generics.

      Hah! Java generics are laughable, especially if you ever used C++ templates. Java generics are nothing more than syntactic sugar for type-casts, except type-casts are performed at runtime whereas generics are a compile time thing. The consequence of this is that, at runtime, an ArrrayList of integers is indistinguishable from an ArrayList of strings (they'd both show up as an ArrayList of objects).

    4. Re:Java 1.5 by LizardKing · · Score: 1

      Hah! Java generics are laughable, especially if you ever used C++ templates.

      Thanks I needed a laugh. Templates in C++ use a disgustingly unreadable syntax, and don't compensate for the bloated mess that the rest of the language represents. If I ever need to develop another server side system in C++ rather than Java I'll be shocked.

    5. Re:Java 1.5 by Piquan · · Score: 1

      It's not just your experience.

      I'm a grizzled old programmer. I also found Java 1.2 severely lacking. I picked it up again with 1.5, and now it's a usable language.

      Generics are a big deal. I don't care what anybody says about "they're just casts": if you're going to build a strongly typed object-oriented language, you have to have generics. Otherwise, you're violating clean object design by either having casts everywhere, or reinventing the same code by implementing abstract data structures five times to hold five different object types.

      Java 1.5 also has decent introspection capabilities. Any language that relies heavily on objects (e.g., Smalltalk, Objective C, some styles of Lisp) needs to have introspection. Otherwise, your tools-to-build-tools (e.g., Browser, IB, and Inspector, respectively) don't get built.

      It has good locking capabilities. Java likes threads, but threads didn't like Java until it got past the whole thing about only having mutex locks.

      I'm not saying that these are requirements for a non-toy language. I like C, which has none of these. But C doesn't pretend that it's some abstract HLL. It knows the kind of language it is, and is good at being that kind of language. Java didn't, and that made a big difference.

    6. Re:Java 1.5 by maraist · · Score: 1
      The consequence of this is that, at runtime, an ArrrayList of integers is indistinguishable from an ArrayList of strings.

      Except that you can't extract the contents of List as a string w/o down-casting the ArrayList to "List".

      While the hidden assertion below is only syntactic convinience:
      List foo = findFooList();
      int x = foo.get(0);

      The following is very powerful:
      interface FooManager { Out getX(In in); }

      Often trivial interface code allows for the lack of type-safety and a proliferation of run-time-errors-in-the-making.

      So:
      class MyComparator implements Predicate


      {
          int someParam; MyComparator(int p) { this.someParam=p; }
          public boolean evaluate(P p)
          {
                return p.isValueTrue(someParam);
          }
      }

      class Foo
      {
          Predicate myPredicate;
          public void setPredicate(Predicate myPredicate)
          { this.myPredicate = myPreciate; } ...
      }

      If you enforce generics, produce compiler-warnings when generics aren't utilizied, or have an editor which can specify that user-defined generics are not being utilized, then the above code is much more type-safe. Foo can be extended beyond MyPredicate, it doesn't even need to extend or even be aware of MyPredicate to be used by Foo, yet it's much more runtime safe then by just allowing a non-generified "Comparator". Now if only java1.5 standard library defined Predicate. I used jakarta's commons-collections and friends, but as of this time they aren't generified so I've literally had to roll my own; but that's the bueaty of open-source APIs.

      --
      -Michael
  17. Re:Don't believe the hype! by jallen02 · · Score: 1

    I think that one of the big advantages C has is that it is a more simple language. Whereas if you were to write a book on PHP and it had "just the language" you would disappoint quite a few people.

    Though it always amazed me that they had time to go into things like binary trees in "The C Programming Langauge". They write about things like that as if they are perfectly natural to beginning programmers (In truth they are not that hard). I love that book, but most books are so big because readers want documentation on the standard library of the language as well as the language.

    Jeremy

  18. Missing option... by DrYak · · Score: 1
    I think C is actually one of the simpler languages. The closer to assembly you get, the simpler the language has to be.


    Do not underestimate Brainfuck !
    --
    "Sufficiently advanced satire is indistinguishable from reality." - [Tips: 1DrYakQDKCQ6y52z6QbnkxHXAocMZJE61o ]
    1. Re:Missing option... by cabazorro · · Score: 1

      I define complexity as the direct relation of the number of components of something and it's inherent quility of that something that allows anyone to intuit it's function by observing the parts of that something interact.

      c, as defined, is a very simple language, yet with it I have witnesed the creation of programs that have reached a level of complexity non-tractable by humans.

      Reminds me of the story of the shepherd and the king, the chessboard and the grain of rice.
      The shepherd asked the king for one grain of rice, and to duplicate the amount for each
      square of the chessboard. 2^64 grains of rice!

      c is that grain of rice.

      To sum up, to say that c is simple language is equivalent to say that binary is the simplest way to present information. True but not what we really mean by simple.

      I would then define simplicity in a language is the inverse relation between the effort required by an individual to understand the overall functionality of a system written in
      such language and the simplicity of such language.

      The more effort the less simplicty.

      My condensed definition is:
      A complex language lets you do more with less instructions at a small to large scale.
      A simple language let's you do less with more instructions at a even larger scale.

      --
      - these are not the droids you are looking for -
  19. Not execution speed, but predictability by awol · · Score: 3, Insightful

    Look, I wish people who keep banging on about how Java is nearly as fast as C would get their heads out of their asses and realise that the biggest defect in Java is not raw execution speed but the "business processing" holiday that the system takes every "completely unpredictible once in a while". If I have a throughput capacity system, I can control the rate of throughput in a number of ways (eg selling less than my total capacity and then throttling at times of peak use) but when the system goes and does something like a garbage collection and the whole pipe goes "fnark" for a some seconds I am quite pissed since my users who want the service level in their SLA aren't getting it.

    Predictability and execution control are why I use C (and to a lesser extent c++) not Java. That cannot change for languages that give me no control over the raw execution path.

    --
    "The first thing to do when you find yourself in a hole is stop digging."
    1. Re:Not execution speed, but predictability by Phil+John · · Score: 1

      The only thing that gives you "Raw control over the execution path" is assembly language.

      Your c/c++ compiler is going to be making optimisations and tweaks to your code such that you can't exactly predict the way it will be working unless you know the inner workings of it as intimately as the people who work on it..

      Garbage collectors have advanced in leaps and bounds since they were first introduced, gone are the days of the painfully naive mark-and-sweep algorithms. In some cases generational GC can be faster than manual memory management by all but the top 1% of c/c++ experts.

      I challenge your "a few seconds" assertation however and expect it to be nothing more than FUD. If it isn't then your server/s are vastly underpowered for the application and you're insane to be offering SLAs based what sounds like a fairly low available capacity.

      --
      I am NaN
    2. Re:Not execution speed, but predictability by rossjudson · · Score: 1

      Maybe we don't have control over the raw execution path, but we do have control over the command line parameters that control the VM's garbage collection behavior, and engage crazy things like "concurrent collection". Guess you've never really looked at those. And I guess you've also written all of your own memory handling for your C app or your app is stateless, so you can avoid those nasty malloc degradings over time.

      Hard real-time is tough, to be sure, but having such a constraint on 1% of your application doesn't seem like a good justification for writing the entire thing at the assembly level (you did mean _raw_ execution path, did you not?). And even then...what if the OS decides to "disappear" a few of your pages for you? You're in the layer cake. Deal with it. App behavior has far more to do with its performance and responsiveness than its environment does.

    3. Re:Not execution speed, but predictability by Anonymous Coward · · Score: 0

      You have it wrong. The problem happends on a CPU-intensive application.

      When the application is drawing nearly 100% CPU, the low-priority GC thread never gets to run, and the VM keeps allocating more and more memory to keep up with the program's object creation. As physical memory runs low, the OS starts aggressively swapping out rarely-used pages (mostly old pages from the VM). This runs fine until memory runs out altogether. At some point, the next allocation needs to happen and there are no more free RAM pages. So, the OS stops that thread, swaps out a page to free one. Because disk is slow, CPU is handed over to another thread: the GC thread. GC will try to walk all of the application's memory causing massive swapping.

      The way it works out, the next page the GC wants is almost always on disk rather than in RAM. Due to locking issues, while the GC is waiting for a page, the application's main thread cannot run (nobody can call new). The application has to wait for all of system memory to turn over at least once before it can continue to run.

      I have personally seen this happen with delays of tens of seconds. A code redesign to reuse objects rather than reallocate them can easily shave a factor of ten off program runtime. I did it. In C++, I could have kept to OO theory while doing it. In Java, I had to break OO theory. But then, shaving an order of magnatude off the time still leaves it with a delay of seconds. What bites is that if I could have used C++, I wouldn't have been swapping at all.

    4. Re:Not execution speed, but predictability by awol · · Score: 1

      To all those griping about how "garbage collection is really much better" and "In some cases generational GC can be faster than manual memory management by all but the top 1% of c/c++ experts" and in particular saying that "A compiler means you have no real control either; well I am sorry but you are wrong on both counts. First I only used GC as an example and it still stands since the GC whilst perhaps continuous it is still out of my control. As for the compiler issue, my point was not about speed RTFT but predicability and once my compiler has run on my code I can happily be sure that the code will follow the same execution path each time I put in the same data. I have never hand tuned the code but when I find performance issues I can provide more and more business level functionality to help me improve the performance of the core system functions because I know the execution path that is going on under the hood (even if I don't know the sepcific instructions. As for malloc, and other OS resources, you are right creating new ones during running would be a problem which is why we alloc the 3 gig and several hundred semaphores etc at the start of the run.

      As for top 1%, I disagree, but I am certainly starting to care about how I layout my memory structures in RAM because I am suffering too many page faults out of the level1 or level2 cache on the the processor and reading from memory is just non-optimal when that happens, particularly if I can keep the structures I use within one transaction in the cache. Stuff like Java just can't give me that control.

      The responses I saw to the OP highlight the defect I was pointing out in the first place, when you are pushing the edge of a CPUs performance or when your problem space is not inherently parallel then languages like Jave do not cut the mustard. Most Java programmers (C#, and other "interpreted" languages as well) just don't seem to understand this issue.

      --
      "The first thing to do when you find yourself in a hole is stop digging."
    5. Re:Not execution speed, but predictability by The+Mayor · · Score: 1

      And you weren't using the concurrent tenured GC algorithm. Here's a decent article covering JDK v1.4's garbage collection algorithms.

      Your apparent description of the problem (heavy swapping, a GC that runs at low priority) is simply wrong. The problem you were seeing is that there was no available space in the "new" heap space for new objects, so objects were immediately promoted to tenured space. Once the tenured space gets to a certain point (I think the default is 75% full), the tenured GC runs and stops the JVM cold in its tracks (if a naive GC algorithm is used). If there is no space to be reclaimed during a tenured GC, it can take a really long time to run. If your heap is large (>512MB, in my experience), this can take >10 seconds.

      Use the "concurrent" GC algorithm, and these "stop the world" delays are reduced to less than 0.2 seconds, in my experience.

      To use the concurrent GC algorithm, start the JVM with this command-line option: "-XX:+UseConMarkSweepGC". Also, you probably want to do some analysis of the JVM churn of memory. There is a good chance your application may require more "new" space, or different ratios between new & old spaces, and for the survivor space.

      If you are having problems with swapping, buy more memory. I don't think porting the code to C++ will help.

      A better solution to your problem is to quit doing XSL transforms, XPath, or DOM processing of XML documents in a server-side application. The app where you saw these delays did heavy XML processing, right? Yeah, I thought so. Try using a SAX parser, and re-implement your transforms to work on small blocks rather than entire documents. The problem is you are creating too many new objects (something that XML processing does a lot of) without freeing them, causing your "young" space to get filled up before the "young" GC can run. This causes the tenured space to get cluttered with "new" objects, resulting in fragmentation and increased frequency of tenured GCs. That, in turn, causes a "stop the world" response that compounds the problem, since the JVM is spending >30% of its time attempting tenured GCs when there is nothing it can garbage collect (since it is filled with "new" references).

      In a word, server-side XML processing is "Bad".

      --
      --Be human.
    6. Re:Not execution speed, but predictability by Anonymous Coward · · Score: 0

      All wrong. I am not doing any XML parsing, and my application doesn't touch the network except for X. I am doing integer number crunching, and I computed the memory bound for C++ (I know the arch of my machine well enough to report the exact number of bytes). It was 60MB. Why should 256MB not be enough?

      BTW -XX:UseConMarkSweepGC falls down flat. Java version is 1.4.2 when developing this application.

    7. Re:Not execution speed, but predictability by Anonymous Coward · · Score: 0

      heres a word of advice : run, not walk to your local computer store. BUY a fast 64-bit AMD X2 CPU. BUY 1GB of RAM. really. then switch to java. feel the difference. you will be more productive. your code will run nicely. you will have less pain. you will have less bugs. you will have less malloc issues. you will waste less time on stupid optimizations. you will be better off, even if you are $300 or so poorer for it.

    8. Re:Not execution speed, but predictability by Anonymous Coward · · Score: 0

      you must have at least 512MB (preferably 1GB) of RAM to do anything useful (read 3 tier app, intensive simulation or real time processing) with Java.

    9. Re:Not execution speed, but predictability by Anonymous Coward · · Score: 0

      So you probably write your code only for DOS. You know, this modern evil OS, just can swap your code out when you want not....

      Probably, just to be safe, we should program bare bone computer in assembler and with a very minimal OS (DOS is too much advanced).

    10. Re:Not execution speed, but predictability by awol · · Score: 1

      Please. I am deploying on a variety of platforms from 1.5GHz UltraSPARC III to Opterons none of the machines have less than 4 Gig of Ram and the only reason my system cannot do more than the 12000 transactions per second that it can currently do is because the CPU is at 100% all of this is in a resilient (any machine can fail and the system keeps running) environment that can be deployed across a wide geographical area supporting thousands of users. The critical issue is that each transaction needs access to all the data in the system (potentially) and it is not predictable from the data in the transaction alone what that data is and so the problem domain is not (easily) parallelisable.

      So heres a word of advice, not all problems are trivial. When performance is really hard, Java simply cannot compete, not even playing the same game, not even close. System programming

      --
      "The first thing to do when you find yourself in a hole is stop digging."
  20. Re:Don't believe the hype! by Analog+Squirrel · · Score: 1

    If I remember correctly, C has 47 keywords. Everything else is built from them. printf and scanf are not keywords - they're functions built from some character-handling routines(no stings in C, remember?) and the read and write keywords... which is also why you need to put that pesky #include at the top if you want to use them.

    --
    I'd rather be flying
  21. Should have payed more attention in CS class by Anonymous Coward · · Score: 0


    Proving any none trivial Software rapidly hits to much complexity, consider the halting problem alone and not even output and absolute proof's are (O^N) complexity, it is only realistic to prove trivially simple functions.

    1. Re:Should have payed more attention in CS class by masklinn · · Score: 1

      I think that the proof record of a software ATM is 500 000 LOCs of space rocket software.

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
  22. Specify max memory by CustomDesigned · · Score: 1
    While this negates much of the benefit of "automatic" memory management, I avoid the problem you describe by specifying max memory. For instance, a multi-user VM with our accounting applications (no graphics) runs in 1M. The solution to the problem is to use some form of continuous GC (a must for real time Java) - but that increases the GC overhead to where it is comparable to malloc/free. Another solution (though I last used it in JDK1.1) is to call System.gc() at a convenient point. This is supposed to do a complete scan of memory before returning. Again - not exactly automatic, but effective.

    While the "automatic" aspect is oversold, I would not want to give up the bug prevention aspect: you can't dereference stale pointers in Java. That and mandatory bounds checking makes me prefer VM based servers (not necessarily Java) for security reasons. IMHO, GC and mandatory bounds checking should be requirements for all public internet servers.

  23. You idiots by Anonymous Coward · · Score: 0

    This conversation was old two or three years ago.
    And only NOW you're getting around to it?
    Only now?

    And how about staying on topic! Yeee - HAWWWW!
    No sir, none of you really comprehend what the article is talking about, and those that do, sure as fuck don't post on Slashdot.

    So this is what passes for up to date informed thinking here.

  24. Garbage Collection by CaptainPinko · · Score: 2, Informative

    I believe that there is a concurrent garbage collector in Sun's JVM that while not as effecient over-all but runs continously preventing pauses and bubbles associated with traditional garbage collectors.

    I'm my Java in a Nutshell 4th Edition (p. 246) one of the java(the interpreter) arguments is:

    -Xincgc Uses incremental garbage collection. In this mode the garbage collector eun continuously in the background, and a running program is rarely if ever, subject to noticeable pauses while gharbage collection occurs. Using this option typically results in A 10% decrease in performance overall, however. Java 1.3 and later.
    As this book was written for Java 1.4 I'd bet it was fine-tuned and enhance for 1.5 and even more so for the upcoming 1.6. Might be worth trying out.
    --
    Your CPU is not doing anything else, at least do something.
  25. Re:Don't believe the hype! by Anonymous Coward · · Score: 0

    C... Complex?! Yeah right. It's one of the most basic lanauges out there.

    Function pointers are slower than calling a function directly. They are basically what you call virtual functions in C++. C++ provides an advantage by allowing non-virtual direct method calls. It's not that you can't do the same thing in C but it is a lot harder to use. You can't use function pointers in C and expect the same performance as C++.

  26. Re:Don't believe the hype! by bmalia · · Score: 1

    The language may be more simple, but that doesn't mean writing code in it is. I say that because you must write a lot libraries from scratch that would be readily available in a "more complex language".

    --
    There's no place like ~/
  27. Also for 3rd party bytecode generators! by JavaRob · · Score: 1

    Right, it's Sun's "responsibility", and of course if the verifier falls down they will get all the bad press -- but they are giving the rest of us the *chance*, if we want it, to contribute to the security of an essential part of the JVM (because we're the ones who'll be vulnerable if there's a flaw!), PLUS to find out if their new verifier is going to play nicely with the myriad 3rd party tools that manipulate and generate Java bytecode.

    There are tons of alternative compilers out there that turn various languages into Java classfiles. Then there are all of the tools that alter classfiles to add in AOP, or to optimize filesize, or to obfuscate the code against decompilers, etc. etc..

    Obviously Sun isn't going to test all of these, though, for example, some of the obfuscators have historically depended on the specific implementation of the verifier (and NOT the classfile spec) to make tweaks that would break popular decompilers.

    See the reasoning now? Personally I think they should put a bounty on it to recognize the value they're getting out of it (and to help folks justify the time they'd cracking it...) but it's silly to say they shouldn't even have made the offer.

  28. Violation of DCMA? by XNuke · · Score: 2, Funny

    Pardon my ignorance, but isn't this a violation of the anti cracking clauses of the DCMA?

    1. Re:Violation of DCMA? by Anonymous Coward · · Score: 0

      Why would it be?

    2. Re:Violation of DCMA? by Anonymous Coward · · Score: 0

      Only if Hemos took it upon himself to ask people to crack it.. this is coming straight from Sun so its giving permission under the DCMA The DCMA is for UNAUTHORIZED cracking

  29. Re:Don't believe the hype! by Urusai · · Score: 1

    What's really scary is that anyone would think that binary trees might pose even a minor challenge to a programmer. This speaks to the quality of code monkeys being turned out these days.

  30. what the fork is a verifier? by Anonymous Coward · · Score: 0

    The post mentions "verifier" about ten times without definition... so for those of us who are lowly lab administrators and not full-on code monkeys.... eh? What is this and what does its success bode for the adoption of Java?

  31. Re:Condition by Stoned4Life · · Score: 1

    that isn't bad at all.

    --
    Stoned4Life
    gen = new Random
  32. Scripting languages can scale just fine by DavidNWelton · · Score: 1

    There is a large ISP in the US called AOL, which runs on a web server called AOLserver, which is now open source software. The web server makes extensive use of Tcl. Many other large sites use PHP. So, you can make it scale if you want to (although this may involve mixing in some C code).

    Does it scale as well as Java? Perhaps not. The point is that it's easier to get started with the scripting language, though. Your customers probably had an easier time of it getting started with scripting rather than diving into some complex, difficult to implement Java solution. In some cases, I know I wouldn't have had any customers at all if they had had to start out with C or Java rather than a scripting language, which was easy enough that they could at least implement their idea to the point where it made money - and then they could pay me to fix up their code and make it faster, more elegant, and so on.

    In any case, what's interesting to me is the range of scaling - Java does pretty well if you consider the high end, but not so well at the low end. Some scripting language systems don't scale up well enough. The best things start out pretty easy and will grow with you a long way before you have to go implement the big hairy memory intensive Java thing though.

    I do agree with you WRT the speed thing... JITing stuff seems to be a pretty good solution.

  33. Re:Don't believe the hype! by dave1g · · Score: 1

    And the Algol manual/language definition is what, 15 pages long?

    Sit down.

  34. Re:DRM Warning by Anonymous Coward · · Score: 1, Insightful

    AC misunderstands the issue. The class verifier checks that that a program is unable to break out of the "sandbox" infect the system. This is not related to DRM. Hate DRM all you want, but at least RTFA before you post.

  35. I'm pretty sure it's been done by lokedhs · · Score: 1
    I'm quite certain that the new code verification algorithm has been theoretically proven.

    What is going to be tested is the implementation, not the theory behind the algorithm, however. It doesn't really matter how well proven the algorithm is if the implementation has a bug (which could caused by a typo for example).

    Code proving is a nice theoretical excersise, but don't for a second believe that just because some code has been put through a formal proof that it cannot contain bugs.

  36. MaxHeapFreeRatio by rossjudson · · Score: 1

    Cripes. You might want to do a tiny bit of fact checking before posting such nonsense. The JVM can and does return memory to the operating system, subject to parameters that you can easily set on the command line. There's a pair of thresholds (low and high) on the ratio of free space to total heap size. When free space drops below the low threshold, the VM will get more memory from the operating system (up to the MX limit). Conversely, when free memory rises _above_ the high threshold, the overall heap size will _shrink_, and memory is _returned_ to the operating system. Look up -XX:MaxHeapFreeRatio.

    The default high limit used to be 70% -- memory would only be returned to the OS after the heap was measured to be 70% free. Many people will observe their app and say "it doesn't return the memory". It does, but you have to be aware of how this is done.

    You can tighten up this up and have your application run much closer to its "true" size. But do you really want that? You have to study the app in its live environment and understand where the time and memory are going. It can be a good idea, and sometimes it's not.

  37. Someone Remind Me... by h4ck7h3p14n37 · · Score: 1, Troll
    ...why we'd want to test Sun's code for free? Oh, that's right, we get props at either the JavaOne Conference, or on a webpage!
    • If you find a flaw in the specification itself - the design of the Type Checking Verifier as embodied in JSR 202 - that compromises the security of the JDK, Sun will specially recognize and thank you for your contribution to the Java platform at the JavaOneSM 2006 conference, during one of the Day 1 keynote sessions on May 15, 2006, in front of all JavaOne 2006 conference attendees.
    • If you find an ambiguity in the wording of the specification that could allow an alternative, unsafe implementation to be created, or if you find an implementation flaw or coding error in the source code for the Type Checking Verifier in the Java SE 6 JDK, you'll be recognized on a special "Verifier Verified" web page on the JDK Community site, as well as a roll call of contributors that will be included for posterity in the source code itself.

    To make the contest even more attractive, we have to sign a legal agreement to review the source code:

    Anyone may participate, but if you would like to review the source code, you'll need to agree to the Java Research License first.
    Thanks Sun, but no thanks. If you want me to do your work for you, I'd better be getting paid in a cash equivalent.
    1. Re:Someone Remind Me... by Anonymous Coward · · Score: 0

      ...why we'd want to test linux for free?

    2. Re:Someone Remind Me... by Anonymous Coward · · Score: 0

      I'd gladly check Sun's code if it wasn't for that stupid license agreement.

    3. Re:Someone Remind Me... by codemachine · · Score: 1

      Or they could put it under a more permissive license like the BSD license. That way they can include it in their commercial JVM, but it would also let the community that is doing their testing work for them to use it in the open source alternatives.

      Of course that will never happen, because one serious advantage Sun's JVM has is its security sandbox. The open source ones often have something that is nowhere near as secure, if there is any security checks at all (take a look at how much security you'd get if you ran Java applets with the gcj toolset for instance).

    4. Re:Someone Remind Me... by Phil+John · · Score: 1

      Don't forget you can mention it on your CV and in Job interviews, that's sure to impress people in-the-know when you're up for that Java programming job.

      --
      I am NaN
    5. Re:Someone Remind Me... by fantastic · · Score: 1

      C'mmon , Sun only has like $4 Billion in the bank and loans the COO 3.5 Million and got 2 Billion from Microsoft. What do you think they are, made of money?

  38. you have no clue by RelliK · · Score: 3, Interesting
    You obviously have never worked on large server-side applications. Other posters have already listed some reasons for java's popularity. I'll add some more:

    * java is nearly as fast as C++ according to all the benchmarks I've seen. Yes, really. The perception of java as being "slow" is simply the legacy of the old awt apps. Yes, the awt gui was (and is) slow. Server-side java applications are not. The "much better performance" is simply not there, particularly for typical enterprise apps.

    * *All* the enterprise apps (which is the area where java is particularly successful) store stuff in a database and/or talk to remote apps. Newsflash: a database query or a remote procedure call is *orders of magnitude slower* than an in-process procedure call. Once you include DB/RPC into the equation, whatever little speed advantage C++ has is wiped out completely.

    * This is CS 101: performance of a program is largely determined by the algorithm used. You can write a linear search in assembly, and it will be very fast for small lists. But for large lists, a binary search written in shell script will beat it.

    * In an enterprise application scalability is much more important than raw speed. So what if I can write a C++ app that's 20% faster than an equivalent java app? Java has frameworks that make it easy to write an app that you can scale horizontally (i.e. by adding more boxes). Easy being the keyword.

    * Developer's time is much more expensive than runtime. It is *much faster* to write an app in java than in C++. And for all but the smallest/simplest apps it is faster to write the app in java than in PHP/perl/whatever.

    If it's a safety/security issue then again you could build the same thing in a native compiled language, sandbox and all.

    Uhhhm, yes. Safety and security are *big* issues in enterprise apps. Show me *one* native language and platform that does it. You are saying it like one can just wave a magic wand and have it built in no time. "You could build the same thing" is not "it's already built".

    I mean really, is it just because Java provides a lot of easy to use API's?

    Yes. among all the other things I've mentioned.

    These are just a few reasons why java is so popular in enterprise apps. Sure, I wouldn't write a game in java, but for enterprise apps, it's perfect. Why java and not PHP/perl/? Simply because java is better. It has all the advantages of compiled laguages (type safety, variable declaration checking, syntax checking, etc.) without some of the disadvantages (manual memory management). Think of java compiler as a sanity checker for your code. It will catch common mistakes like typos, missing return statements, invalid function parameters, etc. A scripting language will not complain about that, but force you to spend hours tracking down the bug. That's why java is faster to develop in than any scripting language for large apps.

    --
    ___
    If you think big enough, you'll never have to do it.
    1. Re:you have no clue by shutdown+-p+now · · Score: 1
      Developer's time is much more expensive than runtime. It is *much faster* to write an app in java than in C++. And for all but the smallest/simplest apps it is faster to write the app in java than in PHP/perl/whatever.
      This should really be a subitem under "Java has a good set of libraries". There's nothing inherent to Java-the-language which lets you write code faster than in Perl; quite the opposite, actually. Time savings generally happen because you don't need to write it at all - you're already given it, either in the standard library, or a mature 3rd-party one. Not even CPAN can match it, not so much in quantity as in quality.
      Sure, I wouldn't write a game in java, but for enterprise apps, it's perfect.
      It's not perfect. It has an ugly, irrational syntax (C/C++ legacy) and misses several major features common in other modern programming languages (e.g. closures). But there are other reasons (mainly the very rich and sell-standardised frameworks it provides - J2SE and J2EE) why it is still the best tool for the job you described, out of those available. It still has a long way to go to being perfect, though, even by measures of this day - and who knows how far will language design progress tomorrow?
  39. Cross-platform really is a big deal by JavaRob · · Score: 2, Interesting

    What I don't understand is exactly what advantage is Java providing on the server-side. Do you really need cross-platform bytecode at that level?

    Actually, yes -- the cross-platform ability is extremely useful. Speaking personally: the two biggest projects I have worked on, both for one client, are deployed (production) on a IBM iSeries server (these used to be called AS/400s -- using the OS/400 operating system), and a Solaris server respectively. Both web apps are built on the same code base, and we developed and tested them on Windows 2000 workstations (XP, now, plus I am starting to do more and more development in RedHat Fedora).

    Can you imagine if I needed my own iSeries at home to run a test server here? Those things aren't cheap. Also, because the client has more in-house iSeries experience, we're going to be moving the Solaris webapp to an iSeries as well at some point -- and guess what? The Java code doesn't need any changes whatsoever; it's only the database SQL that will need to be migrated (DB2 UDB to DB2400 SQL isn't consistent).

    When I'm starting new projects, I can get people started on architecture and writing code in most cases *without* finalizing the eventual platform, and without getting access to the big hardware yet. You aren't locking yourself into anything from the beginning -- this is actually a pretty serious power to have. It also allows me to run side by side performance testing on servers to see the *real* differences in capabilities; this is HUGE because the folks selling the big iron suddenly are a commodity, not an unquestioned master in a domain with benefits we can't actually measure usefully.

    Just my 2 cents -- I'm sure some people wouldn't actually care (e.g., "my webhost only runs RedHat, so that's all I need to care about"), but gotcha-free cross-platform code is a big deal.

  40. Re:DRM Warning by ultranova · · Score: 1

    Help break the class verifier. Make sure your shackles fit nice and tight.

    Actually, I'm more interested in making sure that the Java applets my browser executes from Web pages have their shackles on nice and tight, so they cant empty my home directory.

    So that you can be sure that your next cellphone will make you pay for every ringtone, and no sploit will allow you to upload your own.

    My phone lets me download MID files from the Net; so I can just upload them to my home page and get them from there. Of course the data transfer costs money, but hacking the phone's Java interpreter doesn't change this.

    --

    Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

  41. Actually by Anonymous Coward · · Score: 0

    I'd like them to add the ability to check the returned value from a function in the Java Debugging Interface API. Like they said they would 5 years ago.

  42. Here are some reasons: by DimGeo · · Score: 2, Interesting

    Java Pros:
    1. Zero memory fragmentation. The GC compacts the memory at runtime. This means indefinite uptimes. A server written in a refcounted script language might lack that.
    2. Zero chance of a buffer overflow attack anywhere. Maybe if there is a bug in the VM, however, this might become possible.
    3. All libraries in the standard distribution have been tested for almost a decade now.
    4. Incredibly powerful multithreading and synchronization.
    5. Rapid development of fast programs. Only someone well versed in Java can do that, but java is well worth it when you have the people. This can be done in other languages but at insane costs in security.
    6. Performance costs for all of the above is within the 20% margin, which is great for a server app that does not do anything computationally expensive. Most of the work is offloaded to a fully optimized DB server anyway.
    7. With the right framework, you can easily load and unload modules at runtime. Not easily done though.

    Java Cons:
    1. Incredibly slow startup time. It may take up to a minute for a large app to get fully loaded and JITed. This is a non-issue in a server environment, however.
    2. Extreme memory usage. Up to 10 x the equivalent C++ app. However, the GC makes sure that memory usage remains almost constant under similar loads for months and years of uptime, because there is no memory fragmentation.
    3. Due to 2, sometimes most of the memory gets swapped. This shouldn't happen in a server environment, but on a desktop running server apps (dev machines for instance) this is a great nuisance. It might take running a full GC manually to force your redmond-developed OS to re-load all the memory for the app. Again, a non-issue for servers.
    4. The default Sun Java VM configuration makes Java run any program with a 64 megs of mem usage limit. This is ridiculous for a serious Java app. It takes passing a command-line param to fix that. People can get frustrated because of this.

  43. Gibson required by millennial · · Score: 1

    If only I could hack the Gibson, I'd have the power I needed to crack the verifier.
    /hack the planet!

    --
    I am scientifically inaccurate.
  44. The old trick by Piroca · · Score: 1


    Simply set -Xverify:none and you'll have no class verifier running in your vm. This is a known, old trick to speed up applications.

  45. Eclipse by Gr8Apes · · Score: 1

    One app that bears the lie to lagging behind on desktop applications.

    If you know what you're doing, you can write pretty decent Java desktop apps.

    --
    The cesspool just got a check and balance.
    1. Re:Eclipse by zootm · · Score: 1

      True, but it doesn't really scale so well as it should, and as it does in other applications. It'll get there, I'm sure.

  46. Re:Don't believe the hype! by VGPowerlord · · Score: 1
    The smallest programming language manual I have ever owned (and I've owned quite a number), has to be "The C Programming Language", often hailed as the One True Reference to the language. How can it be that complex if the manual is less than half the size of most of my other manuals? I think languages (in general) have got more complex since then. The size of the .Net Framework is huge, there's no way that's simpler than the C standard library. Then you've got to think about reflection, inheritance, dozens of things that C just doesn't have.

    I don't like .NET, but I do feel I have to ask this...

    When's the last time you've seen an application written in C that only used the standard C library?

    --
    GLaDOS for President 2016! "Well here we are again. It's always such a pleasure." -- GLaDOS, 2011
  47. Re:Don't believe the hype! by jallen02 · · Score: 1

    I have helped mentor some people with programming. I have taught them just enough of the language to build a more complicated data structure like a binary tree or a hash table. Explain the math, it is all relatively easy, and the logic and most people have no trouble building these data structures. If you teach people these data structures and algorithms for efficiently working with the data structures those things become a part of their programming vocabulary and they can generally solve programming problems more effectively. In general you only need a data structure every once in a while. But when you need it and it is the only thing that really solves the problem nicely it makes all of the difference in the world to have that knowledge.

    Jeremy

  48. Re:Take Java seriously (nope) by Anonymous Coward · · Score: 0

    You forget that accessing all that extra RAM has a cost in time. As CPUs get faster, RAM does not improve at nearly the same speed. To bridge this widening gap, you need L1 and L2 caches (some processors have even introduced L3 caches). But caches only work under the assumption of locality of reference. But as you've said above, GC violates this assumption (they "roam all over the heap"). That makes GC cache-hostile. Hence, as CPUs get faster, the gap in performance between programs using GC versus non-GC will continue to widen.

  49. Re:Take Java seriously (nope) by maraist · · Score: 1

    That makes GC cache-hostile.
    I agree, except that a good generational copier shouldn't traverse beyond the most recently allocated memory.. Even as freshly allocated-and-not-yet-released memory exceeds the nursury size it merely gets lumped into the next generation.. This means that it won't even be looked at for many dozens or hundreds of garbage collects.

    It is only when that particular generation gets refreshed (because that generation is too full to accept the previously younger generations over-spill) that it's memory pages will be touched.

    By putting all the reference handles in a tight continugous space, you also reduce the "touching" of too many pages for the purposes of GC analysis.

    Compared to an allocator slab alloc/free, you have two possibilities: external referencing where a tight continuous space of free-pointer/size data-structures lives (memory handles) and the untouched pages of heap-space, or inlined linked-lists of free an allocated allocation chunks. In the case of inlined, then the process of walking a map on a single alloc and or free is likely to do similar degrees of damage as a minor GC to the CPU cache. If, for example, you use a "best-fit" algorithm, or even a buddy-system, you're going to dance around a non-trivial number of pages that are highly likely to not be in the cache (because they weren't directly in use by the application, and have statistical randomness as to where the traversals take them).

    And don't forget the extreme overhead of compactification. Buddy systems aren't too bad (though I haven't worked closely w/ them), but fitting algorithms can be pretty bad.

    I would agree however that in practice, I've seen more swaps of death from competing java processes than from any other architecture system.

    --
    -Michael
  50. Re:Don't believe the hype! by craigmarshall · · Score: 1

    > When's the last time you've seen an application written in C that only used the standard C library?

    Every single day for the last 4 years, at a guess. There are a heck of a lot of awfully useful unix utilities that don't use anything other than the standard libraries.

    Craig

  51. Re:DRM Warning by davesag · · Score: 1
    My phone lets me download MID files from the Net; so I can just upload them to my home page and get them from there. Of course the data transfer costs money, but hacking the phone's Java interpreter doesn't change this.

    My web browser lets me download files from the web and my mac lets me send them to my phove using bluetooth. I've never been able to unerstand why anyone pays for ringtones or phone sized images since most phones seem to play mp3s anyway these days. mine does and it was a free phone that came with my bottom-of-the barrel vodafone account.

    --
    I used to have a better sig than this, but I got tired of it
  52. Re:Google by Anonymous Coward · · Score: 0

    Toplevel ISPs have issues, not google. It would probably require the whole intarweb to break down to down all of google's various servers

    Umm, you know, google had a big outage a year or two ago...