3 ms·
Some of this isn't true anymore. For example, #2 is wrong: You've always been able to get a reference to an array element (both at an IL level, and at a C# leve
by kevingadd 5y ago
Some of this isn't true anymore. For example, #2 is wrong: You've always been able to get a reference to an array element (both at an IL level, and at a C# level). It used to be somewhat awkward - you would need to pass 'ref arr[x]' to a function - but you can store references in locals now.
Agreed on #3, a lot of the BCL is just miserable in terms of design. There have been improvements lately but I'm still stuck using my own custom containers for various cases.
One good move the BCL and runtime teams have made over time is to just expose more unsafe primitives so you can easily build your own stuff - the Memory and Unsafe classes give you lots of useful tools, Span<T> and Memory<T> let you safely work with memory allocated in various ways, and various BCL stuff has been updated to accept Spans instead of requiring you to use managed arrays.
- t8sr 5y agoThanks, I didn’t know about the expanded use of refs. As the other commenter pointed out, the version of C# used in Unity is out of date by a version or two, and so is my experience.
- ygra 5y agoConsidering we're close to C# 10 by now, it's ... a few more versions ;-) Hard to blame Unity here, though. They have written their own compiler backend that converts CIL to C++ and that was back in the .NET Framework days when performance wasn't that high a priority for language and framework design.
- kevingadd 5y agoTheir transpiler would probably be up to date if they open-sourced it, since plenty of other people would be using it. Instead people are stuck using CoreCLR's AOT backend or other closed transpilers like BRUTE. Their transpiler also had a lot in common with ones for other targets (I know for a fact that in the past it used to be very similar structurally to JSIL) which probably improves the likelihood that they would have been able to leverage community knowledge and contributions here. It's understandable though that they want their transpiler and C#->shader compiler to be their secret sauce, though, since they see them as unique advantages over Godot, Unreal, etc.
- amir734jj 5y agoCan you please explain why #3 is bad for system programing?