4 ms·
C# needs them to use them in their own frameworks. GC'd languages has a benefit that Strings can work different then C strings and you get things like interning
by jabart 3y ago
C# needs them to use them in their own frameworks. GC'd languages has a benefit that Strings can work different then C strings and you get things like interning to reduce memory usage. Now C#(dotnet) took it a step further and put in a bunch of optimizations on strings called Spans which is like a block of memory but in a safe friendly way. Now back to intrinsics, you can take a Span, shove it into a vector and poof, you have string matching. You can also use a memory safe image processing library and get intrinsic optimization for scaling, conversion, etc.
I think there is also a buffer pool of spans in asp.net that uses spans to manage all the data coming and going from headers then tosses out the exact same headers while using one copy of it then giving that memory back to the next without having it GC'd. Web servers need a fast response time to serve more requests per a second with less resources and it's all strings all the time dealing with it. Some fancy Spans and Intrinsics baked into the framework give those gains to every call in a C# app.