Slashdot Mirror


C# From a Java Developer's Perspective

Microsoft's C# has raised eyebrows, interest and debate since its official announcement last year. The prolific Carnage4Life (Dare Obasanjo) has completed a detailed comparison of C# and Java, outlining the things that are identical, similar, nearly the same, or completely different between the two languages. If you're considering learning or applying either one, you might benefit by reading this paper first. There are some other excellent comparisons to be found linked from the Open Directory Project as well. Update: 11/20 03:35 GMT by T : Note: here's a mirror; interested readers who mirror the mirror get good seats in heaven.

8 of 507 comments (clear)

  1. Re:Some more information by SanLouBlues · · Score: 3, Interesting

    This comparison is decent, but makes a few uninformed comments.

    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;

    The C# code is immediately more readable by those who are using foo and label.

    True, but this easy method can be done in Java with public member variables, it's just discouraged.

    Declaration:

    public enum Direction {North, East, West, South};

    Usage:

    Direction wall = Direction.North;

    It's a nice construct, so perhaps the question is not why did C# decide to have them, but rather, why did Java choose to omit them? In Java, you would have to go:

    Declaration:

    public class Direction {
    public final static int NORTH = 1;
    public final static int EAST = 2;
    public final static int WEST = 3;
    public final static int SOUTH = 4;
    }

    Usage:

    int wall = Direction.NORTH;

    The java method will compile/run a tad faster, due to the lack of an entirely new type.


    There may be more . . .

  2. Re:C# is really kinda cool stuff by the_2nd_coming · · Score: 2, Interesting

    have you ever tried to run a half a million line Desktop Java app on windows

    yes actualy, I don't know the Lines of code but Jext is almost as robust as Emacs.

    Jext

    you have a vertual file hierarchy, an FTP client, a text editor with Hughlighting for almost every language and markup around, it has its own macro language, it has an embeded python interpreter, you can send e-mail, it divides your projects into seperate workspaces, and each workspace has its own Virtual file hierarchy. This is the text editor fo anyone who is in developing. what is realy nice is that it gets out of your way.

    --



    I am the Alpha and the Omega-3
  3. foreach...kudos by GCP · · Score: 3, Interesting

    In the alpha days of Java, I suggested to Sun that they incorporate some very popular Perl features, such as a foreach and containers that allowed for such things as "foreach char ch in myString" or "foreach int i in myIntVector" or "foreach int i in 30..1", etc.

    The senior designers repeatedly treated such suggestions with contempt. Arthur van Hoff told me, "If you want to use Perl, just use Perl!"

    The MS people I spoke to in the early stages of C# were very interested in input like this. Where Sun's attitude toward "why can't we have X?" was "because we said so", MS's was "hmm, that would be popular, I wonder if we could find a way...."

    Say what you will about MS, one of their standard techniques for locking you in is to try to make what people are asking for. Contrast this to Apple and Sun ("we're your superiors, so use what we tell you to use"), and Linux ("make it yourself, luser!").

    --
    "Those who have never entered upon scientific pursuits know not a tithe of the poetry by which they are surrounded."
  4. Re:Power of Java, Functionality of Windows by ClubStew · · Score: 3, Interesting

    Granted, C/C++ is my language of choice on any platform (unless you're designing cross-platform code, which Java works great for). You have to admit, however, that C/C++ requires greater thought and strong fingers for all the typing you have to do. C# is an abstract language like Java and requires less (and, yes, it does hide more, which can be bad in some cases).

    Just like any language, each has its strengths and weaknesses. If you're looking for abstraction and rapid development on Windows, C# is worth a look. If you're looking for speed (and, seriously, once the .NET framework is loaded, C# isn't too bad on speed), go with C/C++ for faster code and lower-level calls and memory management and stuff.

  5. My take by nebby · · Score: 5, Interesting

    I've been a Java programmer since JDK 1.0 came out, though I've really done most of my Java coding with server side servlet stuff since the GUI library has, and probably always will, suck the wanker.

    I just recently picked up C# about a month ago. The learning curve from Java was pretty damn low, only with a few different naming conventions and new language constructs. Things such as indexers, delegates, and the like (all of which I feel are positive additons to the language.) The event model, to my surprise, is better than Java.

    Then after learning the language itself I started looking into Windows Forms and nearly spooged my pants. Finally Windows progammers get a clean framework of GUI controls with a powerful modern language behind it (ie, not C++ or VB.)

    Usually if you wanted to make a powerful Windows app you were forced to use C++ since VB didn't really cut it. Now you can use C#. Complex Windows apps are going to be a whole lot easier to write now, nevermind the fact that they'll be able to do remote method calls via SOAP, and be deployed effortlessly (ie, create a Windows Installer in like 3 clicks or something.)

    I have to say, for the stuff I'm writing that I don't need cross-platform compatibility (which I did surprisingly find to work in the case of servlets) .. C# and the .NET framework wins hands down.

    --
    --
  6. Langs the same. Companies differ. by mactari · · Score: 4, Interesting

    I've done a little C# programming and I've done more Java programming. Heck, I've even done some J# (http://msdn.microsoft.com/downloads/default.asp?U RL=/downloads/sample.asp?url=/msdn-files/027/001/7 54/msdncompositedoc.xml) programming.

    The things that make these two different as a language are pretty trivial. As a Chem. Eng. professor told me when I asked if I needed to bother with FORTRAN when I already knew Pascal, "They're all different dialects of the same langauge".

    The only real difference is that you'll want to use the dialect best suited to your particular programming task. If you want to leverage code written in .NET quickly and easily and build off of a Web Service on another office's server or if you have hoardes of legacy COM code, you'll use C#. If you have a giant UNIX server farm running JSP you'll use... That's right! Java. If you're a madman who likes to make Frankensteins in your spare time, you'll use J#. :^)

    The biggest difference isn't syntaxical. It's the mindset of the companies behind the code. No matter how many times MS wants to claim C# isn't a Java clone, the point is it's a well-done language based on lessons learned by programmers who are familiar with Java. My only fear is that C#, an excellent language in theory by anyone's measure, is going to be wrung through Microsoft's "profit maximization machine" and be made to do things that, in practice, aren't the best.

    The neat part is that people familiar with C#'s concepts will also be able to quickly learn Java! I wouldn't be too surprised to see some VB programmers turned C# developers start to think, "Hey, you know it wouldn't be that hard to run this on [Linux/OS X/etc] by implementing this idea in Java!"

    --

    It's all 0s and 1s. Or it's not.
  7. C# is what Java developers really want... by javabandit · · Score: 5, Interesting

    C# being better designed than Java is no big surprise. Why? Because Sun has done very little to further the actual language itself.

    Java really hasn't changed much since its inception. All we have are a few more libraries, a GUI framework that blows ass, and a server-side framework that we didn't really need to begin with. But we have no real additional language FEATURES.

    Like a lot of people, I've been using Java since the beginning. I look at the C# language and I see everything I want in Java. The great majority of differences between C# and Java are purely syntactical sugar -- compiler candy. AND THAT IS WHAT WE WANT.

    We've been asking for support for generics and parametric types since JDK1.1. And they still aren't in (they were removed from 1.4 at the last minute). We've been asking for A REAL CONST. We've been asking for assertions -- and finally got them.

    But all in all... most SEASONED Java developers aren't happy with the progress. Java has been plainly behind the curve when it comes to evolving new and different features. Instead, Sun poured all of their effort into their bullshit J2EE framework which is a complete shambles, IMHO.

    Its obvious. Microsoft simply went to Usenet... read a bunch of Java posts... and saw that Java was stagnant. They took advantage of it. They created a new language... based upon Java... adding everything that Java developers were complaining about. Voila! C#!

    I wonder if this would have happened if Java were open source. Probably not.

    But one thing for sure... Microsoft is an EXPERT at catching a company while it is asleep at the wheel... ripping of its product... making it better... and seizing an entire market.

    They just might be doing it again...

  8. Re:Some more information by Anonymous Coward · · Score: 1, Interesting

    foo.size++ using get/set is pretty nifty tho', but since there's no performance advantage I don't see it as an advantage.

    Readability is easily as important as performance, and this improves readability. It's *great*, and it's high time a mainstream language got this feature.