Slashdot Mirror


Java API and Microsoft's .NET API: a Comparison

Nerval's Lobster writes "Previously, developer Jeff Cogswell focused on the respective performances of C# and Java. Now he's looking at yet another aspect of the languages: the runtime libraries—what exactly the libraries are, how they are called, and what features the languages provide for calling into them. Examining the official Java API (now owned by Oracle) and the official .NET API owned by Microsoft, he finds both pretty complete and pretty much a 'tie' with regard to ease-of-use and functionality, especially since Java version 7 release 6 allows for automatic resource management. Read on and see if you agree."

23 of 319 comments (clear)

  1. I don't want to be "that guy", however by paysonwelch · · Score: 4, Interesting

    However, I mostly code in C# .NET and I dabble in Java in my spare time to model financial markets. What I have found is that C# has some powerful features that other languages do not have. This allows the .NET framework to be a little more robust than Java. Also my opinion is that C# and .NET creates a more syntactically elegant and coder friendly experience whereas Java is good, but not as good as .NET. In closing, C# .NET > Java. Please address .NET hate-responses to /dev/null

    1. Re:I don't want to be "that guy", however by Xest · · Score: 3, Interesting

      Microsoft has had the benefit of being the single controller of the .NET framework whilst Java has been victim of design by committee a lot of the time. This is why the .NET framework has managed to stay tidier and more focussed, but as I said in my other post what does it matter, because who the fuck sticks to just the core framework anyway when there are things like Spring out there?

    2. Re:I don't want to be "that guy", however by OhSoLaMeow · · Score: 5, Funny

      In closing, C# .NET > Java. Please address .NET hate-responses to /dev/null

      Your windows environment has /dev/null?

      How cool is that?

      --
      They can take my LifeAlert pendant when they pry it from my cold dead fingers.
    3. Re:I don't want to be "that guy", however by Mitchell314 · · Score: 5, Funny

      Yes. It's c:\.

      --
      I read TFA and all I got was this lousy cookie
    4. Re:I don't want to be "that guy", however by AmiMoJo · · Score: 4, Insightful

      This is the wrong question. What matters is the quality of the apps that are written in either language. In that respect C# is way ahead on the desktop, but in other areas Java is king.

      --
      const int one = 65536; (Silvermoon, Texture.cs)
      SJW, n: "Someone I don't like, and by the way I'm a fuckwit" - AC
    5. Re:I don't want to be "that guy", however by iluvcapra · · Score: 5, Insightful

      Microsoft also had the benefit of Java going first and making all the mistakes, and then Microsoft got lucky when Java lost its first-mover advantage chasing down several blind alleyways -- "Applets", Sun's mismanagement, a bureaucratic open source strategy.

      --
      Don't blame me, I voted for Baltar.
    6. Re:I don't want to be "that guy", however by paulpach · · Score: 5, Insightful

      I am both a professional java and C# developer. Each one has their advantages:

      On the C# camp:
      * delegates and events
      * functional constructs
      * automatic variable types
      * LINQ
      * Value types (efficiently allocate thousands of value objects in an array, you need some really nasty workarounds in java)
      * Generics that keep their types at runtime

      On the java camp:
      * Spring (There is Spring.Net, but lets be honest: it does not compare)
      * Collections library (much more complete and better thought out than C#'s)
      * Maven
      * J2EE
      * A million other libraries freely available, that do _anything_ you want.
      * Portable to more platforms (Mono sometimes leaves something to be desired)

      So in my humble opinion, C# is much more complete as a language, but java has much better libraries and community. So which one would I pick? well, it depends on the project, the platform, and the amount of code I can reuse from open source libraries.

    7. Re:I don't want to be "that guy", however by Darinbob · · Score: 4, Informative

      While Mono allows C#, it does not turn .NET into a cross platform executable environment. Practical programs using C# and .NET are tightly tied to Windows capabilities. Since C# isn't a standardized language, and Microsoft doesn't even stick to their own standards with their own products anyway, there will be incompatibilities between Windows .NET and Mono. Mono also does not re-implement all of the .NET framework and is playing catch up whenever there's a new inevitable .NET release. So if you want a cross platform executable system you are much better off with Java.

      Basically the whole reason for existence of .NET was to tie the developer to Windows. It was created as a direct response to Java being a cross platform system.

    8. Re:I don't want to be "that guy", however by benjymouse · · Score: 5, Informative

      I don't use C#, however last I looked all of its features were borrowed from other preexisting languages, same as Java. Is there something new and Microsoft for once in its life has done something novel?

      LINQ is a pretty big deal. I don't know of any language that has something similar. LINQ itself is comprised of a number of language constructs such as expression trees, extension methods, type inference, anonymous types.

      Async/await is huge! Right there, MS looks to leapfrog other platforms by allowing developers to create robust, asynchronous programs that doesn't need to spin up threads (or use threadpools) to achieve perfectly composable asynchronous methods.

      Dynamic support (statically typed to be of dynamic type) allows the best from dynamic languages to be used from within C#, even interop'ing with dynamic languages and e.g. use an object created in Ruby as a first-class object in C# (or vice versa).

      --
      Reading slashdot one-liner: (irm http://rss.slashdot.org/Slashdot/slashdot).rdf.item | fl title,desc*
    9. Re:I don't want to be "that guy", however by PlastikMissle · · Score: 4, Informative

      C# isn't standardized? Someone should call ECMA and ISO then and tell them they've been had.

    10. Re:I don't want to be "that guy", however by Michalson · · Score: 5, Interesting

      Microsoft has also had the benefit of Anders Hejlsberg being the lead architect, one of the best minds in the industry. There are maybe a handful of people in the industry today that can stand at the same level as him, and none currently alive that can stand taller. Hiring him away was a major boon to Microsoft and a crushing blow to Borland.

    11. Re:I don't want to be "that guy", however by benjymouse · · Score: 4, Interesting

      Microsoft has also had the benefit of Anders Hejlsberg being the lead architect, one of the best minds in the industry. There are maybe a handful of people in the industry today that can stand at the same level as him, and none currently alive that can stand taller. Hiring him away was a major boon to Microsoft and a crushing blow to Borland.

      As much as I love to code in C#, I think that Martin Odersky is at least as smart and knowledgeable as Anders Hejlsberg. I've seen them debate each other and IMHO Martin came out looking somewhat better. And Scala is no small feat.

      --
      Reading slashdot one-liner: (irm http://rss.slashdot.org/Slashdot/slashdot).rdf.item | fl title,desc*
    12. Re:I don't want to be "that guy", however by benjymouse · · Score: 3, Insightful

      Especially since what it actually does, doesn't seem to match up with what they tell you it does. At least in the simple cases they use for examples.

      Citation needed. Care to elaborate?

      Grand Central Dispatch has had similar functionality. The key differences being that Await has more concise syntax for the simple cases, but it gets progressively uglier the more complicated your cases become (such as awaiting a group of tasks that can all be done in parallel to each other

      You mean like
      await Task.WhenAll(task1, task2, task3); ?
      You find that too complicated? I am curious how you would make that code simpler in Java, Objective-C or C?

      GCD's syntax starts off somewhat ugly

      Indeed

      ..., but doesn't really change as you do more complicated things, partly because the syntax already assumes you probably want to use blocks/lambdas by default so you can spin off 2-3 lines of code that don't really need a full function.

      Apart from being verbose and ugly, GCD still does not solve the problem with composability of asynchronous operations. GCD is the equivalent of TPL (Task Parallel Library) in .NET or Futures in Java.

      --
      Reading slashdot one-liner: (irm http://rss.slashdot.org/Slashdot/slashdot).rdf.item | fl title,desc*
    13. Re:I don't want to be "that guy", however by Nerdfest · · Score: 4, Insightful

      ISO is no longer a standards body in many people's opinion after some of their previous dealings with Microsoft. They can quite obviously be bought.

    14. Re:I don't want to be "that guy", however by cbhacking · · Score: 4, Informative

      Java is actually not "entirely OOP based" although it's close enough for most purposes. Example:

      17.ToString()
      works in C#. It (or the eqivalent 17.toString()) does not work in Java.

      In .NET, everything is an object. "int" is another name for Int32, which is a struct (stack-allocated, value-passed object) that inherits from Object and implements a number of interfaces (IComparable, etc.).

      --
      There's no place I could be, since I've found Serenity...
    15. Re:I don't want to be "that guy", however by K.+S.+Kyosuke · · Score: 3, Funny

      In .NET, everything is an object.

      Unless it isn't, of course.

      --
      Ezekiel 23:20
  2. I hate them both by Gothmolly · · Score: 5, Interesting

    As they are the harbingers of the new age, post dotcom world, where overspecced hardware fixes everything, where there are legions of entitled douchebag "developers" who took a certification course, and of apps which can't run in less than 8GB of memory (our resident BOFH hung up on our developers when they asked for a 64GB VM because they kept getting OOM errors in Java).

    In short, both languages rode the crest of the cultural revolution where it is now OK to suck, to offshore code development with no expectation of quality coming back, of "agile" methods where your next version is always going to be the stable one. I'm not exactly saying that these languages CAUSED any of this, but there is at least a temporal correlation.

    Yes, I am a Unix guy, and yes, I have grey hair.

    --
    I want to delete my account but Slashdot doesn't allow it.
  3. What C# have that Java sorely lacks by benjymouse · · Score: 3, Informative

    Async methods (huge!)
    Generator methods
    Partial classes/methods
    Reified generics
    LINQ (as in LINQ to objects, LINQ to Entities, LINQ to XML - all part of the core framework)
    Dynamic typing and -interop
    Value types
    Operator overloading
    Implicit/explicit type conversions

    --
    Reading slashdot one-liner: (irm http://rss.slashdot.org/Slashdot/slashdot).rdf.item | fl title,desc*
  4. Disagree about ease-of-use by sttlmark · · Score: 3, Insightful

    I use both, and I find that .NET really shines when you're in unfamiliar territory and working with a part of the framework that you don't touch every day. Features are more easily discovered and idioms tend to be more consistently applied in .NET, whereas it feels like Java suffers from implementers applying the pattern du jour, forcing you to wade through more docs.

    I attribute much of .NET's success in this regard to the absolutely awesome book "Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries," which includes a lot of direct insights from the designers of the framework. Microsoft has been really good about sticking to those guidelines, and it shows.

    http://www.amazon.com/Framework-Design-Guidelines-Conventions-Libraries/dp/0321545613 ...or maybe I just understand the .NET Framework better because I read that book. I'm not aware of a Java corollary that would give me the same insights, though.

  5. Re:What did you expect? by bmo · · Score: 4, Informative

    C# was the direct result of MS being blocked from using Java,

    No, no it wasn't.

    It was that Sun owned the standard and told Microsoft to quit violating the standard or call it something else.

    Sun sued and won in court, because they were right.

    If the situation was reversed, I'm sure you'd be saying Microsoft was in the right for defending C#.

    Microsoft was always free to use Java and write their own version, as long as it conformed to the standard. But Microsoft being Microsoft, "standards are for pussies."

    --
    BMO

  6. Re: Critical Bugs by benjymouse · · Score: 4, Informative

    There are ciritical fixes released for the .net API every so often via windows update. Neither are flawless in that regard.

    True, neither is flawless.

    But one of them appears to have been considerably better designed (or better QC):

    .NET 4: 34 vulnerabilities Released 2010-04

    Java 1.7: 216 vulnerabilities Released 2011-07

    or the previous incarnations:

    .NET 2: 53 vulnerabilities Released 2006-12

    Java 1.6: 432 vulnerabilities Released 2006-01

    Java experiences 6-8 times the number of vulnerabilities, even over shorter time frames.

    --
    Reading slashdot one-liner: (irm http://rss.slashdot.org/Slashdot/slashdot).rdf.item | fl title,desc*
  7. Re:What did you expect? by bmo · · Score: 5, Informative

    No, they weren't blocked from using Java.

    They were blocked from creating their own non-standard Java.

    Because Sun owned the trademark and the standard. Now owned by Evil Larry.

    You can create your own language and API, but you can't call it Java if it doesn't meet the standard. How difficult is this to understand?

    Poor persecuted Microsoft.

    --
    BMO

  8. Re: Critical Bugs by benjymouse · · Score: 3, Informative

    95% of those java bugs are for the browser plugin. Last time I checked, activeX didnt have a great track record either. They both find about the same amount of server issues. .Net just sells their extra vulnerabilities to the NSA rather than fixing them.

    No they are not. They are all over the runtime and library: Libraries, Hotspot, JavaFX, AWT (many), 2D, serialization, reflection, JAXP, RMI, beans, JAX-WS, etc etc. They are amplified by the fact that many of them are indeed in a library/feature that can be accessed through applets from remote. But the vast majority of the vulnerabilities exists isolated from the applet and could be exploited through other channels.

    ActiveX has nothing to do with .NET.

    And even so, there has been precious few vulnerabilities in ActiveX. The problem with ActiveX was that the model allowed foreign code to execute non-sandboxed on your machine, so that a bug in a control could have (and had) dire consequences. In that regard, ActiveX resembles SUID on *nix: You check at the gate and if the subject appears to have legitimate papers you let him in and assume that he'll be well-behaved. Just like with SUID where a bug in a SUID root tool may lead to system compromise, a bug in an ActiveX control could let the attacker run his own code with your credentials.

    --
    Reading slashdot one-liner: (irm http://rss.slashdot.org/Slashdot/slashdot).rdf.item | fl title,desc*