Hacker News new | past | comments | ask | show | jobs | submit login

Is there resources to learn this kind of programming in c#? I’ve tried to learn vector, spans, and other lower level features of c#, but I can’t ever find a real world use for them.



Spans are not a low-level feature, they are a general purpose container type representing a slice, like &[T] in Rust. That's it. Analyzers will nudge you to use them naturally next time you write int.Parse(text.Substring(0, 4)) to replace it with int.Parse(text.AsSpan(0, 4)) - you don't need an intermediate string, just a slice of it. But because they can wrap any memory, you can now pass anything to int.Parse that can produce a span of chars or bytes: stackalloc, pointer + length from C/C++, an array, a string, etc. all unified with a single type.

Vectorization techniques themselves are not C# specific, but dotnet/runtime does have an introductory guide that demonstrates their "basic" use-case:

https://github.com/dotnet/runtime/blob/main/docs/coding-guid...




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: