3 ms·
Expressions (LINQ) are the most powerful feature available in C#. There isn't much you can't do with them if you get a bit clever. I can't imagine how many tota
by bob1029 3y ago
Expressions (LINQ) are the most powerful feature available in C#. There isn't much you can't do with them if you get a bit clever. I can't imagine how many total hours of development time these abstractions have saved. I also find it relatively easy to explain these bits of code to non-developers. Performance is a common argument for not utilizing code like this, but modern .NET does all kinds of insane runtime optimization techniques to make sure things go fast (if they need to!).
We just recently started looking at using EFCore (instead of raw SQL via Dapper) and it is dawning on me that it was a strategic mistake to not further utilize the leverage that expressions can bring to the party.
- louthy 3y agoIf you want to see this taken to the max, then my library [1] has many monadic types (which is what LINQ is for) implemented. Including an implementation of Haskell Pipes [2], with some examples [3] [1] https://github.com/louthy/language-ext https://github.com/louthy/language-ext [2] https://louthy.github.io/language-ext/LanguageExt.Core/Effects/Pipes/index.html https://louthy.github.io/language-ext/LanguageExt.Core/Effec... [3] https://github.com/louthy/language-ext/blob/main/Samples/EffectsExamples/Examples/TextFileChunkStreamExample.cs https://github.com/louthy/language-ext/blob/main/Samples/Eff...
- lacrimacida 3y agoFor some reason your github link repeatedly crashes for me. Not sure whether it’s because im trying to view it from my iphone..
- ako 3y agoSeems like you could do the same in Sql with CTEs or views, with the benefit of the query optimizer finding the fastest way to execute your pipeline on a large dataset.
- electroly 3y ago> modern .NET does all kinds of insane runtime optimization techniques to make sure things go fast Not as much of this applies to LINQ as we'd all wish. If you've got LINQ in a performance hotspot, the first thing to do is remove the LINQ. I love LINQ but plainly written loops are faster every time, and removing LINQ from profiled hotspots has always been a successful optimization for me in practice. Avoid it in performance hotspots. Once you've removed the LINQ, eliminate any inner-loop heap allocations and you're probably done optimizing. LINQ and heap allocation are the two major killers of performance in typical C# code.