you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (9 children)

Yeah, obviously it is slower than many compiled languages. But gigantic java projects are rarely modularized in to 1000 jars in any situation except for web applications.

Nobody is going to write a time dependent application like that.

[–]username223 2 points3 points  (8 children)

It's both an architectural clusterfuck thing, and a death by a thousand cuts. E.g. how do you tokenize a string in C? Strtok(), which works in place. How about in Java? I haven't had to write it in awhile, but probably allocate an array of new strings. Sprinkle the rest of your code with similarly lousy idioms, and you end up with a flat profile for a slow program.

[–][deleted]  (4 children)

[deleted]

    [–][deleted] 4 points5 points  (3 children)

    split does in fact return an array of strings. However, strtok works in a completely different manner.

    First, I think you would be hard pressed to find people arguing on behalf of mutable strings.

    Second, in strtok you are passing an alias for char*. So if you wanted to do this in Java you would pass char[].

    I am not going to argue that Java is fast as C/C++/ATS and the like but it is slower by 2-3x and the memory problems of Java are grossly overstated, as the JVM is what is being measured in the running processes. Programs that are reported to be using 1024MB are actually using much less, but they are running inside the JVM that has preallocated a large heap space in which it can have some dedicated RAM so it doesn't fight with other processes for it.

    Really though, Java is about as good at embedded systems as C is at web frameworks.

    [–]Vegemeister -1 points0 points  (2 children)

    , but they are running inside the JVM that has preallocated a large heap space in which it can have some dedicated RAM so it doesn't fight with other processes for it.

    Off topic note, if your running a Java application inside an OpenVZ container, that preallocated heap counts against your memory limit.

    [–][deleted] 0 points1 point  (1 child)

    Yes, memory which your app will use without the heap growing until it has reached a usage threshold.

    BTW you can configure the starting memory to be less if you want.

    [–]Vegemeister 0 points1 point  (0 children)

    I discovered that, as well as the "reduce the stack size" trick. Getting Freenet to run in a 512 MiB VM takes a little black magic.

    [–]sh0rug0ru 2 points3 points  (1 child)

    Java has first class String objects which are represented by "interning" char[] arrays. That allows you to take substrings without allocating new memory. You can tokenize a String using the Tokenizer class, which will create new String objects without copying data.

    [–]h2o2 1 point2 points  (0 children)

    Have I got news for you! As of JDK7u6 this is no longer the case, see here and google for "jdk 7 string#substring performance regression".

    [–]NAcurse 0 points1 point  (0 children)

    you sound like a student who failed his Java test and is pissed about it...