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.

24 of 507 comments (clear)

  1. Some more information by nll8802 · · Score: 3, Informative

    There is a good, clean quick overview of C# here. The also do some comparison of C# to Java.

    1. Re:Some more information by Steveftoth · · Score: 2, Informative

      Sorry, but javac WILL do that.

      All static final primitives are substituted at compile time. They are treated as compile time constants. See the JLS 13.4.8 for reference.

      (I just love being a language nazi)

    2. Re:Some more information by vsync64 · · Score: 2, Informative

      Back when I worked at Sun, I had a nasty experience involving final. I performed the same experiment you did, with the same results, and wrote a paper about it. Yes, it does suck.

      --
      TO BUY A NEW CAR WOULD MAKE YOU SEXUALLY ATTRACTIVE.
    3. Re:Some more information by vsync64 · · Score: 2, Informative

      I don't suppose it matters that Common Lisp has had accessors and SYMBOL-MACROLET since, well, forever, does it? *sigh*

      --
      TO BUY A NEW CAR WOULD MAKE YOU SEXUALLY ATTRACTIVE.
  2. Correction by aspillai · · Score: 2, Informative

    Unlike what the article says, Java does have a byte keyword.

  3. Go Here: by B00mZilla · · Score: 1, Informative

    I couldn't get to the /. link either, but this site works fine: http://www.kuro5hin.org/story/2001/11/18/152437/24

  4. Java != Sun by RichiP · · Score: 5, Informative

    Although Sun engineers are handling the boards, the direction of Java is mostly influenced by the general public through the Java Community Process (See http://www.jcp.org/). Sun simply acts as an arbiter and caretaker.

    If there are any good ideas in C#, there's really no reason it couldn't be adopted by Java. Someone just has to submit a request

  5. False by Anonymous Coward · · Score: 1, Informative

    How nice of you to engage in FUD. You've heard the term? Fear-Uncertainty-Doubt

    So allow me to eliminate some of your FUD, right here, right now.

    It's true that as of right now the .Net platform only runs on a subset of Windows products(i.e. they do not intend to support Windows 95), and there is debatable evidence that it will support other platforms.

    This notion that it requires Windows Messenger and .Net passport is absolutely false. No such requirement exists, and none shall ever exist. To make such a claim is to prove you have no understanding of what .Net is.

  6. Re:urm yeah, 'up and coming dev guys' take some ad by easter1916 · · Score: 2, Informative
    If you want to make money, learn C/C++ in *nix or windows, or c#.
    How does $100K/year sound to you? I'll stick with Java, thanks.
  7. Re:The lesser of two evils by Anonymous Coward · · Score: 1, Informative

    I'm glad you're not letting the facts stand int the way of your anti-MS crusade.

    MS will be releasing an implementation of the C# virtual machine for FreeBSD, under either their shared source or possibly BSD license (probably with the advertising clause). A Macintosh vm will be available as well.

    There already is a gcc side project to compile code to the .net VM as well as a side project to compile C# code natively. I'd give you the URL, but sourceforge is currently down, so I can't look for it.

    Since MS Office has been interpreted code for quite some time now, it's likely it will be migrated to use their new VM. Which means MS Word might run natively on XWindows... (ok, maybe not without wine :)

  8. Re:The lesser of two evils by tazzzzz · · Score: 2, Informative

    For people who haven't yet checked it out, IBM's Eclipse project... IBM has developed a GUI toolkit for Java that uses native widgets.

  9. Interesting, but there's an error... by ncc74656 · · Score: 3, Informative
    From the linked article:
    In languages like C and C++, each subarray of a multidimensional array must have the same dimensions.
    I'm fairly sure you could do something like this in C or C++:
    int** foo=(int**)malloc(sizeof(int*)*2);
    int* foo[0]=(int*)malloc(sizeof(int)*3);
    int* foo[1]=(int*)malloc(sizeof(int)*9);
    That will set up a jagged array with the same dimensions as in the given C#/Java example. It will be addressable in the same manner. It won't have the bounds checking, but I suspect that the comment regarding Real Programmers and strong typing could be extended to bounds checking. :-)
    --
    20 January 2017: the End of an Error.
    1. Re:Interesting, but there's an error... by Fjord · · Score: 3, Informative

      This isn't right. C can do truely multidimensional arrays. If you say char[30][20] x it does one allocation of 600 contiguous bytes. When you use the array like x[10][10] it computes the full offset as in Pascal and BASIC, and then does a single pointer add. Here is an ok page that talks about C multidimensioned arrays.

      But Java and C# don't actually let you have jagged multidimentional arrays like this. They have like you said in your first post, an array of pointers, which is valid in C. One wonders what the writer of the article thinks argv is (typed char*argv[])

      --
      -no broken link
    2. Re:Interesting, but there's an error... by man_ls · · Score: 3, Informative

      Multidimensional arrays in Pascal are childishly easy, even in insanely large numbers of dimensions.

      type xarray=packed array[0..20,0..20] of integer;
      var data:xarray;

      That's a multidimensional array for you, with a data type so you can pass it to a function.

      If you'd wanted, but didn't feel like passing it to functions (i.e. no data type so it couldn't pass correctly) you could write

      var data:packed array[0..20,0..20] of integer;

      and accomplish the same thing. Either is accessible with a somple

      data[x,y] structure, that can be controlled by FOR/WHILE loops, IF statements, and the like. Last year, I was working in truely 3-dimensional arrays in PASCAL to store data for an airline seating chart.

      type xarray=packed array[0..20,0..20,0..20] of integer;
      var data:xarray;

      data[x,y,z]

      And even 4+ dimensional arrays "worked" but I'll be damned if I could visualize them in any coherant way.

      type xarray=packed array[0..20,0..20,0..20,0..20] of integer;

      It may have been a fluke that it worked at all, but I did a relatively simple program to fill up each space with random data and writeLn() it out, just to see if it worked. For that big of a data structure, you could probably do much better using records, or seperate linked arrays if Pascal can do such a thing.

      I've never done any programming work in BASIC so I can't speak for it's handlig of multidimensional arrays. I don't recall them being too hard from a program I looked at though, something to the effect of

      DIM variable%type% AS array (x,y) or something.

  10. Re:C# is really kinda cool stuff by Osty · · Score: 2, Informative

    BTW, who knows if C# is native ,bytecode, or both? I'm still confused on that point.

    Both, depending. This holds true for all languages targetting the .NET CLR. The different cases are:

    1. Application is distributed as native machine code. This is how binary-only applications are currently distributed. Upsides: Fast out of the box, installation only consists of copying files and registering components (in general). Downsides: not portable a la "Write once, run anywhere".
    2. Application is distributed as bytecode, installer compiles to native machine code. This is likely what will end up being the most popular. It's more akin to NeXT's "Write once, compile anywhere" idea, but with the compilation portion automated via an installer. Upsides: native speeds post-installation, portability. Downsides: Longer install times, potentially larger distribution files.
    3. Application is distributed as bytecode, run through a runtime using JIT compilation. This is essentially java. Upsides: portability, JIT compilation can do some optimizations at runtime that aren't possible at compile time (see Sun's HotSpot JIT). Downsides: Average case runtime is slow. Startup times and running times of important but less-frequently used code paths are slower.

    Item number 2 is likely the way things will go, because ISVs will be able to sell a single box of software and it will work on any platform with a compliant .NET CLR (assuming the code itself doesn't use any platform-specific extensions, but this caveat holds true for java as well). Plus, you'll get native performance, because the installer will actually compile the bytecode to machine code for you.

    For all supported languages, intermediate bytecode will always be generated (called IL, appropriately enough, for Intermediate Language). Whether you then compile that down to native immediately, do it at installation, or do it at runtime is up to the developer.

  11. w00t? no dynamic class loading? by mnf999 · · Score: 4, Informative

    I did not know that (and couldn't read the full description as the site is totally /.ed :(

    I design JBoss, the leading J2EE server and at THE HEART of it is the capicity to dynamically deploy new applications on our application server. I mean that is what application servers are ALL ABOUT.

    in fact (plug) in JBoss we go the extra mile and allow you to hot-deploy (dynamically add classes) the server classes themselves, which neither IBM nor BEA, nor Oracle do.

    So I was curious to know who would win the .net webservices race but it is extremelly clear in my mind, J2EE frameworks will deliver with webservices easier than any C# framework will

    Why? well imagine that ANY time you change your class in C# YOU NEED TO REBOOT THE APPLICATION SERVER, yes, boys and girls that is the simple thing that "dynamic class loading" affords you, without it, the VM is tied to whatever you have at startup.

    GEEEEZZZ!

    --
    The real mnf999 always posts as anonymous coward
  12. Having used .NET by f00zbll · · Score: 3, Informative
    I haven't used C#, but I am using .NET on a project. From my experience so far, the .NET platform has a long way to go. It's good that C# will make things easier for developers, but like all languages with wide adoption, bloat will inevitably occur.

    The first release of .NET will still be 2-3 releases from full fault tolerance and enterprise level computing. There are alot of complicated processes in enterprise computing and Microsoft's .NET platform as it stands today is far from meeting those needs. Microsoft has yet to define really useful modules and standards for complex processes that span multiple systems which include legacy VMS systems and modern solaris 8 applications.

    SOAP is great for simple processes, but it is far from adaquate to handle distributed and transactional processes. Using standards like UDDI is a great step towards easing multi-platform integration. Instead of having different divisions of the same company design different API for publishing resources, it will be easier to have a common way of doing those things. It is not uncommon for financial institutions to store information differently. Take a simple think like address. Some places may store the number in a separate field, while others may replace "jr" with "junior". Anyone who has worked with large mixed environments knows this fact. SOAP is a message centric way of doing things. It is not designed for complex processes. The stuff IBM is building around SOAP is more complete than Microsoft's offering, but then again IBM has been at services longer.

  13. Re:Come on now: Have you ever really used C#? by mmayo · · Score: 2, Informative

    ripped straight from Delphi's object pascal I would guess

    Given that Microsoft hired away Borland's chief Delphi (and object pascal) architect, Anders Hejlsberg, and that Anders' name is on the C# language specification, this should come as no surprise. :)

    Naturally, Borland has been attempting to sue Microsoft for its systematic destruction of their company by recruiting all of their top people (mostly on the technical front).

  14. Re:So how exactly... by ergo98 · · Score: 3, Informative

    Well given that Beta 2 has been available for closing on a year now, and I've had RC1 on my machine for about a month now... That's how I use C#.

  15. Slashdotted! by hugg · · Score: 3, Informative

    For those who feel like they're downloading the page over a 110-baud modem with an acoustic coupler located in the same room as a Disaster Area concert, here are some other similar comparisons.

  16. Alternate Site For Article... by Carnage4Life · · Score: 4, Informative

    Get it here

    PS: Mirrors encouraged, so if you manage to grab it and can host it at a site with beefier bandwidth, go ahead.

  17. another mirror by Lord+Omlette · · Score: 3, Informative

    here.

    It'll be off the front page tomorrow, so all these mirrors shouldn't be needed...

    --
    [o]_O
  18. ANSI/ISO My Ass by Anonymous Coward · · Score: 1, Informative

    The only "standards" body C# has seen is ECMA which seems to be a rubberstamper for whatever MS wants to push.

  19. Jagged arrays by Tribbles · · Score: 2, Informative

    You know, I'm not entirely sure that his assertion that subdimensions of a multidimension array must have the same dimension (topic 5).
    After all, in C, I'd use:

    int* array[2];
    array[0] = (int*)calloc(sizeof(int), 3);
    array[1] = (int*)calloc(sizeof(int), 9);


    True, this doesn't use heap-based stack, but to me, the functionality is the same...