[OT] .net is getting slices

via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 13 23:05:42 PDT 2017


On Thursday, 13 July 2017 at 17:08:38 UTC, jmh530 wrote:
> On Thursday, 13 July 2017 at 14:34:56 UTC, Stefan Koch wrote:
>>
>> It's a stack-only type. Wow. It totally sucks!
>
> Huh? Take a look at the "Using Span" section.

`new T(args)` does not always heap allocation in C#, unlike D.
When `T` is a `struct`, `T t = new T(args)` in C# is equivalent to
`auto t = T(args)` in D - i.e. `t` is allocated on the stack.

I have to agree with Stefan here. Even as a C# user, Span<T> of 
marginal
usefulness compared to D's built-in slices. Yes, it's a much 
needed
improvement for library writers, but still most of .NET's API 
won't
support it for at least several years, so it's essentially 
useless for
application developers. Put on top of that the lack of `const` 
type
constructor, the PITA ref type requirements [1] (quite alien to 
most C#
developers), the inability to use atomic instructions to update it
concurrently, and most of all - being close to unusable in 
generic code.

These kinds of foundational types must be there from the start. 
Regardless
of the .NET Native hype, .NET will never be suitable for 
high-performance
applications. 95% of the frameworks were never written with 
performance in
mind (only ASP.NET Core and EF Core come to mind as written in a 
perf
sensitive manner). Performance was almost always an afterthought.
Consider the following - I have a relatively trivial WPF app that 
undergoes
5-10 GC collections per second during window resize, while being
completely idle otherwise. Even on a desktop Core i7 this looks 
extremely
sluggish. WTF???

[1]: 
https://github.com/dotnet/csharplang/blob/master/proposals/span-safety.md


More information about the Digitalmars-d mailing list