|
|
|
|
|
by iliketrains
1238 days ago
|
|
Game dev here. The reason is simple - performance. Unlike Java, C# has zero-overhead structs (custom primitive types if you will), so say a Vector3f is just 3 floats in memory, 12 bytes, no object overhead, no pointer indirection. This is a BIG deal. Array of vectors can be just raw data in C#, not an array of pointers like in Java. You can fairly easily map C# structs to C/C++ structs that GPU drivers need. C# even allows fixing struct fields to certain offsets to ensure identical memory layout with other languages. Other features are also critical to performance such as true generics. Say List<Vector3f> in C# is specialized for that type, no overhead from objects, no extra pointers, no casting. In C#, if you are very careful, you can get close to the performance of C++. I don't think the same can be said about Java, because the language does not give you the tools to achieve that. |
|