C++ performance vs. Java/C# -


my understanding c/c++ produces native code run on particular machine architecture. conversely, languages java , c# run on top of virtual machine abstracts away native architecture. logically seem impossible java or c# match speed of c++ because of intermediate step, i've been told latest compilers ("hot spot") can attain speed or exceed it.

perhaps more of compiler question language question, can explain in plain english how possible 1 of these virtual machine languages perform better native language?

generally, c# , java can fast or faster because jit compiler -- compiler compiles il first time it's executed -- can make optimizations c++ compiled program cannot because can query machine. can determine if machine intel or amd; pentium 4, core solo, or core duo; or if supports sse4, etc.

a c++ program has compiled beforehand mixed optimizations runs decently on machines, not optimized as single configuration (i.e. processor, instruction set, other hardware).

additionally language features allow compiler in c# , java make assumptions code allows optimize parts away aren't safe c/c++ compiler do. when have access pointers there's lot of optimizations aren't safe.

also java , c# can heap allocations more efficiently c++ because layer of abstraction between garbage collector , code allows of heap compression @ once (a expensive operation).

now can't speak java on next point, know c# example remove methods , method calls when knows body of method empty. , use kind of logic throughout code.

so can see, there lots of reasons why c# or java implementations faster.

now said, specific optimizations can made in c++ blow away c#, in graphics realm , anytime you're close hardware. pointers wonders here.

so depending on you're writing go 1 or other. if you're writing isn't hardware dependent (driver, video game, etc), wouldn't worry performance of c# (again can't speak java). it'll fine.

one java side, @swati points out article:

https://www.ibm.com/developerworks/library/j-jtp09275


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -