Ah, worrying about JIT vs native code is all too often a meaningless
exercise. Consider that applications spend most of their time waiting.
Waiting for disks, video retrace, waiting for the server to answer a (dumb)
question, waiting for the net to respond and (most of all) waiting for
the
user to come back from lunch.
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Sahil Malik [MVP] wrote:
Maybe in very specific situations it can be. Maybe in future the
balance will tip, but in general native code is faster, don't you
think?
Managed code has the overhead of the CLR and JIT which consume cpu
time. native code doesn't have that. On the other hand, native code
lacks information about code usage at runtime. This means that it has
to perform compile-time optimization and hope for the best at runtime.
In theory, you can argue that a JIT can produce faster code at runtime
because it knows the code usage patterns and can therefore decide some
code path is faster, based on information available only at runtime.
native code doesn't have that, which can lead to slower code.
That is, in theory. Deciding what's faster eats time too, and the more
time spend on deciding what's faster, the less time is gained.
Another optimization trick for managed code is that it performs code
analysis at compile time like native compilers do, and instead of
optimizing the code in full, it places JIT hints into the IL, so at
runtime the JIT will be faster in deciding what to do, as it knows up
front what lays ahead (because that's already analysed at compile
time). I believe sun's hotspot system uses these.
MS research has said that within a few years time, managed code is
faster than native code. That is to be seen though. A lot is needed in
the JIT department to get everything as fast as it should be.
FB
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
Actually, managed code can be faster than native code due to CPU
specific optimisations.
Perhaps now there aren't many optiomizations compiler does, however
in future we should se more of them.
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
Blog:
http://cs.rthand.com/blogs/blog_with_righthand/
SLODUG - Slovene Developer Users Group
www.codezone-si.info
Managed Code can never be as fast and as optimized as native code.
Why not?
I have the idea about the opposite.
I make it short otherwise you probably don't understand the
question.
--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET:
http://www.llblgen.com
My .NET blog:
http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------