From: Ben Voigt [C++ MVP] on


"Jon Skeet [C# MVP]" <skeet(a)pobox.com> wrote in message
news:MPG.22b241bbc4f93330d41(a)msnews.microsoft.com...
> Daniel <Mahonri(a)cableone.net> wrote:
>> What is the difference in definition between clr and jit compiler?
>
> The JIT compiler is just one small part of the CLR.
>
>> Does the use of jit make .NET an interpreted language, or is it still
>> a compiled language, or both?
>
> The code is never interpreted in .NET - always JIT compiled and then
> executed natively (with support from the CLR, of course).

Which occasionally is a performance-killing mistake.

For example, a type initializer. Is there ever an advantage to optimizing
the .cctor? Anything I can think of that could need optimization (anonymous
methods, expression trees, etc) has already been separated by the compiler
before any MSIL is generated.

>
> --
> Jon Skeet - <skeet(a)pobox.com>
> Web site: http://www.pobox.com/~skeet
> Blog: http://www.msmvps.com/jon.skeet
> C# in Depth: http://csharpindepth.com

From: Andrei Varanovich [C# MVP] on
Hello Ben,

>> The code is never interpreted in .NET - always JIT compiled and then
>> executed natively (with support from the CLR, of course).
>>
> Which occasionally is a performance-killing mistake.
> For example, a type initializer. Is there ever an advantage to
> optimizing the .cctor? Anything I can think of that could need
> optimization (anonymous methods, expression trees, etc) has already
> been separated by the compiler before any MSIL is generated.

If you care about performance -- use NGEN utility from .NET SDK. It produces
native code from your assebmly instead of IL.

Thanks,
Andrei


From: Jon Skeet [C# MVP] on
Ben Voigt [C++ MVP] <rbv(a)nospam.nospam> wrote:
> >> Does the use of jit make .NET an interpreted language, or is it still
> >> a compiled language, or both?
> >
> > The code is never interpreted in .NET - always JIT compiled and then
> > executed natively (with support from the CLR, of course).
>
> Which occasionally is a performance-killing mistake.
>
> For example, a type initializer. Is there ever an advantage to optimizing
> the .cctor? Anything I can think of that could need optimization (anonymous
> methods, expression trees, etc) has already been separated by the compiler
> before any MSIL is generated.

Likewise the initialization code for most forms is often executed only
once. I believe that Sun's HotSpot JIT will interpret code the first
time it runs, unless it spots significant loops. The benefit of the
"always JIT, and JIT exactly once" solution is that it's much simpler
than the kind of optimisation HotSpot performs. But yes, there can be a
price to pay.

--
Jon Skeet - <skeet(a)pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon_skeet
C# in Depth: http://csharpindepth.com