View Single Post
Posts: 3,319 | Thanked: 5,610 times | Joined on Aug 2008 @ Finland
#171
Originally Posted by zimon View Post
Why VM wouldn't know about physical memory layout and architecture? There is not reason VM couldn't be clever like that.
Because it has no HW level access and only knows whatever the kernel tells it to. It's been a problem even for native apps, every now and then somebody thinks that the OS is not smart enough to deal with memory on a large scale and tries to implement their own tricks (to outsmart swapping, etc). This invariably either backfires or has very specific use-cases.

In the (in)famous "Java will be faster and C++" tells also that VM can also know how many and what kind of processors (how many registers, what is the size of L2 cache) the platform where it is running has. It can monitor page fault rate especially in multi-core platforms or if a program is interactive and sometimes is not doing anything. On the other hand, fully compiled C++ code cannot be optimized so well because it has to fit to some minimum common architecture or have multiple compilations.
This was the promise 10 years ago when I was heavily involved with Java, however those super-HW-optimized JVMs have never materialized. What has materialized were various JSRs which are mostly hated very passionately as they managed to make Java one of the (if not THE) most fragmented mobile platform.

Of course C++ can be also JITed and interpreted, but then why use C++ after that when there is Java which seem to be more productive than C++, easier to maintain, easier to read, easier to fix and find bugs?
Easier to read ? Maybe some templates or non-Qt stdlib code, but other than that... I for one don't miss Java's verbosity. Plus C++ is most of the time faster even without JIT, exists on far more platforms and hasn't got the problem of a megacorp deciding it's (and its developers) fate.

It is probably true, not yet for example Dalvik has all these fancy optimizations, but if it lives long enough it will, especially now when mobile platforms have started to get multiple CPU cores.
Actually that's one of the shortcomings of Java - people seem to be using threads by the boatload (mostly inertia as AIUI it's not necessary since Java 5), and threads make those optimizations nigh impossible. And we know that, as Alan Cox said, threads are for people for don't know how to program state-machines

But anyway, we're running in circles for some time now. You say it will be better - I say, whatever floats your boat, but reality can be really uncooperative when it comes to these academic explorations. Over and out.
__________________
Blogging about mobile linux - The Penguin Moves!
Maintainer of PyQt (see introduction and docs), AppWatch, QuickBrownFox, etc
 

The Following User Says Thank You to attila77 For This Useful Post: