Getting back to the original post:
Just out of curiosity, I heard that game engine is mostly written in C++ because it is faster. But I don't know what kind of optimization C++ can offer over C#, can someone give some highlights so I can have general ideas of it
The myth that C# is inherently slower than C++ is exactly that: a myth.
There are similar myths that Java was inherently slower than C++, and they are also a myth.
Early compilers in both languages were very pessimistic in optimization and did generate slower binaries. Those very early tools have evolved.
There are facets of the libraries that are faster, and facets of the libraries that are slower. But the languages themselves are equal.
C++ is the core language in large part because experienced programmers know c++ and know how to get solid performance out of it. When engines must be cross-platform it is currently easier to use c++ because the third-party vendors provide c++ based interfaces; the network effect has locked that language in power for the time being. That is changing rapidly as many third party vendors are clearly moving toward C# as their preferred interface.
What you say about speed is just not accurate, c# and java are significantly slower when executing high work loads. There is a reason they develop their environments in c/c++. And there is a reason that hard ware manufactures write their drivers in c. These languages are faster, and are less waste full in memory as well.
When you take an experienced c++ programmer and try to turn them into competent Java or C# programmers, there is a clear learning curve as they must re-learn what patterns are expensive to use and which are cheap.
It is easy to write poor-performing c# code if you are not familiar with the language, and most experienced game engine developers are not very fluent in c#. It is difficult for those experienced developers to make the transition.
Many of the up-and-coming developers are able to write more high quality code in C# than the experienced C++ developers could do in C++. Few developers need to know raw assembly any more because there are more productive tools out there. My studio has been mostly in C# for six years now, and the difference between our c++ and C# code is incredible. There was a brief learning curve and migration cost, but it has been more than made up for by performance in creating games. It is easier to put more in the game, and our results are at least as good. It is easier to find skilled C# programmers who can write performance-critical code than it is to find C++ developers who can do the same.
A lot of what you say here is a bit whatever. However lets look at something. In windows 8 you can program in c++ however it is an interesting dialect of c++. There are no naked pointers. Instead they have what is really just a shared_ptr operator ^ .
This means there are absolutely no memory leaks in their version of c++. You can do this without using windows 8 if you wish. So you get the best part of C# in c++. It is rather genius I might add. And there is no need for garbage collection, everything is deleted properly. There is no garbage collector, and everything runs very fast. This is interesting because 2 of the major reasons developers chose c# over c++ is that c++ is very error prone due to miss use of pointers, including memory leaks. The other reason is that c# is easier to use. C++11's main goal was to clean up the language and make it easier to use, learn, and harder to create bugs. They really did a good job of that. So what you have here are the 2 of the top reasons people chose c# over c++ now fixed.
There is very clear motion in the works. From my perspective nearly all our tools are written in C#, and a good portion of our engine and most of our game code is written in C#. Mono runs great on all the major consoles, and there is no need for JIT compilation since the tools can emit the fully-optimized binaries if you pass the right arguments.C++ is enjoying a huge resurgence because of c++11, even Microsoft creators of c# has been "Going Native". In fact they are so sold on c++ they have been investing in it. They paid for the new http://isocpp.org/ website for example, and have fitted the bill for many things the c++ organization needed this year.
The OP (and many others) have just made the assumption that C# is slower or more cumbersome. I heard the same thing in the 90s that C++ was bloated and more cumbersome than C. I read the same arguments in the 80's that C was painfully slow and could never replace the skilled assembly-writing artisan.
This is true, but what changed? Computers got faster, much faster and the cost of the more expensive language features became affordable.
The question has never been "will c++ be replaced", but "when". I believe we passed the tipping point a few years ago. It is now more difficult to get a seasoned C++ developer than to get a seasoned C# developer who is also more productive overall than that c++ developer.
Actually c++ is seeing a large resurgence in the industry due to being significantly upgraded to c++11, you realize that all these "Modern" languages have been getting patches and upgrades while c++ hasn't had new features added since 1998 and it still is in heavy use today, that says a lot. Not only has this changed with c++11 but they now have a complete structure in place to be able to release new upgrades to the c++ language every couple of years. In fact there are upgrades planned for 2013 and 2014
With that said, c# is a fine language, I like that language too. For a long time c# has been gaining ground and for good reason. It's been getting updated with features and things while c++ hasn't.