Great article but what do you think about the allocations caused by LINQ?
As a game programmer I've been taught to avoid using LINQ, especially in scripts running in real-time on the main thread in order to avoid allocations and so sudden frame drops caused by the GC kicking in. Surely a game is not comparable to other types of programs and besides not every LINQ method necessarily allocates (I sincerely don't know). Maybe some of the allocations could be even avoided, like those caused by the Func passed by simply caching them, but then it would lose in readability.
It's a tool like many others .NET put you at your disposal but would you still suggest it for environments like games?
I use LINQ by default. However, I did find while profiling a roguelike's core AI routines that LINQ significantly added to the duration of the application. However, this was a core routine in a genetic algorithm that had to run millions of times.
My suggestion would be to go with LINQ until your data tells you to avoid it in key places, then make those optimizations.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great article but what do you think about the allocations caused by LINQ?
As a game programmer I've been taught to avoid using LINQ, especially in scripts running in real-time on the main thread in order to avoid allocations and so sudden frame drops caused by the GC kicking in. Surely a game is not comparable to other types of programs and besides not every LINQ method necessarily allocates (I sincerely don't know). Maybe some of the allocations could be even avoided, like those caused by the Func passed by simply caching them, but then it would lose in readability.
It's a tool like many others .NET put you at your disposal but would you still suggest it for environments like games?
I use LINQ by default. However, I did find while profiling a roguelike's core AI routines that LINQ significantly added to the duration of the application. However, this was a core routine in a genetic algorithm that had to run millions of times.
My suggestion would be to go with LINQ until your data tells you to avoid it in key places, then make those optimizations.