Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Java is a high-level language and its reputation nowadays is to have performance on par with other, comparable high-level languages.</p> <ol> <li><p>It has <a href="http://en.wikipedia.org/wiki/Dynamic_binding_(computer_science)" rel="nofollow noreferrer">dynamic binding</a> semantics. Compared to C++ where non-virtual methods are compiled as function calls, even the best Java compiler in the world has to produce code that is less efficient. But it's also a cleaner, more high-level semantic.</p></li> <li><p>I do not remember the details, but I heard in the early days of Java that there was a mutex per Java object, to be acquired and released by each method. That tends to make it better adapted to concurrency, although unfortunately just a mutex per object will not protect you from races or deadlocks or any of the bad things that can happen in concurrent programs. That part, if true, is a little naive, but it came from good intentions. Feel free to fill me in on the details if you know more about this aspect.</p></li> <li><p>Another way in which Java is a high-level language is by having <a href="http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)" rel="nofollow noreferrer">Garbage-Collection</a>. Garbage-Collection may be slower than <code>malloc</code> and <code>free</code> for programs that allocate at once all the memory they need and work with that. The problem is, in languages that do not have Garbage-Collection, programmers tend to write <strong>only</strong> programs that allocate all the memory they need at once and fail if it turns out some arbitrary maximum size constant has been overflown. So the comparison is apples to oranges. When programmers make the effort to write and debug programs with dynamic allocation of chained structures in non-GC languages, they sometimes find that their programs are no longer faster than in a GC language, because <code>malloc</code> and <code>free</code> are not free! They have overhead too... Plus, not having a GC forces to specify who frees what, and having to specify who frees what in turn sometime forces you to make copies — when several functions are going to need the data and it's not clear which will be using it last — whereas copying wouldn't have been necessary in a GC language.</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload