7 ms·
Based on the code snippet, I'm not surprised he thinks C# is "verbose" with "lots of boilerplate" and "resembles Java", because the snippet is written as if it
by V-2 13y ago
Based on the code snippet, I'm not surprised he thinks C# is "verbose" with "lots of boilerplate" and "resembles Java", because the snippet is written as if it WAS Java, or at least written 10 years ago. Compare his GetFrequencies implementation with idiomatic, LINQ version: http://pastie.org/8834650 http://pastie.org/8834650
- ansimionescu 13y agoThis. 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
- koyote 13y agoI completely agree. After having used C# extensively recently, and having used quite a lot of Java before that, I have a feeling that C# is what Java should have been/should be. LINQ alone makes C# infinitely less verbose and 'boilerplate' than Java.
- dllthomas 13y agoYeah, having done a little C#, my impression was "They aimed for 'a better Java' and mostly succeeded."
- tracker1 13y agoMostly? There are very few things Java does better as a language, and most of those are opinion, not outright better. My biggest interest in .Net/CLI/Mono from very early on was how much easier it was to interface with systems libraries vs. Java's JNI.
- dllthomas 13y agoGiven the large surface areas of each, I'd be astounded if there were zero points on which Java is genuinely superior. I don't recall either well enough to give any specifics.
- sixbrx 13y agoViable production-ready implementations existing on all major server platforms (without having to jettison favorite libraries here and there), is a pretty big one, but I guess that might go without saying (or maybe outside the scope of "language" proper - but that's the elephant in the room).
- V-2 13y agoBetter enums in Java.
- jtfrench 13y agoSo true. C# = What Java wanted to be, sans "write once, deploy anywhere" hype
- mcv 13y agoI know nothing about C#, but I keep hearing announements of Groovy-like features in C#, and to me, Groovy is what Java should be (but with better performance). If C# is really like Groovy with better performance, then it should be a very nice language indeed.
- teh_klev 13y agoI've tinkered with Groovy (writing custom event handlers etc for Jira). If I was going to spend any serious time writing stuff to run on the JVM then Groovy would probably be my choice. C# has been my primary development language since 2002. Fell out of love with it for a while until LINQ and then dynamics appeared. Oddly, this week I am writing nagios plugin code in Perl, which I am getting a weird kick out of, I haven't used Perl in anger since 1999.
- kbenson 13y agoA few tips for the infrequent Perler: If you have a more recent Perl available, use it and it's newer features (use 5.014; at least, hopefully). It's a small thing, but being able to call keys/values/shift/unshift/push/pop on the reference versions of their subject is very nice. There's useful new features in every new version now. Additionally, Function::Parameters (or some other module that does similar, take your pick) will make your life much, much simpler if you tend to write a lot of subs. Use Moose (or at least Moo or Mouse, if you want it lighter weight) if you are using objects. Enjoy!
- vorg 13y ago> I keep hearing announements of Groovy-like features in C# I'm pretty sure the builders of C# didn't think about Groovy at all when putting in features such as closures and dynamics. Correlation doesn't imply causation.
- pjmlp 13y agoWhat features? Many of those trace back to Smalltalk and Lisp with some Eiffel as well.
- 13y ago
- skrebbel 13y agoSame for his PHP examples. He seems to have picked notably horrible examples for the languages he doesn't really like.
- sanderjd 13y agoWhile it's a pretty impressive survey in its breadth, he doesn't seem to have much depth in a lot of the languages. There were mildly cringeworthy things in all the sections for languages I know well. For instance, the Ruby section seemed strangely obsessed with Rails, saying that programmers find joy in Ruby, citing the metasploit folks as an example, and then confusingly attributing that joy in part to Rails, which of course metasploit doesn't use.
- kodablah 13y agoAnd the PHP example is incredibly unidiomatic to today's devs (short-arrays, typehints, etc)
- cpfohl 13y ago+1 This. C# counter-example: NancyFx. A library that enables you to write a complete Web Server in a custom DSL that (if written correctly, of course) reads as close to English as you can imagine. Plus Type Safety. Plus awesome SQL Server Support. P.S. The other reason you use C#: you want to interact w/ SQL Server. TDS works, but boy is it a pain compared to just adding a reference in Visual studio. Also the bindings for TDS are pretty weak in some languages.
- romanovcode 13y agoBUT IT ISN'T SEXY ENOUGH!
- V-2 13y agoYeah that's a good one as well. Like F# classified as one of "unreasonable langauges" on the basis that "we have enough company-sponsored languages already"
- computerslol 13y agoIf you wanted to make a version with a live UI that's monitoring a stream instead of a file, I suggest Reactive Extensions. It adds support for IObservable, the stream version of IEnumerable (what LINQ is used against). Once you get your head around it, there is magic to be made. I think a bunch of Reactive Extensions is now bundled with .Net. It is produced by Microsoft. http://rxwiki.wikidot.com/101samples http://rxwiki.wikidot.com/101samples - A cursory look; it goes far deeper than this.