C# 4.0 Pocket Reference - Joseph and Ben Albahari

My day job involves writing Java, but sometimes it pays off to check out the competition. So, I've been reading up on C#. The last time I read a book about C# was in 2009, and that book was written while .Net was in beta! So, it's definitely time for me to brush up.

Java started off as a very simple language, and C# as a none-too-subtle Java rip-off. Since then... things have changed. They're both relatively chunky languages now, and seeing the features C# has picked up has been very interesting.

C# feels much the more pragmatic language, at the expense of complexity. With structs (value-typed and storable on the stack), operator overloading, extension methods, "using" blocks, unsafe operators, etc., it's a bit more feature-packed. It's rather more like a cleaned-up and GC'd C++.

I guess this is kind of the point. Languages grow cruft over time. C++ has now become utterly mad. On the other hand, C# now sanely files a niche in the same way that C++ more-or-less did in the late '90s (albeit a different one). It has grown practical complexity over time.

Even things like LINQ, which I'd heard things about to make me go "Hmmm" looks reasonably sane. I'm not too sure about the extra syntactic sugar, but the basic mapping/filtering/etc. framework is rather neat - like a watered down version of the super-general higher-order operators of Haskell, only without the need for a post-graduate degree to understand the underlying category theory.

Of course, all the above is based solely on reading about the language. My practical use of it is approximately, er, zero. Theoretical knowledge is fun!

So, this book. The 5.0 reference is out, but wasn't in my local bookshop. This is very much the pocket reference - it tries to cover the language as briefly as possible, skimming over much. It does not cover the language's libraries, which is perhaps problematic if you wish to use the language practically. While it is pocket-sized, it's still 200 pages long. That's 200 pages just for the language, no libraries. This is not a small language any more.

The book is well-written, although the LINQ section is somewhat tedious. It tells you the fundamentals of everything, compactly. It's clearly written to go with the C# in a Nutshell book (same authors), which provides more detail. If you know other languages, and just want to get up to speed on the core syntax, this is great. As it lacks library documentation, or in-depth discussion, it's not really suitable as a sole reference. If you've got Google, though, you're probably good to go. Whether it was good to start with, or revised over the editions, it's very readable. Recommended.

Posted 2014-02-03.