Also limits on number of people in given time who can write optimal C code vs C# will also make managed code better.
Also limits on number of people in given time who can write optimal C code vs C# will also make managed code better.
Now, I could be talking out of ass, haven't done enough C/C++ coding in over a decade.
And the intel C++ compiler has provided significant performance for decades via optimization without needing to optimize by hand.
The inlining of virtual calls is the critical optimization that enables this. Because C/C++ is optimized statically and never at runtime, it is unable to optimize results of function pointer lookups (in C, and thus also virtual calls in C++). However, the JITs can inline through function pointer lookups.
In sufficiently complex programs, where polymorphism is used (i.e. old code that calls new code without knowing about it), this yields an unsurpassed speed advantage. Polymorphism is critical to managing complexity as an application evolves (even the Linux kernel, written in C, uses polymorphism, e.g. see struct file_operations).
These are then subsequently wrapped by `Span<T>` and `ReadOnlySpan<T>` respectively. This way a span can be a slice of memory that can have any origin:
var fromStack1 = (stackalloc byte[32]);
var fromStack2 = (Span<byte>)[0x20, 0x20, 0x20, 0x20];
var fromHeap = new byte[32].AsSpan();
unsafe
{
var ptr = NativeMemory.Alloc(32);
var fromMalloc = new Span<byte>(ptr, 32);
// Don't forget to free :)
}Ignoring the type systems from Eiffel, Objective-C, Oberon and Modula-3 linage, even though they were inspirations for Java, has been shown to have been a bad decision in hindsight.