Jon Skeet on "C# in Depth"
Join the DZone community and get the full member experience.
Join For FreeJon Skeet has worked with C# since 2002, and has been a Microsoft C# MVP since October 2003. Jon Skeet is also the author of the latest book by Manning called "C# in Depth". In this interview, Jon tells us about different versions of C#, what he thinks about C# and Java and much more. Read on.
[img_assist|nid=2589|title=|desc=|link=none|align=left|width=81|height=100]Meera: Jon, tell us something about yourself. Who you are, where you are located, and what kind of work do you do?
Jon: I'm a developer living in Reading, just to the west of London in the UK. Most of my professional career has been spent going from Java to C# and back again in a few different companies. I'm proud to say I've recently joined Google, and I'm looking forward to seeing what I can help to achieve there.
Meera: How did you get involved in writing this book?
Jon: After Manning published Groovy in Action, Jackie Carter and I discussed various options for a "next" book. We initially looked at ideas in the Java space, but then she brought up the possibility of a book about
C# 3, and I jumped at the chance. I've been following C# 3 since before Visual Studio 2005 was released - I firmly believe it has the potential to make a huge change in how developers not only write but *think* about code. I wasn't about to pass up the opportunity to delve into it more deeply.
Of course, "a book about C# 3" could mean almost anything - the next step was to work out what kind of book I really wanted to write.
Meera: Who is the target audience?
Jon: The book is aimed squarely at existing C# developers. In my experience, many developers are fairly comfortable with C# 1 (barring a few areas which cause some confusion) but aren't nearly as familiar with C# 2. Lots of people know enough about generics to use the collections in the framework, but they don't tend to write their own generic code. They're happy to use iterators in foreach loops, but might not be aware of just how easy they are to create with the "yield" statements of C# 2.
Add C# 3 in the mix, and you end up with a lot of people who have really powerful tools at their disposal, but aren't ready to fully exploit them.
So, what's available for these developers? There are plenty of books covering the new features, but most of them also try to teach C# from scratch. That means the reader ends up paying for material they already know, and they have to spend time sifting through it to get to the new stuff. I'm hoping that by skipping C# 1, I'll make the book more interesting and accessible for existing developers. It's also given me much more scope to write about the details of the language without ending up creating a book heavy enough to sink a yacht.
Meera: What version of C# are you covering in this book?
Jon: I cover C# 2 and C# 3 fully, but barely cover C# 1 at all. I go over a few of the core concepts of C# 1 in the second chapter - just topics which developers often find tricky, and which are very important for C# 2 and 3.
Meera: Do you expect the readers to know LINQ basics in this book?
Jon: Not at all. I work up to LINQ from the building blocks provided by C# 3 and .NET 3.5, showing each block individually before putting them together. Having said that, this is *not* a book which is about LINQ itself. I try to build a firm foundation, explaining how features such as query expressions, lambda expressions, expression trees and extension methods work. I go into LINQ to Objects in a fair amount of detail, but then I pull back the camera when it comes to the other LINQ providers.
In a single chapter I show the *basics* of LINQ to SQL, LINQ to XML, LINQ to DataSet and look at some of the upcoming LINQ providers too. Obviously that means I don't cover any of them in much detail - but that was never the aim. I've tried to explain *how* LINQ providers such as LINQ to SQL work, using the IQueryable interface - and *why* LINQ is such an important technology. I believe with that foundation and a firm understanding of how C# 3 as a language supports LINQ as a technology, the reader will be in a much better position to fully appreciate LINQ.
LINQ in Action (also published by Manning) is a great book to take the reader on a deeper journey into the various LINQ providers. The two books complement each other nicely.
Meera: I have used both .NET and Java extensively, and I like both technologies a lot, but still biased towards Java. How about you? Have you used Java at all?
Jon: I've used Java reasonably extensively, although not for the last year or so. I haven't seen much of the detail around what's going to be in Java 7, but that'll certainly be interesting.
Meera: If yes, please tell us how would you compare these two languages?
Jon: Well, I think there are various aspects to be considered. In terms of the plain languages themselves, I'd say C# is quite a long way ahead. I regard C# as "Java++" in many ways - it avoided a lot of the mistakes of Java (but not all of them) and each release has been significantly stronger than the last.
C# has better support for some pretty common patterns - little things like the "using" statement which means manual try/finally blocks are pretty rare in C#, but omnipresent in Java. Likewise although Java has some language support for iterators (with the "enhanced for loop"), C# not only makes it feasible to write iterators which will clean up after themselves (again, by having the Dispose method called at an appropriate time automatically) but it also makes it easy to create an iterator in the first place with "yield" statements.
The type system of C# and .NET is also significantly richer than that of Java - user-defined value types, a set of built in primitives which includes unsigned integral types, the nullable types introduced in C# 2 and .NET 2.0, and *much* richer support for generics, for instance. Generics in Java have various interesting properties when it comes to covariance/contravariance, but the design decision to use type erasure (so the JVM doesn't really know about generics) has really hurt the language in my view.
Delegates provide another very important difference between the two platforms. I believe that Java 7 will get function types (similar to delegates, at least) and closures (available in C# in the form of anonymous methods and lambda expressions). I gather that the closure design is somewhat different to C#'s support, and I'm looking forward to reading more about it.
On the plus side, Java has much nicer support for enums than C#. In C# they're basically named numeric constants, whereas Java has a far more object-oriented approach.
On a different level, it's worth looking at the platforms themselves, taking languages out of the equation. On Windows, .NET provides a more tightly integrated experience, with simple out-of-the-box for features like the Windows registry. Interoperability with native code is simpler with .NET than with Java, too. However, the big problem is that it's not multi-platform. I have a huge amount of respect for what the Mono team has accomplished, but companies which run their server-side applications on Unix boxes tend not to buy into that vision. They're more comfortable sticking with Java.
Java's multi-platform support is one of its biggest strengths - as is its multi-vendor support. It's pretty clear that if Sun were to disappear off the face of the planet somehow, there'd be plenty of companies willing and able to keep Java alive. There might be some ugly political battles, but it would be okay. I don't think the same can really be said for .NET. There are plenty of companies who have helped to shape it to some extent, and plenty which have bought into it as a solid platform - but I can't see anyone ready to take up the reins if Microsoft decides to drop it as a platform. I can't see that happening, of course, but there's something reassuring about seeing IBM leaning over Sun's shoulder.
The downside of this is that perhaps Java's evolution hasn't been as focused as it might have been. Everyone has had different angles they've wanted to work on, rather than there being one coordinated effort like we've seen with .NET 3.5 and LINQ.
That's a very long answer to a short question, but for me it boils down to C# being a superior language to Java at the moment, cramped somewhat by its Windows-centric platform. Java will have to work hard, both as a language and a platform, to offer a more compelling story than .NET to companies that are happy to use Windows. I really hope it does though - I strongly believe that the competition between C# and .NET has helped both sides to up their game, and it's the developers and users who are the big winners.
Meera: You said you joined Google recently, what language and technology have you been using there?
Jon: I'll be using Java for the most part, but I expect I'll be learning Python too. It's about time I did anyway, to be honest. I can't go into detail about the technologies I'll be using, but I'm in the Mobile team, so that should give you *some* hints as to the type of product I'm likely to be working on.
Meera: I read that C# 4 is coming out soon, what are the major changes in this version?
Jon: I wouldn't hold your breath for it coming out just yet, and I don't know of any absolutely concrete features to expect. Microsoft has indicated that they're looking at letting C# act as a dynamically typed language in certain well-defined areas (entirely under developer control) but we haven't seen much more than that yet. I'd be surprised if the immutability story didn't improve for C# 4 - with an emphasis on a functional style of programming, immutability is very important but not well supported in C# at the moment.
I don't expect C# 4 to be nearly such a big step from C# 3 as that was from C# 2. For the sake of developers, it had better not be! There's already a bewildering set of new frameworks to learn, and we really need to have some time for programmers to become really comfortable with C# before any more radical changes take place. Fortunately, I believe Microsoft has heard that message loud and clear.
Even though I'll be working in the Java space, I fully intend to stay up-to-date with what's going on in the .NET and C# world.
Meera: Any tips for our readers moving from Java to C# or vice versa?
Jon: My simplest tip is to make sure you understand the differences between the two languages. Don't be afraid to get a beginner's book, even if you feel you *could* get by with some assumptions when reading a more advanced book. Of course, that shouldn't stop you from reading more advanced books later (particularly not if you're moving to C# 2 or 3!) but it's worth making sure you're comfortable with the foundations first.
In purely practical terms, there's a really easy way to help you think in the right language: follow its naming conventions. If you start writing C# with Java naming conventions, you'll end up trying to write code which uses Java idioms. The two languages are certainly similar, but there are enough stylistic differences that it's worth trying to get your head fully into the language you'll be using before actually writing the code.
Opinions expressed by DZone contributors are their own.
Trending
-
AI Technology Is Drastically Disrupting the Background Screening Industry
-
Simplifying SAP Data Integration With Google Cloud
-
File Upload Security and Malware Protection
-
Tomorrow’s Cloud Today: Unpacking the Future of Cloud Computing
Comments