Slashdot Mirror


C# for Java Developers

joefrench writes: "It might seem strange to review a C# book on Slashdot, especially one published by Microsoft, but I felt that there must be a lot of readers like me -- programmers who know Java, but want/need to learn something about C# and .NET. C# for Java Developers aims to teach experienced Java programmers how to write in C#." Joe outlines what he considers the book's good points (many) and weak points (few) in the rest of his review, below. C# for Java Developers author Allen Jones, Adam Freeman pages 548 publisher Microsoft Press rating 9 reviewer Joe French ISBN 0735617791 summary A comprehensive C# from Java tutorial

First things first First of all, let's deal with the Microsoft issue. I was surprised to find that this book even existed given the problems MS has had in the courts recently. I was even more surprised to find that C# for Java Developers is very balanced and does not hype up C# at the expense of Java -- throughout the book there are places where the authors say that "Java is better at this" or "We have no idea what the C# designers were thinking." A refreshing attitude from a company that is not known to be an admirer of Java.

I was reluctant to pay for a Microsoft book, but I have to admit that I am impressed. This is the first MS book I have ever purchased, and it is clearly written, well thought-out and very, very comprehensive. One of the best features for me is that all of the instructions for compiling and managing code assume that you are using the command-line tools, rather than Visual Studio. For someone on a tight budget, this was a real bonus.

The Scoop

The first part of the book is an overview of .NET, and contains the boiler-plate description that you get from the .NET web site. Not that useful, but pretty short. There is a chapter that compares .NET to Java (J2SE and J2EE), but again, there is nothing new or important there.

The second part of the book covers the C# language, using Java as a starting point. The coverage seems comprehensive, and explains where the two languages are the same (quite often), where they are different (now and then) and when they appear to be the same, but you are likely to spend a couple of hours tracking down something weird (more often than I would like). I had started playing around with C# before buying this book, and all of the problems that I had in the early days were detailed here with clear explanations.

Part three delves into the .NET class library, covering basic topics such as collections, IO and handling XML. Once again, I was impressed with the depth of coverage and the way in which the authors use Java classes to explain the workings of .NET. It was while I was reading through this section that I realized just how different C#/.NET and Java can be.

The last part of the book covers "advanced" topics. There seems to be little reason for the division between basic and advanced topics, but chapters cover areas such as threading, security and networking. The one thing that is consistent in this part of the book is that there is less of a parallel between Java and C#. For example, "Windows Forms" is used to build client UI applications, but is very different toolkit from Swing/AWT.

The appendix list is a little dull, covering topics like GC and configuration files. There are some interesting snippets, but I got the impression that these were topics that the authors thought were important, but didn't know where else they should go. The exception is the "Java to .NET API Reference" which, for me at least, sets this book apart from the competition. Every class from the J2SE class library is mapped to an equivalent .NET class and a reference to where the topic is covered in the book -- having something like this has saved me hours of searching.

What's to Consider?

This book uses a lot of C# fragments to demonstrate how classes are used, but contains very few full "working" examples. I found this to be great once I knew the basics of C# (because I could focus on the topic), but difficult at first (because I could not play with complete code).

C# for Java Developers covers much more of the .NET Framework than the other books in my local bookstore, but because of this the text can be dense at times, as the authors try and pack in a bit too much detail.

I can't find major fault with this book, and a (small) part of me admires Microsoft for publishing such an unbiased book.

Summary

If you are a Java programmer who wants or needs to learn about C# and .NET, then this is a great book. Don't be put off by the Microsoft logo, and bear in mind that you don't need a copy of Visual Studio to follow the examples.

The book effectively uses Java as a tool to teach C# and explain the workings of .NET. If you are like me, then you will find this book invaluable and will likely keep it close at hand for quick reference.

Table of Contents

  1. Introducing .NET
    1. Introduction to Microsoft .NET
    2. Comparing Java and .NET Technologies
  2. The C# Language
    1. Creating Assemblies
    2. Language and Syntax Features
    3. Data Types
    4. Advanced Language Features
  3. Programming .NET with C#
    1. Strings and Regular Expressions
    2. Numbers and Dates
    3. Collections
    4. Streams, Files, and I/O
    5. XML Processing
  4. Advanced Topics
    1. Reflection
    2. Threading and Synchronization
    3. Networking
    4. Remoting
    5. Database Connectivity
    6. Security and Cryptography
    7. Graphics and UI
    8. Introduction to XML Web Services
  5. Appendices
    1. Platform Integration
    2. Shared Assemblies
    3. Configuring Applications
    4. Garbage Collection
    5. Cross-Language Code Interoperability
    6. Java to .NET API Reference

You can purchase C# for Java Developers from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

26 of 382 comments (clear)

  1. C# may not stand for long... by FortKnox · · Score: 4, Insightful

    Now, C# is a pretty language. MS looked at Java and started on their list... "This is good in Java, lets include it. This isn't, lets either not include it or make a nicer alternative." They made quite a nice, competitive language.

    But I think C# will be used to convert the C, C++, and Java crowd into the .NET framework. Now, once you are in the framework, you'll see that VB.NET is easier to use, has the OO that Java/C++ people desire, and can make the deadlines easier to make.

    Yeah, I think C# is MS's way to convert everyone to VB.NET.

    Luckily, .NET isn't as platform independent as Java atm, so I'll stick with my cup-of-joe.

    --
    Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
    1. Re:C# may not stand for long... by km790816 · · Score: 5, Informative

      Slow down, turbo.

      No one at Microsoft likes VB.NET. It was meant as a crutch to get old VB developers into the new programming model.

      All of the .NET class libraries were written in C#. I don't think they are planning no changing that in the near future.

    2. Re:C# may not stand for long... by JamesOfTheDesert · · Score: 3, Interesting

      And since it only runs on Windows, hence x86, I need to produce bytecode why?

      So you can run it on FreeDSD or Linux using Rotor or Mono.

      --

      Java is the blue pill
      Choose the red pill
  2. Terrarium by killthiskid · · Score: 3, Interesting

    The thing that finally got me to play with C# was Terrarium. Players create 'creatures' which then compete in a peer-to-peer set of virtual terrariums. You can create plants, herbivores, or carnivores. It was quite fun (in a super geek way) and VERY challenging.

  3. Wow- C# review on Slashdot? by glh · · Score: 3, Insightful

    I'm really suprised by this (especially with the book being from MS) but I think it is a nice to see on Slashdot.

    C# really is a nice language. It is more powerful than other .NET languages (such as VB.NET) because it allows you to write unsafe code (ie, code that doesn't have to go through the garbage collector). Not that most MS programmers will need this capability, but its nice to have if you need the extra performance over maintainability/safety.

    C# also gives you the ability to write XML comments in your code that can be parsed by the compiler to generate documentation. There is also an open source project called "NDOC" (hosted on Source Forge) that lets you generate really cool and helpful docs.

    However, the majority of Slashdot readers probably don't care how C# is better than other .NET languages. The real question is- how does it compare with Java. Honestly, I believe there are some differences in syntax and power, but I don't know the details (as I am not that experienced with Java) but it would seem this book could help answer that question. I plan on taking a look at this book. Thanks for the review, and again- nice to see this kind of thing on Slashdot!

    1. Re:Wow- C# review on Slashdot? by glh · · Score: 3, Interesting


      No, C# doesn't allow you to write unsafe code, you have to use C++ for that. What's new about C++ in the .NET framework is that it allows you to mix safe ("managed") code with unsafe code. In managed mode, it's a rather castrated C++ (particularly the lack of templates), but with the niceties of GC.


      You can write UNSAFE CODE with C#. Yes, it is mixed in, but it is still unsafe code. See this article for reference.

      I never said it runs outside the CLR, just the GC.

  4. The Canonical C# for Java Developers Article by Carnage4Life · · Score: 5, Informative
  5. What was wrong with J# for Java users? by SadatChowdhury · · Score: 3, Informative

    If anyone wants to port Java application to .Net platform, wouldn't it make more sense to use J#? With .Net's language insensitive nature, C# vs J# should not matter, and so J# would naturally make more sense to someone wanting to attempt to port a Java application into the .Net platform.

  6. Good starting point online by km790816 · · Score: 3, Interesting

    A Comparative Overview of C#

    This is a great site. If anyone wants to learn C# coming from a C/C++ or Java background I send them here. Shows source in all three languages (where applicable). Good place to start.

    I must say I was a hard-core Java fan until I found C#. I must qualify that statement since I develop exclusively for Windows.

    If you write code that will only live in the Windows world, you owe it to yourself to check out C#/.NET.

    1. Re:Good starting point online by Kynde · · Score: 4, Insightful

      This is a great site.

      After a first glance I saw :

      This is typical code you might write in Java or C++:

      foo.setSize (getSize () + 1);
      label.getFont().setBold (true);

      The same code you would write like this in C#:

      foo.size++;
      label.font.bold = true;


      Now, if that isn't biased crap then I must be the guy bending over at goatse.cx. The rest of the article goes on in much the same way.

      I just knew it. For C/C++ coders C# is what Windows is to a proper OS users. It may be easier if you're a numwit, but I'm quite sure that the design is rigid and quite quickly you'll wind face to face with some illogicality or utter impracticality. And there you are... not happy as a clam, but happy as a lion with a hedgehog rammed up in it's butt.

      If you're now thinking "well, C++ is flawed, too" the you've missed the point or you only think you know C/C++. There's a big difference in knowing and mastering and my guess is that that in particular will be the problem with C#, as with all other Mickeyware.

      --
      1 Earth is warming, 2 It's us, 3 it's royally bad, 4 we need to take action NOW
    2. Re:Good starting point online by Kynde · · Score: 3, Interesting

      Your visceral hatred of Microsoft has you defending Java's disgustingly verbose syntactic conventions for properties where yep, they got that wonderful beans model, then proceeded to do absolutely NOTHING with the language syntax to support it.

      Couldn't agree more, but the same won't hold for C/C++ which they referred to.

      I bet you thought those were direct property accesses, right? I wouldn't expect such a staunch defender of The One True Faith to actually look up the mechanisms of property declarations...

      Doh, it being methodized was obvious enough. It just kinda bugged the hell out of me seing :
      foo.setSize (getSize () + 1);
      label.getFont().setBold (true);


      Labeled as "typical code" in C++.

      And the part which you were obviously referring to as it cannot be done in C++ (because one can't overload .):

      label.font.bold = true

      Well, I for one am quite doubtfull wether that is better than what C++ has now :
      label.font().bold = true

      The article goes on and argues that the .font. syntax won't be mistaken for a field by "However, almost all classes with any real complexity designed in Java (and certainly in C#) do not have public fields anyway.".

      Well, I sure don't see the "extra" parentheses harmfull, moreover I'm worried about the complexities of the scoping rules for similarily named fields.

      Having read the cursive (italic) parts of the article, I have to say that I don't agree with most of it. And just as my comments here are biased, so is the article. Rants like these don't make good articles. That's why I post my crap here, which would've been a fair idea for that author aswell.

      --
      1 Earth is warming, 2 It's us, 3 it's royally bad, 4 we need to take action NOW
    3. Re:Good starting point online by the+eric+conspiracy · · Score: 3, Informative

      After I read that I article I also came away with the impression it was highly biased. Nowhere does it describe some of the significant advantages that Java has over C# such as checked exceptions, inner classes, class granularity reflection, a far better collections implementation and so on.

  7. Wow.. review sounds pretty good! by Quixote · · Score: 3, Flamebait
    Too good, in fact. Am I the only one who was reminded of the recenty story about 'stealth advertising', with paid "actors" using cool gadgets as if they were normal users, to create a buzz? This review, with its liberal dosage of "I was skeptical of ... but was pleasantly surprised to find ... " reminds of just such marketing efforts.

    1. Re:Wow.. review sounds pretty good! by tshak · · Score: 3, Insightful

      Of course, when the next Java review comes out no one will by crying conspiracy.

      --

      There is no longer anything that can be done with computers that is nontrivial and clearly legal. -- Paul Phillips
    2. Re:Wow.. review sounds pretty good! by Yankovic · · Score: 3, Funny

      This coming from a guy with a Java contest sponsored by Sun as his sig...

  8. Why should it seem strange to mention C#? by Tattva · · Score: 5, Insightful
    It might seem strange to review a C# book on Slashdot

    There is absolutely nothing strange with not keeping your head buried in the sand. Just because some folks seem to have a knee-jerk reaction to all things Microsoft doesn't mean Slashdot should be expected to ignore relevant and widespread programming practices.

    --
    personal attacks hurt, especially when deserved
  9. Microsoft press has some good titles. by Zapman · · Score: 3, Informative

    They're not Oreilly, but they do have a good reputation for quality books. Code Complete and Rapid Development are amazingly good books by Steve C McConnell, put out by MS press.

    --
    Zapman
  10. Review of this review by gabbarsingh · · Score: 3, Insightful

    While I am a Java developer and I am interested in C# from a knowledge-about-languages perspective, this review is far from getting me there. At exactly one point the reviewer mentions threads and Swing. But then what about it? At more than four places Microsoft press is mentioned and it is advised to give them a fair chance. Well, after reading this review I still don't have a clue what the book is about. The ToC is interesting but not helpful. I bet that a 'Python for Perl Programmers' book would get an objective review with less focus on publishers and book contents/excerpts that would do the topic some justice. What I am trying to say is that there is no 'java angle'

    I propose slashdot community lay down some guidelines about reviewing a technical book. I applaud the reviewer's efforts and for keeping an open mind towards the source ;-)

  11. Re:Java developers should use J#, no? by Jugalator · · Score: 3, Interesting

    Yep, that's also the #1 reason to use it according to MS.

    However, syntax is often the easiest thing to relearn when switching language. Often much easier than to relearn an entire API. And since J# use the .NET Framework (and only the .NET Framework - it doesn't even run a VM) you could just as well go for C#. It's not *that* hard of a transition to relearn at all. For me, it was enough with some tutorial browsing on the internet to get into C# with a couple of years of Java experience since earlier.

    --
    Beware: In C++, your friends can see your privates!
  12. curious? download the SDK. by MORTAR_COMBAT! · · Score: 4, Informative

    No registration required: download the Microsoft .NET Framework SDK. Includes command line utilities, documentation, etc.

    The sound you here is a dozen moderators clicking 'Troll'.

    --
    MORTAR COMBAT!
  13. mono for windows by MORTAR_COMBAT! · · Score: 4, Informative

    Just downloaded the excellent 4 MB mono 4 windows as mentioned in an earlier thread, and as a C# hobbyist, let me tell you, it is a pretty nice way to get acquainted with the language without having to download the 150 MB or so of the full .NET SDK.

    And as is said elsewhere, every language has its place. C# is pretty nice for building Windows native applications. If you don't want to do that, then use a different language.

    More on-topic, I'll definitely be checking this book out of the company library.

    --
    MORTAR COMBAT!
  14. Re: C# by Black+Parrot · · Score: 4, Funny


    > This is a maligned language.

    Is it byte maligned, or word maligned?

    --
    Sheesh, evil *and* a jerk. -- Jade
  15. Re:Good Stuff! by pmz · · Score: 3, Interesting

    Hey! If that's true, can't sun sue them for use of a trademarked acronym?

    Not quite, since Java is widely implemented. Sun doesn't expend time and money trying to make these implementations incompatible; instead, Sun wants them to be compatible and has test suites available for that purpose. Conversely, Microsoft has a history of prefering their implementation over any others and works hard to drive other implementations into obscurity. Only time will tell if history will repeat itself with respect to efforts such as Mono.

    ...do you REALLY expect to get EVERYTHING for free?

    No, but I do consider the amount of risk associated with a technology. .NET provides a one-way ticket to the Microsoft Village; if you are comfortable with that, then, by all means, use C# and be happy. Those people looking for multiple-vendor technologies (i.e., lower risk technologies) should look elsewhere.

  16. Funny, I saw the opposite by GCP · · Score: 3, Insightful

    What I noticed was just how uncomfortable the author seemed, to be seen saying anything positive about something from MS to this crowd.

    Pretty sad when the political orthodoxy is so overwhelming that every sentence has to start with the equivalent of "please don't hate me for saying it, but this wasn't as bad as I naturally assumed..." when discussing a book on programming.

    C# is what you get if you take several years of Java real-world experience and ask "if we could do it over again from scratch, with no backward compatibility requirements with existing Java, what would we do?"

    C# is what you get if, instead of taking Sun's attitude of "please, you're a programmer, not a language designer -- if what you're asking for were a good idea, we would have done it", you take MS's "mercenary" attitude of "what changes would you make to Java if you could?".

    --
    "Those who have never entered upon scientific pursuits know not a tithe of the poetry by which they are surrounded."
  17. Re:Maligned? by Wavicle · · Score: 3, Interesting

    It really is just scared developers concerned that anything redmond can cough up is too mainstream and below them...

    I'm pretty sure most of us developers are just a frightful bunch. Ada is an infamously derided language ("oh the government made it, so it's basically a beauracracy of a language") - yet it has more built in support for requirements validation and maintainability. If you look carefully at Ada, it is a pain to work with, but the result can be readily and meticulously examined by people other than the original developers.

    If you were a sailor and an exocet was screaming towards your vessel 500 yards out and skimming the waves and the only thing between walking the deck and treading the waves is your Phalanx close-in weapon system, you're probably hoping the software which controls the Phalanx was developed with Ada. Now would not be the time to file a support request because your C++ caused a general protection fault.

    So whether it's C# or anything else... I think way too many are afraid of having to re-stock their toolset from scratch. There's comfort in working with what you've always worked with. Insert cliche dinosaur analogy here.

    --
    Education is a better safeguard of liberty than a standing army.
    Edward Everett (1794 - 1865)
  18. VB.NET by Bodrius · · Score: 3, Informative

    Well, I don't know about Microsoft, and I do know a lot of VB developers that hate VB.NET with all their guts, but I have to say I find it impressive for the same reasons they hate it: it's a language that forces OO design, uses modern libraries, and in the end it's all source code.

    I'm not a big fan of VBisms such as "MustOverride", "MustInherit", "NotInheritable" etc, which can easily become unreadably verbose for my taste as you combine them, but after trying it out for a couple of simple apps as an experiment I find it an outstanding improvement over the original VB.

    I think it's perfectly feasible to build a relatively big project in VB.NET without destroying some hardware and going on Prozac, as I would expect with any other VB.

    Not that I would, but it has become a matter of taste or distaste for the VB-like syntax, not a major disfunctionality of the language itself.

    VB.NET is a crutch. But it's a crutch that manages to fix VB as a language. I consider that an achievement, to say the least.

    --
    Freedom is the freedom to say 2+2=4, everything else follows...