Re: C# or C++ for Emulator?



Eric <englere_geo@xxxxxxxxx> wrote:
Since C# is JIT compiled, you pay a penalty up front when a class is
entered but after that it's running as optimized native code. Since it
JITs on the target computer and not on the build computer it can even
optimize things in a target-specific manner. Most C++ compiles are
done to the lowest common denominator so they can't take advantage of
extra CPU features a given target may have. To be fair, I don't think
they fully utilize this yet but it's an interesting idea.

You pay a price for C# language overhead -- null pointer checks and such.
The "is JIT faster than native compilation" argument comes up enough that
there's probably a wikipedia page for it. C++ compilers generally have
architecture target flags that default to something relatively current.

You're not going to get the same level of performance out of JIT code
than you would native. However, you'll get the code finished faster and
you'll have fewer lurking bugs if you write it in Java or C# (though you
can cut down on these in native code with tools like valgrind).

Best approach is usually to write the app in the "higher level" language
and write the parts that need to be fast in the "lower level" language.
CiderPress would've been easier to write if I'd used C# (and some parts
of my sanity would not have been lost to MFC).

When you say "error trapping", do you mean "exception handling"? It
does not significantly slow down C# unless an exception is actually
thrown. I guess it's the same for C++ but I am not an expert on that.

If C# works like Java, there is zero overhead if an exception isn't thrown.
C++ exceptions incur a penalty whether they're used or not; code for
embedded systems usually compiles without exceptions to save both space
and time. The difference is largely due to the use of a garbage collector
vs. destructors -- Java doesn't have to explicitly clean up objects when
it rolls up the stack.

--
Send mail to fadden@xxxxxxxxxx (Andy McFadden) - http://www.fadden.com/
Fight Internet Spam - http://spam.abuse.net/spam/ & http://spamcop.net/
.



Relevant Pages

  • Re: Create Visual C++ application fails
    ... Win32 Smart Device Project ... I am not sure what you mean by "target device's SDK (which you must ... display, no network support, no COM support, no .NET Compact Framework ... For native code development, however, that's not how it works. ...
    (microsoft.public.windowsce.app.development)
  • Re: any JIT compilers for Prolog?
    ... to WAM bytecode and saves it in a file.wic ... in it were further compiled to native code (on Sparc ... I wouldn't name the above JIT: it is just a staged compiler whose last ...
    (comp.lang.prolog)
  • Re: JIT compilation question
    ... JIT to run and the time and overhead of opening another file and reading it ... There's also the issue of tracking the environment (security, ... done on a per-user basis. ... Or is the native code cached - and if so, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Pocket PC Deployment
    ... You're going to need ActiveSync on the target PC at a minimum. ... you can use RAPI from native code to copy the files to the device ... the target computer need to have the .net framework on it? ...
    (microsoft.public.pocketpc.developer)
  • Re: I have 2 versions of .NET, which is being used
    ... > John, can you provide more detail on this? ... > initial JIT happens, the IL assembly is compiled down to native code, ... > which time a new JIT assembly is created. ... the temp asp.net files folder do contain the compiled CS ...
    (microsoft.public.dotnet.framework)