7 ms·
This. I am as anti-Microsoft as the next guy, but C# is one of the few "insanely great" things they have. edit: I'm not just blowing hot air, I've actually wro
by ansimionescu 13y ago
This. I am as anti-Microsoft as the next guy, but C# is one of the few "insanely great" things they have.
edit: I'm not just blowing hot air, I've actually wrote C# code that went into production.
- bananas 13y agoI'm someone who has put lots of C# into production and whilst you're right, caution has to be used when using LINQ. There are several humungous hand grenades that will go off in production unless you really 100% understand how it works (memory ballooning, infinite sequences, total misunderstanding of log complexity, leaky abstractions and difficulty of debugging).
- hvidgaard 13y agoLINQ is a tool, and a great one. But just as you need to understand malloc when writing C, you need to understand the basics of LINQ to use it in production. The main problems I've come across are all failure to understand delayed evaluation. Maybe I'm not using it in a complex way, but as soon as it start to feel too complex, LINQ is not the way to go. I agree that it can be difficult to debug - that's why it should be kept simple. Personally, I love that LINQ enables me to think of my data in terms of sets and operations on them, rather how to execute the operations on the data.
- V-2 13y agoIt should be used with caution and not abused, you're right of course. But when I use LINQ's GroupBy, SelectMany etc. I know they've been tested millions of times before. The same cannot be said about somebody's "hand-made" algorithm, accomplishing the same result with foreach loops, breaks etc. like you would in good ol' Java. So it's not just a matter of being imperative, long-winded or ugly. You can also break LINQ expressions down into a series of simplier ones: deferred evaluation is a bliss here! Or - thanks to the way it works, extension methods, anonymous methods etc. - simplify it by creating your own LINQ-like functionality, such as - say - Batch (not part of the standard Linq library)
- sanderjd 13y agoWhat are the best resources for really grokking LINQ in depth? I'm not too impressed with the level of depth in the main LINQ section on MSDN - it seems (sensibly) more focused on how to use it than on how it works.
- 3minus1 13y agopluralsight's video tutorials on LINQ are excellent. the free trial should give you enough time to watch them
- Glide 13y agoThe biggest thing for me with grokking LINQ was understanding the difference between IQueryable and IEnumerable types of operations. Most of the complexity in the runtime with it is with IQueryable. I don't know if there are a lot more resources out there but the best one for me was understanding Expressions and that namespace in .Net and trying to grok the ASTs that were being passed around to understand how it was all working. There are a couple smaller LINQ implementations out there like Linq to Amazon that you can take a look at (Linq2<insert whatever here> libraries seemed to be coming out of nowhere for a while).
- computerslol 13y agoThere are also IObservable and IQservable if you want to go deeper. http://channel9.msdn.com/shows/Going+Deep/Bart-De-Smet-Observations-on-IQbservable-The-Dual-of-IQueryable/ http://channel9.msdn.com/shows/Going+Deep/Bart-De-Smet-Obser...
- ansimionescu 13y agoThis seems to be popular (a lot of people had it at the MS shop I interned last year) [0] and, to be daft, here's two more recommendations via SO/reddit: [1] [2]. 0: http://www.amazon.com/dp/1590597893/ http://www.amazon.com/dp/1590597893/ 1: http://www.manning.com/marguerie/ http://www.manning.com/marguerie/ 2: http://manning.com/skeet/ http://manning.com/skeet/
- Xdes 13y agoOne of the best ways of understanding something is to implement it yourself. To that end Jon Skeet has already documented how to do it in his Edulinq series[0][1]. [0] Link to series: http://msmvps.com/blogs/jon_skeet/archive/tags/Edulinq/default.aspx http://msmvps.com/blogs/jon_skeet/archive/tags/Edulinq/defau... [1] Download of series (found in link): https://code.google.com/p/edulinq/downloads/list https://code.google.com/p/edulinq/downloads/list