0 Replies - 730 Views - Last Post: 14 January 2018 - 05:08 PM

#1 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7192
  • View blog
  • Posts: 24,374
  • Joined: 05-May 12

Loving and hating C# 7.2's Span<T>

Posted 14 January 2018 - 05:08 PM

For reference (pardon the pun) see the following articles:
C# - All About Span: Exploring a New .NET Mainstay

I'm loving the use of Span<T> and ReadOnlySpan<T> because I've managed to get a major performance boost for my Karatsuba multiplication implementation in little program for generating large factorials because I considered the problem in the C/C++ thread mildly interesting. I'm not yet to the point of computing factorials of 20 digit numbers, but I'm computing 25000! in under 20 seconds with my 8 year old systems. In fact, when I started using Span<T> for some parts of my code, I got that down to about 4 seconds including JIT time.

I'm hating Span<T> because now I'm writing C# code as if I were writing C/C++ code where I need to keep close attention to where things were allocated, and looking at things at a low level instead of an object oriented point of view. All my work to start thinking functional is devolving back to thinking procedural.

Has anybody else played with Span<T>? What do you think?

Is This A Good Question/Topic? 2
  • +

Page 1 of 1