There is a minor-war going on in Sun Alumni mailing list and elsewhere where the common misconception: “Java is slow” is surfacing again and again, much to the dismay of knowledgeable Java developers who have known for ages that Java is fast even compared to C++ and has been so for several years. Non vi è un minore-guerra in corso in dom Alumni mailing list e altrove in cui il comune malinteso: "Java è lento" è emersione ancora e ancora, con grande costernazione il saperla di sviluppatori Java che hanno conosciuto per le età che Java è anche veloce rispetto in C + + e così è stato per diversi anni. All this re-surfaced because Sun decided to Tutto questo ri-emerse perché ha deciso di Sun change its ticker symbol to JAVA modificare il proprio simbolo a Java (previously it was SUNW). (precedentemente era SUNW). All of this is terribly frustrating to Java developers who take pride in Java and are well aware of its capabilities because they leverage it every day. Tutto questo è terribilmente frustrante per sviluppatori Java che essere orgogliosi di Java e sono ben consapevole delle sue capacità perché si leva ogni giorno. So let’s rest this myth to rest once and for all, shall we? So let's resto questo mito a riposo, una volta per tutte, per così?


Myth 1: Java is Interpreted language and so it must be slow Mito 1: Java è Interpretato lingua e quindi deve essere lenta

Java is currently just-in-time-compiled by the JVM (Java virtual machine). Java è attualmente just-in-time-compilato dalla JVM (Java Virtual Machine). Just-in-time-compilation gives it equivalent performance to compiled applications, sometimes better. Just-in-time-compilazione dà risultati equivalenti a compilare le domande, a volte meglio. Sun’s JIT is not the only one either. Sun JIT non è l'unico. IBM and others provide their implementation of JVM with just-in-time-compilation too. IBM e altri, fornire ai loro attuazione della JVM con just-in-time-compilazione.

You can also compile Java programs in native executables with free compilers like gcj ( http://gcc.gnu.org/java/ ) or paid ones like Excelsior JET ( http://www.xlsoft.com/en/products/jet/index.html ). È inoltre possibile compilare programmi Java eseguibili nativi in libera con compilatori come gcj (http://gcc.gnu.org/java/) o pagato, come Excelsior JET (http://www.xlsoft.com/en/products/jet / index.html).

Java’s slowness is not intrinsic, that is an architectural mis-conception as demonstrated above. Java della lentezza non è intrinseco, che è un architettonico dal concepimento, come dimostrato sopra. But wait there’s more.. Ma aspetta c'è di più ..

Java versus C++ Benchmarks Java contro il C + + parametri di riferimento

Let’s look at some benchmarks comparing Java with C++. Diamo un'occhiata ad alcuni parametri di riferimento a confronto Java con il C + +.

Performance of Java versus C++ by JPLewis and Ulrich Neumann from Computer Graphics and Immersive Technology Lab, University of Southern California Prestazioni di Java rispetto C + + di JPLewis e Ulrich Neumann di Computer Grafica e Immersive Technology Lab, University of Southern California

http://www.idiom.com/~zilla/Computer/javaCbenchmark.html Zilla http://www.idiom.com/ ~ / Computer / javaCbenchmark.html

This article from 2003 finds “This article surveys a number of benchmarks and finds that Java performance on numerical code is comparable to that of C++ , with hints that Java’s relative performance is continuing to improve. In questo articolo dal 2003 trova "Questo articolo indagini una serie di parametri di riferimento e ritiene che le prestazioni di Java sul codice numerico è paragonabile a quella di C + +, con sentori che la relativa Java prestazioni continua a migliorare. We then describe clear theoretical reasons why these benchmark results should be expected.” Siamo quindi descrivere chiaro teorica motivi per cui questi risultati parametro di riferimento dovrebbe essere previsto. "

I would like to quote even further as they gave a detailed explanation about the slowness myth of Java and dispels it thoroughly: Vorrei citare ancora di più in quanto ha fornito una spiegazione dettagliata circa la lentezza mito di Java e si dissipa completamente:

Conclusions: Why is “Java is Slow” so Popular? Conclusioni: Perché è "Java è lento" così popolare?

Java is now nearly equal to (or faster than) C++ on low-level and numeric benchmarks. Java è ormai quasi pari a (o più veloce di), C + + a basso livello numerico e parametri di riferimento. This should not be surprising: Java is a compiled language (albeit JIT compiled). Ciò non dovrebbe essere sorprendente: Java è un linguaggio compilato (anche se compilato JIT).

Nevertheless, the idea that “java is slow” is widely believed. Tuttavia, l'idea che "Java è lento" è opinione diffusa. Why this is so is perhaps the most interesting aspect of this article. Perché questo è così è forse l'aspetto più interessante di questo articolo.

Let’s look at several possible reasons: Diamo un'occhiata alle diverse possibili motivi:

* Java circa 1995 was slow. * Java circa 1995 è stato lento. The first incarnations of java did not java a JIT compiler, and hence were bytecode interpreted (like Python for example). Il primo incarnazioni di java non Java compilatore JIT e, di conseguenza, sono stati bytecode interpretato (come ad esempio Python). JIT compilers appeared in JVMs from Microsoft, Symantec, and in Sun’s java1.2. JIT compiler apparso in JVM di Microsoft, Symantec, in java1.2 di Sun.

This explanation is implausible. Questa spiegazione è plausibile. Most “computer folk” are able to rattle off the exact speed in GHz of the latest processors, and they track this information as it changes each month (and have done so for years). La maggior parte dei "computer folk" sono in grado di sonaglio al largo della esatta velocità in GHz dei più recenti processori, e monitorare queste informazioni come cambia ogni mese (e lo hanno fatto per anni). Yet this explanation asks us to believe that they are not able to remember that a single and rather important language speed change occurred in 1996. Ma questa spiegazione ci chiede di credere che essi non sono in grado di ricordare che un unico e piuttosto importante cambiare la lingua di velocità si è verificato nel 1996.

* Java can be slow still. * Java può essere ancora lento. For example, programs written with the thread-safe Vector class are necessarily slower (on a single processor at least) than those written with the equivalent thread-unsafe ArrayList class. Ad esempio, i programmi scritti con il thread-safe classe Vector sono necessariamente più lento (su un unico processore almeno) da quelli scritti con l'equivalente thread-non sicuri classe ArrayList.

This explanation is equally unsatisfying, because C++ and other languages have similar “abstraction penalties”. Questa spiegazione è altrettanto unsatisfying, perché il C + + e le altre lingue sono simili "astrazione sanzioni". For example, The Kernighan and Pike book The Practice of Programming has a table with the following entries, describing the performance of several implementations of a text processing program: Ad esempio, il Kernighan e Pike libro La pratica di programmazione ha una tabella con le seguenti voci, che descrivono le prestazioni delle implementazioni più di un programma di elaborazione testo:
Version 400 MHz PII Versione a 400 MHz PII
C 0.30 sec C 0,30 SEC
C++/STL/deque 11.2 sec C + + / STL / deque 11,2 sec
C++/STL/list 1.5 sec C + + / STL / list 1,5 sec

Another evidently well known problem in C++ is the overhead of returning an object from a function (several unnecessary object create/copy/destruct cycles are involved). Evidentemente un altro ben noto problema in C + + è il sovraccarico di ritornare un oggetto da una funzione (più oggetto inutile creare / copia / cicli di distruzione sono coinvolti).

* Java program startup is slow. * Programma Java di avvio è lento. As a java program starts, it unzips the java libraries and compiles parts of itself, so an interactive program can be sluggish for the first couple seconds of use. Come un programma Java avvia, unzips le librerie Java e compila le parti di se stesso, in modo interattivo programma può essere lenta per il primo paio di secondi di utilizzo.

This approaches being a reasonable explanation for the speed myth. Questo è un approccio ragionevole spiegazione per il mito della velocità. But while it might explain user’s impressions, it does not explain why many programmers (who can easily understand the idea of an interpreted program being compiled) share the belief. Ma mentre si potrebbe spiegare utente impressioni, non spiega il motivo per cui molti programmatori (che può facilmente comprendere l'idea di un programma di essere interpretato compilato) condividono la convinzione.

Two of the most interesting observations regarding this issue are that: Due dei più interessanti osservazioni in merito a questo problema sono le seguenti:

1. there is a similar “garbage collection is slow” myth that persists despite decades of evidence to the contrary, and vi è una simile "garbage collection" è lento "mito che persiste nonostante decenni di prova contraria, e
2. that in web flame wars, people are happy to discuss their speed impressions for many pages without ever referring to actual data. che nel web fiamma guerre, le persone sono felice di discutere la loro velocità impressioni per molte pagine, senza mai riferimento a dati reali.

Together these suggest that it is possible that no amount of data will alter peoples’ beliefs, and that in actuality these “speed beliefs” probably have little to do with java, garbage collection, or the otherwise stated subject. Our answer probably lies somewhere in sociology or psychology. Insieme questi suggeriscono che sia possibile che nessuna quantità di dati altererà popoli 'credenze, e che in realtà queste "convinzioni velocità" probabilmente hanno poco a che fare con Java, garbage collection, o il soggetto diversamente indicato. La nostra risposta sta probabilmente in qualche parte sociologia o psicologia. Programmers, despite their professed appreciation of logical thought, are not immune to a kind of mythology, though these particular “myths” are arbitrary and relatively harmless. Programmatori, nonostante il loro apprezzamento professi logica di pensiero, non sono immuni da una sorta di mitologia, anche se questi particolari "miti" sono arbitrari e relativamente innocuo.

Here is another benchmark on Java versus C++ Qui è un altro parametro di riferimento rispetto a Java e C + +

The Java is Faster than C++ Benchmark Java è più veloce di C + + Benchmark

http://www.kano.net/javabench/
This was also quoted in JDJ magazine article: http://java.sys-con.com/read/45250.htm Questo è stato anche citato in JDJ rivista articolo: http://java.sys-con.com/read/45250.htm

“I used G++ (GCC) 3.3.1 20030930 (with glibc 2.3.2-98) for the C++, with the -O2 flag (for both i386 and i686). "Ho usato g + + (GCC) 3.3.1 20030930 (con glibc 2.3.2-98) per il C + +, con la bandiera-O2 (sia per i386 e i686). I compiled the Java code normally with the Sun Java 1.4.2_01 compiler, and ran it with the Sun 1.4.2_01 JVM. Ho compilato il codice Java di norma con il Sun Java 1.4.2_01 compilatore, e correva con la Sun JVM 1.4.2_01. I ran the tests on Red Hat Linux 9 / Fedora Test1 with the 2.4.20-20.9 kernel on a T30 laptop. Ho eseguito il test su Red Hat Linux 9 / Fedora Core Test1 con il kernel 2.4.20-20.9 su un T30 computer portatile. The laptop has a Pentium 4 mobile chip, 512MB of memory, a sort of slow disk. Il portatile è un Pentium 4 Mobile chip, 512MB di memoria, una sorta di lento disco.

The results I got were that Java is significantly faster than optimized C++ in many cases. I risultati che ho ricevuto sono state che Java è significativamente più veloce rispetto ottimizzato C + + in molti casi. "
JVM startup time was included in these results. "JVM il tempo di avvio è stato incluso in questi risultati. That means even with JVM startup time, Java is still faster than C++ in many of these tests. Ciò significa che anche con il tempo di avvio JVM, Java è ancora più veloce di C + + in molti di questi test. "

BTW: The article also links to lots of other benchmarks at the end. BTW: L'articolo anche link ad un sacco di altri parametri di riferimento alla fine.

Hopefully I have finally laid rest to the myth of “ java is slow “. Speriamo, ho finalmente a riposo di cui il mito di "Java è lento". It is a perception, a blatantly false perception, not a reality. Si tratta di una percezione, un palesemente falsa percezione, non una realtà. Get over it. Ottenere su di esso.