Coffeehouse Post

Single Post Permalink

View Thread: is managed code faster than native?
  • User profile image

    Dynamic languages versus static languages is easy: dynamic languages need more runtime checks and an embedded parser in order to run code. Static languages get to remove certain checks (e.g. C++ doesn't need to decide if a variable should use an ADD opcode to add two integers or an FADD or possible a full-blown strncat, whereas PHP given a random variable doesn't know until runtime.

    Managed languages versus unmanaged ones is less obviously one side or the other - managed languages get to take certain optimisations based on runtime data that static ones can't do, whereas static languages get to make slower, but ultimately more effective optimisations because they're not under pressure to return quickly so that the runtime isn't held up by the JIT.

    Similarly the heap versus the GC are much of a muchness. The GC has to do expensive collects, but native heaps have to do expensive free-block coalescing and lose performance due to stuff like fragmentation pushing up the working set of the process and hence accesses being more likely to fault.

    What I would really like though is the ability to tell C# to compile my app down not to CIL but to x86 and for it to burn in or link to a GC implementation. If it could strip all symbols, types and reflective information from the binary like I can strip PDBs from C++ that would be extraordinarily awesome too.