2 ms·
I'm a fulltime Unity lead developer and I love C# as a business logic (or game logic) language, but it becomes quite ugly for hot code that is perfomance-critic
by golergka 8y ago
I'm a fulltime Unity lead developer and I love C# as a business logic (or game logic) language, but it becomes quite ugly for hot code that is perfomance-critical. Once you get thousands of objects that you have to process every frame, you have to throw the usual C# object-oriented style and things like Linq (and I'm a fan of Linq!) out of the window and write code that reads like C. And when you get to object pools, well, that's practically the same thing as writing your own allocator (only instead of allocating arbitrary memory, you allocate objects).
Seriously, for this kind of tasks there's nothing better than C/C++ - and I write this as someone who is actively AFRAID of power of C++ and uses less powerful tools whenever and wherever possible (because I don't want all that power to shoot in my own leg).
- fsloth 8y ago"things like Linq" It's really easy to accidentally create a simple Linq query that underneath turns into O(N^2) and suddenly the production application crawls to a halt. Actually happened.
- golergka 8y agoThat's why you should know where to write code optimized for perfomance and where to write code optimized for readability. It's the latter 95% of the time.
- pjmlp 8y agoNo one said that one needs to use LINQ with C# all the time. Likewise no one is using C++ with MI and 9 level deep hierarchies for game engines anymore. C++ is one of my toolbox languages, which I know since C++ARM days, yet I am also open minded that it shouldn't be the only way. I am old enough to remember when C, Modula-2, Basic and Turbo Pascal, AMOS were the "Unity" of MS-DOS/Amiga, because for this kind of tasks there's nothing better than Assembly and everyone had a copy of Zen of Assembly Language. Then the speech was updated to there's nothing better than C when compilers improved, and it took PS 2 with its C++ SDK to eventually force game devs to grudgingly accept C++. Which now reigns on all things GPGPU, but it doesn't mean we should be happy with just one language. And even though it is one of my favorite ones, I dislike the lack of modules (maybe C++23 with luck) and the copy-paste compatibility with C that endangers the software I use written with it, because on many teams static analyzers and guidelines are foreign words.