Slashdot Mirror


Java 1.5 vs C#

SexyFingers writes "Sun released Java 1.5. The non-API stuff that they've added made it finally "catch-up" with C# - since both languages are built to support OOP from the ground-up, their constructs become almost identical as additional OOP "features" are supported. So if you're doing C# and your foundations in OOP are rock-solid, there really isn't any difference whether you're coding C# or Java."

Here's the list of enhancements to the Java Language:

  1. Generics (C# 2.0 already supports this)
  2. Enhanced For-Loop (the foreach construct in C# 1.0, duh!)
  3. Autoboxing/Unboxing (C# 1.0 already has this, everything is an object, even the primitives - not really, but they do it so well...)
  4. Typesafe Enums (again C# 1.0 already implemented this, but I think they've added a little bit more twist in Java, that its actually a better implementation)
  5. Varargs (C# 1.0's params construct, ellipsis construct in C++)
  6. Static Import (I don't know if C# 1.0 has this, or C#2.0, but C# has a construct for aliasing your imports - which is way cooler. Static Import, actually promotes bad coding habits IMHO)
  7. Metadata/Annotations (this is C# 1.0's Attributes, Sun's upturned noses just gave it a fancier name - also, C#'s implementation is better and more intuitive)

They've beefed up the API some, and integrated several packages with the regular JSDK that used to be a part of a separate package or installation ---in my NSHO, the Java API has become bloated...

At this point (even before Whidbey) the deciding factor (as always) for Enterprise work, when choosing a language platform, should be the support it has behind it, in terms of IDE, tools, api, and longevity of the vendor pushing it (forget the OpenSource crap argument, those guys are too in love with Perl, Python, and Ruby - Java could become the child nobody wants to talk about if Sun dies) - right now that's C# and the .NET Framework ---

If you ask Paul Graham though, both language would be utter crap and fit only for idiots :) http://www.paulgraham.com/gh.html [I'm exaggerating, so hold off on those flames.]

66 of 790 comments (clear)

  1. Fix the link by eissimuf · · Score: 2, Informative

    Fix that first link. It shouldn't have a slash at the end:

    http://java.sun.com/j2se/1.5.0/docs/relnotes/fea tu res.html

    1. Re:Fix the link by eissimuf · · Score: 2, Informative

      omg, it hates me... trying one last time Java 1.5

  2. Java 1.5 vs c# 2.0? by hpj · · Score: 5, Informative

    It's a bit unfair to compare the new Java 1.5 release with c# 2.0 since c# 2.0 is not due to be released until sometime Q2 or Q3 next year. But I do agree that before the 1.5 release Java had a lot of catching up to do to c#, but now c# is a bit behind (Mainly because of it's lack of support for generic classes which Java now supports).

    1. Re:Java 1.5 vs c# 2.0? by jeif1k · · Score: 2, Informative

      But will you be releasing those apps before dotNet 2.0 is officially released

      Well, people seem to be reluctant to release code for Java 1.5 as well because there seem to be some backwards compatibility issues as well.

      To me, it doesn't get interesting anyway until gcj and Mono have the features, and both of those are still several months off.

  3. From the Horse's Mouth - might make more sense by Anonymous Coward · · Score: 2, Informative

    Maybe it makes more sense to listen to what the tech lead of Java 1.5 had to say here.

    (= Calvin Austin)

  4. templates by minus_273 · · Score: 2, Informative

    After templates (generics) come out in a few months, i dont expect java to have an easy time catching up.Personally, I really miss templates from C++ and would drift over to the camp that offers it.

    --
    The war with islam is a war on the beast
    The war on terror is a war for peace
  5. Corrected URL by waynegoode · · Score: 4, Informative
    The first link does not work. For the few who might not notice that the problem is the extra / at the end, thep link should be this.

    Perhaps /. will correct the error. I emailed the editor when the story was in preview, but it was too late.

  6. Optimization models by scumbucket · · Score: 2, Informative

    Java has a few advantages over C# in optimization. It's very easy to analyze Java programs to be certain that certain memory locations absolutely will not be modified. That's much harder in languages with native pointers. Those invariants allow you to compile out certain calculations that would have to be done at runtime in a C# program. You can even start spreading loop cycles over multiple CPUs, but I'm pretty certain that the present JVMs aren't that smart.

    --
    CMDRTACO CHECK YOUR EMAIL!
    1. Re:Optimization models by Headius · · Score: 2, Informative

      Several JVMs use an m:n threading model (such as BEA's JRockit) that allows individual Java threads to be handled by different processor threads; this results in some extreme scalability, but obviously adds complexity to the JVM (since it is now required to manage both "green" and "real" threads). I don't believe either the .NET VM or Mono suppose m:n threading (yet).

      FYI.

  7. Re:APIs by Palshife · · Score: 4, Informative

    XML Parser

    You mean like JAXP and JAXB?

    --
    Attention deficit disorder is a complicated issue, spanning several major... HEY LET'S GO RIDE BIKES!
  8. Re:APIs by Moe+Yerca · · Score: 2, Informative
    MD5 is native... java.security.MessageDigest.

    A quick Google for "java MD5" gives a code example in the first hit, http://www.bombaydigital.com/arenared/2003/10/10/1

    Think before you whine.

  9. IIS vs J2EE Servers by knitterb · · Score: 5, Informative

    It's not so much the language that is a question of contest, but the platform they run on. I've done Java programming since 1.1.8, and have deployed on Tomcat, Resin and Weblogic.

    Recently I switched to C# (new job) and I have to tell you, the language is pretty neat with some of the tricks you can do. Nothing ground breaking though.

    What's really missing is the platform for release, and release management. Where are WARs and EARs for .Net? What the fuck is up with IIS (oh yeah, it's crap)?? Where is any sort of replicated server side session management (no, long ass hidden fields are *not* sessions - and a M$SQLServer *only* solution doesn't count).

    The constructs and tricks of a language can be debated as long as you want. You will probably find something nice in every language. But when you have to [operationally] deploy any application, great or not, on some cheap as shit, crap ass, hard to manage, non-repeatable platform such as IIS, that's when the real rubber hits the road with Java.

    J2EE deployment platforms are light years ahead of .Net's deployment platform (singular). Man I miss working with J2EE platforms and loathe IIS...even though it is my job to keep all this stuff running on IIS! :(

    --
    -bk
    1. Re:IIS vs J2EE Servers by nuggetboy · · Score: 2, Informative
      Nothing groundbreaking? What about DataGrid1.DataBind() or built-in viewstate management? I love it to bits when I think back at how horrible stuff like that was in PHP.
      I see your point, but those are features of the .NET framework, not C# as a language. Also, aren't these things available in JSF?
      I don't know what your IIS issues are but on my win2003 servers we've not had a single problem.
      You've been lucky then. We just started to have issues with our ASP applications that *only* manifest themselves with 2003.
    2. Re:IIS vs J2EE Servers by eakerin · · Score: 4, Informative
      SourceSafe is free with VS and will be even better integrated in Whidbey.
      He wasn't talking about source code management, he was talking about deployment packages.

      In the Java world with your Servlet engine, you drop a war (which is a glorified zip) file in a given deployment directory, and the engine unpacks it, and brings the app online. That's your entire process for deploying a simple app. It includes your web pages, classes, libaries, base config, etc.

      SourceSafe may be free, but my biggest complaint with it is it's poor branching, lack of proper security, and non-client-server access menthods.

      I've recently switched the windows developers at work to CVS, and had them install WinCVS and TortoiseCVS. WinCVS handles the hard stuff that you do very rarely. TortoiseCVS handles the everyday stuff. It ties into Explorer and My Computer (and other file browsing areas) and allows you do normal SCM operations (checkout, update, commit, tag, branch, diff, log, etc) right from the file browser.

      It's a nice package to try out if you've never seen it. CVS has it's own problems, but they're pretty easy to watch out for. Once the windows tools for subversion get a little more time under them, I'll probably end up switching our repositories over to it, for the renames, repository-wide version, and O(1) tagging/branching.

  10. Re:All in it together by jungd · · Score: 4, Informative

    ikvm.net ( http://www.ikvm.net ) is a java VM for .NET/Mono that uses classpath for the JDK API. It can also statically cross-compile java bytescodes into IL code. For example, you can compile a .jar into a .dll (even the resources are preserved).

    --
    /..sig file not found - permission denied.
  11. Re:APIs by GileadGreene · · Score: 2, Informative
    Well, let's see, javax.xml.parsers and the related packages that are part of the Java API for XML have been standard since Java 1.4. Meanwhile, javax.crypto (which includes a Message Authentication Code class that supports MD5 hashing) has also been standard since Java 1.4. Java 1.4 is the major release that preceded the one the current article is talking about, and has been out since around 2002.

    So, were you trolling, or did you just not bother to keep up with Java?

  12. Re:APIs by AKAImBatman · · Score: 2, Informative

    Quick correction:

    The XML APIs were part of a standard extension in 1.3. They were added to the core in 1.4. Also, I found the JavaDocs for 1.1, so here's a link to back up my statement that MD5 support has been around that long.

  13. Re:All in it together by mortenmo · · Score: 4, Informative

    Trust me, we looked at that one. The "tool" can only be used in extremely simple circumstances and is not much more than a marketing trick from Microsoft.

  14. API talk... by Chuck+Bucket · · Score: 2, Informative

    Funny, we were talking about the 1.5 APIs last week here at work, while talking about migrating our apps over from 1.4.x. This site Official Java Programming Documentation gives you a ton to think about. I rem when we were on 1.2...

    CB*($#@

  15. Re:Varargs? by Anonymous Coward · · Score: 1, Informative
    That sounds like it should be some Adams-esque race of semi-competent space pirates...
    You're thinking of the Variag, the Vikings who colonized Russia.
  16. Re:Flaws in both Languages by KZigurs · · Score: 1, Informative

    This is flamebait. If you have no need for seroius programming, this don't means others don't. And try to support 500 page site written in PHP and the same - in Java. There is a difference. Therefore, we need, Java. And, we need, C#. Ok, they are not ideal languages, but, they are more or less the best mainstream languages we have now. And, at least, they don't degrade programmers the way PHP do*.

    Also, PHP STILL DOES NOT have anything that remotely resembles ide. Bad. Really, really, bad.

    IntelliJIdea and Java allows me to be much more productive and write better code, because I don't have to live in jet another text editor with sintax coloring added just to call it an IDE. (they don't pay me. It's just a fact. I don't have to think about writing code or looking up variables, I can concentrate on functionality. And, no, I don't use wizards (especially since there are no wizards to optimize Java midlets code to bytecode level))

    But, please remember, each language is for it's own purposes. Why being interpretated (PHP, Perl, Python) is better than having virtual machine?

    From my point of view -

    Java. A nice language, but the API sucks. It's ye good old SUN that develops MIDP standart and forgets to add function drawPixel to canvas.

    C# - Also, quite good, language. Lacks proper operating envorement, is too closely tied to M$ api, but a really good one anyway.

    I can work in both. Just as in LISP, Python, PHP, C++ or perl. None is better, each is more suited for it's own tasks.

    le fin.

    *About PHP degrading developers - Unfourtonately, I has to say, a lot of students coming out of university choose to work with PHP firsthand. It's web developement, it's easier to get first job there, et cera. But, once starting to learn PHP, quite soon they are incapable to think about software design and how their code works. Maybe because programming with some kind of architecture in PHP is a pain in the ass task and nobody knows how PHP code executes in real life?

  17. Re:varargs by CountBrass · · Score: 2, Informative

    I think you've completely misunderstood polymorphism and/or varargs.

    I've never, ever had to write a Java method that would have been better implemented using varargs, but I've written plenty in C and C++ in the past that would have been better written without them...

    I can only think of a couple of cases in Java where varargs would actually improve matters (have a look at MessageFormat, the work around it uses to emulate varargs is painful so varargs would be great there). But I just know varargs will get horribly absued: so overall I think Java was better off without them.

    Personally I think that, overall, Java 5.0 is a mistake. Metadata is already going out of fashion: Google for "metadata hell" to read why. It's a passing fad that's passing. Autoboxing/unboxing *shrug* nice when you need it, but how often do you actually need it? Generics/templates was something I missed when I first moved from C++ to Java 10 years ago: but now it feels like more unnecessary complexity.

    So overall it seems to me the 1.5 changes address some limited circumstances at the cost of additional complexity; and no doubt we'll see them mis-used and abused and that will outweigh any benefit by an order of magnitude.

    What they should have done in 1.5 is strip out all the deprecated crap: Sun has this habit of constantly adding layers but never actually removing the old stuff. I really would hate to be learning Java now: it's so bloody big!

    --
    Bad analogies are like waxing a monkey with a rainbow.
  18. Java is not only a language by hurricane_sh · · Score: 1, Informative

    The comparison only lists some baic language features, it makes no any sense! Java is NOT only a lanuage, it's a platform, it's a system, it provides all kinds of solutions for your desktop, network, micro device and enterprise web service.

  19. Re:Only Microsoft by teromajusa · · Score: 4, Informative

    "For my own opinion I prefer unchecked exceptions as the code is far cleaner. "

    No, the code will just appear cleaner. Hiding exception propogation is an invitation to ignore exceptions. If someone wraps code in a single catch, you can at least see where they've been sloppy. The equivalent in a non-forced exception check is to do nothing, which is invisible.

  20. Re:Meanwhile, C++ goes nowhere by scotch · · Score: 2, Informative
    What do you propose changing in C++, exactly? A general purpose smart pointer is going to be added, BTW.

    C# doesn't really compete directly with C++, it competes with Java.

    --
    XML causes global warming.
  21. Re:Why is there a C# advertisement on /.? by jrumney · · Score: 2, Informative
    I've worked on C# and Java projects. As far as I'm concerned, C# = MS Java.

    Ditto. I'd go so far as to say that .NET has some of the same bugs as the MS JVM and class libraries, especially in the networking support, where Java is streets ahead.

  22. still very different by jeif1k · · Score: 4, Informative
    Don't be fooled by syntactic similarities; C# and Java are still very different languages:
    • C# has value classes
    • C# has operator overloading
    • C# has multidimensional arrays
    • C# has unsafe modules; in unsafe modules, you can call C functions directly (no JNI) and manipulate C data structures and pointers
    • C# does not force you to declare exceptions
    • C#'s generics are efficient for unboxed types while Java boxes in many cases
    • C#'s generics are type-safe across compilation boundaries (I believe Java's are not)

    Basically, Sun did a bunch of things they could do without changing the VM too much and without breaking old code. But for a bunch of other features, they punted and just added a bit of syntactic sugar to the compiler that makes Java look superficially like it's doing the same thing but is much less efficient under the covers.

    For enterprise applications, those differences may not matter much (and they may even be harmful), which is probably why Sun doesn't do anything about them. But for desktop use and application programming, they do matter. Microsoft wanted to create a new language that their legions of C++ programmers could use, and C# is a pretty credible answer for that. Those people don't care about cross-platform features, they care about getting the job done, and if that involves the occasional unsafe module, it doesn't matter to them.
    1. Re:still very different by rabtech · · Score: 2, Informative

      You are correct re:generics. The java complier just wraps all the type casts behind the scenes - the JVM doesn't actually understand generics and the bytecode can't represent them either. Generics gain you nothing except some syntax sugar. This is a direct result of Sun's refusal to modify the JVM to support generics.

      C#, VB.NET, and all dotnet languages that support generics behave differently in that the MSIL can represent and consume generic types and the runtime also understands them.

      For value types, a unique native version of the class is generated per each value type used. (by the JIT). Reference types share one implementation. Constraints also allow for compile-time safety to be enforced wrt generics.

      --
      Natural != (nontoxic || beneficial)
    2. Re:still very different by Bob9113 · · Score: 2, Informative

      C# does not force you to declare exceptions

      Correction: C# does not give you the option of using checked exceptions. Java has both checked and unchecked.

      Checked exceptions, when used properly, are a very good thing. The point of a checked exception is: "Pardon me developer, but did you ensure that precondition X is satisfied before calling this method?" If there is a precondition that is not apparent from the API itself, the checked exception is a good compile-time method for getting the developer's attention.

      That said, I have seen (and even committed) overuse or misuse of checked exceptions. Thus I can understand Microsoft's assumption that programmers aren't smart enough to use them properly.

  23. Re:Sounds a lot like religion by AvitarX · · Score: 3, Informative

    If I am not mistaken MS helped Mono out on their C# implementation.

    In the driver arena this the prefered solution to having a closed official impementation. I would assume it is the same for the sake of a language also.

    --
    Wow, sent an e-mail as suggested when clicking on "use classic" banner, and got a fast response that addressed my msg
  24. Re:Java 1.5 vs c# 2.0? Full of shit by Anonymous Coward · · Score: 1, Informative

    You state that .NET development implies having to purchase VS.NET which makes .NET inferior to Java where you can download the SDK for free and a third-party IDE for free. However you completely ignore that the .NET SDK is also freely downloadable and that there are free third-party IDEs, such as SharpDevelop. As such both stand on equal footing despite your FUD attempt.

    As for docs, you find it easier to use JavaDoc because that is what you learned. Those who learned MSDN find that much easier. It has little/nothing to do with the completeness or organization of either documentation.

  25. Re:With C#, stuck in windoze by fitten · · Score: 2, Informative

    LoL... Write Once, Run Anywhere.... good one there... Java is Write Once, Debug Everywhere. Once you commit to one JVM, you are pretty much locked in because of the incompatibilities in other JVMs. A number of groups are using C# developed apps on both Windows and Linux without any issues at all (as long as the code uses GTK#).

    There are C# development environments on other platforms... Linux for example (Mono) and one can even use Rotor on other platforms. And... at least C# is an open standard.

  26. C# and Java are so similar.... by Manitcor · · Score: 2, Informative

    that I dont care which a client wants anymore. Its like asking for 6 of one and a half dozen of the other. I had been afriad of learning Java for ages but knew C# very well. Then I forced myself to learn Java and as soon as I got into it I kept saying "Wow MS copied Sun!"

    When you think about it though good OO concepts tend to evlove toward similar goals. Languane and usablitly concepts are the same all around. Its to the point now where the differences between Java and C# are more syntax and available libararies. Ive even been able to easily port Java to C# and vice versa since the languges are so similar.

    It has defintaly opened up things more for me, as now I leave it to the client as to what they want. If they are an MS shop then C# is an obvious choice if they use Linux or perfer alternative platforms then Java is obviously what you should build in.

    --
    "Don't mess with him, he taunts the happy fun ball."
  27. Re:Only Microsoft by mcc · · Score: 4, Informative

    it just does not force you to declare and handle checked exceptions, an issue of strong contention within the Java community

    Um, Java supports both checked and unchecked exceptions.

  28. Re:I code C# for a living by CaptnMArk · · Score: 2, Informative

    C# vs Java, mostly a tie (c# good: ref and out parameters, indexers, foreach; c# bad: properties, operator overloading)

    c# library vs Java library: c# is much cleaner in some aspects.

    VS.net vs Eclipse: no contest, VS.net is much worse.

  29. there is a difference by RoninSix · · Score: 1, Informative

    I've looked at most of the posts, and I haven't yet seen someone mention about the pointers and memory allocation that can be used in C#.

    This is where Java and C# differ.

    Java doesn't have these features and most likely will not have them any time soon.

    Of course when using them in C#, you have to label the those areas of code using those features as unsafe.

    "Two wrongs don't make a right, but three rights make a left."

    --
    "Two wrongs don't make a right. But three rights make a left!" - Cosmo, "The Fairly Odd Parents"
  30. Re:flamebait by jeif1k · · Score: 4, Informative

    .NET in the enterprise is currently painful.

    It's not about the enterprise, it's about the desktop. Microsoft had to do something there because C++ and MFC and COM was seriously getting in the way of getting the job done. Java isn't even trying to compete seriously on the desktop, so C# wins by default on the desktop. And (crazy as those people may seem to you and me) Microsoft desktop application developers actually seem to like Visual Studio. If Microsoft can additionally win market share from Java in the enterprise, that's icing on the cake for them.

  31. Re:I code C# for a living by gooser23 · · Score: 3, Informative

    Granted I've only used a few IDEs (VS6, VS.Net2002, VS.Net2003, Tornado for vxWorks, Xcode, Kdevelop & ddd), but of all VS.Net is cleanly the easiest to get things done in overall.

    I did not find Kdevelop or ddd particulary more useful than vi other than having been weaned on VS6 I am simply more comfortable with a GUI than a tty.

    Xcode does every part of project management and structure more correctly than VS in my opinion. The idea that your source tree is separate from your targes and that your targets are separte from your executables just makes sense. There's a lot less special cases this way.

    Tornado for vxWorks (ver 2.2.1 IIRC, its been some time since I used it) is a poor copy of VS6 -- possibly more correctly VS5 or 4, but I've never used those. The one thing that Tornado got right is the remote debugging (e.g., you build a vxWorks system, load it onto your embeded system, and you can debug through your app via ethernet, serial port, or a local pci bus). In fact, without the remote dubugging I would have considered Tornado to be utterly useless.

    The things that set VS apart is its build styles and debugging features. Xcode could catch up on the both of these (esp. the build styles), but I'd say gdb has a long way to go to be on the same leve als VS's debugger. Its really nice to be able to add new code, change existing code, and arbitrarily set the execution pointer. Really the 'advanced feature' I've figured out how to replicate on gdb is changing a variable's value, but even this feels rudimentary to how in VS you can arbitrarily change the contents of memory directly.

    So, in short, what I like about Visual Studio is its build styles and debugging capabilities. But I do think Xcode 1.5 is better thought out, just not as polished in these two areas.

    I should add that all this does not apply to any APIs of the aforementioned products, in which I would agree with you (having used MFC, ATL, COM and WIN32), I don't see why informed person would choose these over the alternatives (wxWindows, stl, boost, Cocoa) if they had a choice.

    --
    "Dying tickles!" -- Ralph Wiggum
  32. Re:I code C# for a living by iezhy · · Score: 3, Informative

    Java has checked exceptions

    exception management in c# is so painful without them

  33. Re:flamebait by Fnkmaster · · Score: 2, Informative

    Well, I think some people might be trying to help Java compete on the desktop. Have you heard of SWT and Eclipse? It does have IBM behind it. I agree that Sun seriously dropped the ball with desktop Java for years, so nobody used it for that. As for developing desktop apps in C++, yes Visual Studio 6 was a very solid choice. Is VS.NET as good? Many people seem to think not. I haven't spent enough time with it to know, and don't really have the desire to.

  34. JNI by Anonymous Coward · · Score: 1, Informative

    Java has had a way to write "unsafe" code from day 1.2. It's called JNI. Write your unsafe code in an unsafe language and hook it in with a dll.

  35. Re:With C#, stuck in windoze by cmorriss · · Score: 2, Informative
    LoL... Write Once, Run Anywhere.... good one there... Java is Write Once, Debug Everywhere. Once you commit to one JVM, you are pretty much locked in because of the incompatibilities in other JVMs.

    You haven't been writing many cross platform applications in Java recently have you? I've been writing large, complex applications that must run on Windows, Linux, HPUX, AIX, OS/400, and Solaris for 6 years now. When I started, your statement was true. However, this has largely become a non-issue. Throughout testing we rarely come across a bug that is specific to a single platform or JVM as long as you use a robust JVM like Sun's or IBM's.

    While you still need to test on all platforms just to be sure, 98% of the bugs found are in the Java code, not the JVM.

    --
    10 minutes working on a sig. What a waste.
  36. Re:Welcome stranger! by Anonymous Coward · · Score: 1, Informative
    One problem remains with our C++ though. We live on a planet inhabited mainly by clueless morons, people who do not like to learn, people who refuse to accept that maybe others have seen farther than themselves.

    I'd be tempted to buy into your argument if I didn't know someone who codes VOIP applications in C++.

    There are books out there (Effective C++ series) that discuss how to write code so the compiler generates intelligent errors messages when it barfs on templates instead of the usual gibberish. Books that teach crazy, convoluted macros and #defines that allow you to do compile-time checks on template code, etc. Plus, the STL is buggy when used in concurrent applications.

    You can learn the basics of C++ in a few weeks with Stroustroup's book. The advanced stuff takes years to learn and even longer to learn how to use effectively. I won't even get into the issues you run into with a build system for C++ code.

    The problem with C++ is that it's too fscking complicated to use. Granted, there are a lot of idiots that think they're C++ coders because they could compile a Hello World! application, but they're not the sole issue.

  37. It's the installation stupid by nzgeek · · Score: 3, Informative

    I've done enterprise-level Java and C# implementations for financial institutions, and reckon there is one thing that people always miss when comparing the two languages: installation.

    C#, despite any other flaws, Just Works(tm). Install Visual Studio, write some code, click the run button. Sure it takes a bit of thinking to get a n-tier implementation up and running properly, but the installation of the back-end stuff (IIS, db connections, remoting) is incredibly simple.

    On the other hand, to get enterprise Java (J2EE, although some would argue that a class library is easier and more versatile), you need to learn how to install an app server (JBoss, Orion, or god forbid WebSphere), and how to configure that system for database connections, performance, session and object permanence, etc..

    None of this really matters in a 'big-iron' enterprise environment, because there's room to hire a websphere monkey to look after the cat-herding. In anything below a mega-corp or mega-bank however, the overhead of running Java can sometimes be a burden that developers just don't want to think about.

    I see it kinda like using Firefox over IE. They both do pretty much the same thing, and one does it 'better', but at the same time requires some effort to implement. Some people just can't be bothered with the effort.

  38. Re:I code C# for a living by swilver · · Score: 5, Informative

    Seriously, I tried most of the IDE's you mentioned and then some, but Eclipse just blows them all away. The fact that it builds a complete syntax tree of your project which can basically be queried in any way you see fit makes refactoring so easy. It can rename method calls for an entire project, add new parameters, reorder parameters, change return code, display what methods call what method in tree form (especially if you suspect the code is dead), displays lots of very useful compiler warnings (unused parameters, variables, methods, unneeded casts, often surprising how many you can find of those in non-Eclipse projects and the possible subtle bugs they introduce). That's just scratching the surface really... it's very evident that Eclipse was written by programmers for programmers, and even after using it for more than a year it still manages to surprise me :)

  39. Re:Limitations of Generics in Java. by fforw · · Score: 2, Informative
    And C# 2.0 has real closures and none of the limitations of java inner classes. No need for the "final array of one element" hack, if you know what I mean.
    no.. what is this hack?
    --
    while (!asleep()) sheep++
  40. You're going to name it what?! by richever · · Score: 5, Informative

    Sometime in 1999 after I'd worked at Sun for about a year, a routine all-hands meeting was held for all of the Java Software division. JDK 1.1.8 was the current version of Java on the street and JDK 1.2 was in the works, almost ready for release. We sat there and listened to the usual rah-rah speaches from the divison's head honcho (can't recall who it was at the time), and then he introduced us to a marketing guy to tell us about the launch for JDK 1.2. As he begun talking he displayed a new slide on the project and it read, in all its powerpoint glory, 'Java 2000!' And he went on to say that the new JDK would be called, not Java 2, but Java 2000. Everyone in the audience started laughing hysterically. We all thought it was a big joke. I mean, Microsoft was on the verge of releasing Windows 2000, so you don't really mean.... Turns out this marketing guy didn't have much of a sense of humor. "I'm not joking", he said. The laughs and knee slappings turned into boos and hisses. Head honcho guy says something like the marketing guys have worked hard on this and that's the name they've choosen. The Q&A session was next and, boy, did both of these guys get an earful! Anyway, I can't say for sure, but I think that had it not been for the outrage and disbelief at that all-hands we'd be stuck with even weirder Java naming convenstions today.

    Rich

  41. Re:Plenty of differences by Deadbolt · · Score: 4, Informative

    Behold BigInteger and its evil twin, BigDecimal. They laugh at silly-big numbers.

    --
    "Honey, it's not working out; I think we should make our relationship open-source."
  42. Re:All in it together by fitten · · Score: 2, Informative

    Interfaces are your friends. Most of what people use multiple inheritance for can be achieved by using multiple interfaces.

  43. Re:Mistake by blowdart · · Score: 2, Informative
    If we're supposed to have a collection of rocks, what the heck would paper be doing in there? More often than not, reasonable coding should prevent this

    That is not what generics do, that's what your base collections of type object does. Generics (at least in c#) allow you to write templated code like

    class List<T> {...}

    where T is the type parameter. it actually comes time to create a List object, you say List or List. Now your list is a type safe list of ints or Customers, instantiated at runtime. You cannot mix ints and Customers in the same list.

    The Java implementation is a compiler hack. It casts everything to objects, so in theory you could mix because it's just a compiler trick. Worse because everything is really an object you can't reflect over the List and work out what type it is a list of.

  44. With Java, stuck in Windows/Linux/Solaris by RdsArts · · Score: 2, Informative

    "I want C# on my *N*X/Window box"

    http://www.go-mono.com/

    "I want Windows.Forms support on my Mac/*N*X/Windows box"

    http://www.dotgnu.org

    If it's a choice of language based solely on the portablity of code, C# wins out IMHO. With Java, you're dependant on Sun to support your system, which is a royal pain. (as anyone with a *BSD box will tell you)

  45. Re:The java generics system is a joke by mdemirha · · Score: 1, Informative

    I did some tests and the benchmarks are really interesting. C# performs incredibly fast compared to Java. I didnt expect that much difference - may be I am doing something wrong...

    Java Code:
    public class Test1 {

    public static void main (String [] args) {

    ArrayList<Integer> l = new ArrayList<Integer> ();

    System.out.println ("Started.");

    for (int i = 0; i < 60; i++)
    {
    for (int j = 0; j < 1000000; j++)
    l.add (new Integer (j));
    l.clear();
    }

    System.out.println ("Ended.");
    }
    }

    C# Code:
    class Program
    {
    static void Main (string [] args)
    {
    System.Collections.Generic.List<int> l = new List<int> ();

    Console.WriteLine ("Started.");

    for (int i = 0; i < 60; i++)
    {
    for (int j = 0; j < 1000000; j++)
    l.Add (j);
    l.Clear ();
    }

    Console.WriteLine ("Ended.");
    }
    }

    Java took 23 seconds to complete on an IBM Thinkpad T30 with Pentium 4M 1.8 Ghz.
    C# took 1.5 seconds.

    First, I want to say that I am not an expert C# or Java programmer. I use C++ mostly, and I really dont know which collections are best suitable for this job in each language. I used LinkedList and ArrayList in java and ArrayList performed 2 times faster than LinkedList. Similarly, I tried LinkedList and List in C# and List performed better than LinkedList - so I compared ArrayList in Java with List in C#.

    Also, instead of adding 1,000,000 items in a list, I tried adding 10,000,000 - but java gave me an out of memory exception. I tried it with 2,000,000 and I got the exact same error. C# worked fine with larger numbers - I tried C# with 50,000,000 and it worked fine.

  46. Re:I code C# for a living by cakoose · · Score: 5, Informative
    C# vs Java, mostly a tie (c# good: ref and out parameters, indexers, foreach; c# bad: properties, operator overloading)

    While 'ref' paramters are debatable, 'out' parameters are stupid. They should have created a way to return multiple values from a function. Allowing first class tuples would have been the correct way to do this (in most C-style languages, tuples are allowed as arguments to functions and disallowed everywhere else). Adding tuples would also have eliminated the need for the hacked up delegate functionality. Then again, Java doesn't have any equivalent functionality, so it could be seen as an advantage for C#.

    Operator overloading is a good thing. It can be abused, but so can anything else. Removing operator overloading doesn't even come close to making it impossible to write obfuscated code. There are many situations where operator overloading makes things a lot simpler.

    Properties are also good. Instead of identifying them through string matching ("get*", "set*"), language-level support for properties allows more accurate data type modelling. In the end, however, the CLR doesn't really have true support for properties. They implement them as methods (like Java, except at a lower level so most programmers don't have to care about it). This implementation mistake resulted in different opcodes for field access and property access, which means you cannot switch between fields and properties without changing the class's public interface (and breaking binary compatibility with client code). It's still better than what Java does...

    Function pointers and anonymous functions. This has got to be the biggest improvement over Java. Unfortunately, class libraries were already designed before the anonymous function feature so they probably wont be designed to take advantage of it. Also, VB and C++ are probably holding things back because, as everyone knows, "language agnostic" is just a euphemism for "lowest common denominator".

    You also forgot generator functions. They make it easier to write pull-style classes (a "pull" XML parser, for example). Though it isn't as powerful as full-blown continuation support, I think it'll still be useful for many coding tasks.

    C# has more comprehensive generics support (aside from variance). Though both languages made the mistake of allowing arrays to be fully covariant (ArrayStoreException), Java got screwed when they decided not to maintain dynamic type information for generic type parameters. This limits the use of generics in often confusing ways. Type erasure isn't a problem in languages that have a good enough type system to avoid resorting to dynamic typing (like ML or Haskell). But C# and Java do not have good enough type systems and the C# people recognized that and chose to keep the dynamic type information around.

    C# is better than Java in almost every way. Java has better enums and support for covariant and contravariant generic type parameters, but that's about it.

  47. Re:All in it together by Anonymous Coward · · Score: 1, Informative

    If you've ever had to program in J# you'll know that it isn't s stepping stone, it's more like a pit of despair.

    The compatibility is ancient, and it's maintained by a klunky .NET to Java abstraction layer. It just gives up on some issues cross language issues (like the signs of integers).

    The only sane person who programs in J# is someone who is forced to port old Microsoft Visual J++ to .NET. But honestly, with the headaches it's given me, my advice is to just bite the bullet and either port the dam thing to real Java or real .NET and relieve yourself of this bastard child of Satan.

    J# is a bad April Fools joke.

  48. Re:And multiple inheritance is due when...? by Anonymous Coward · · Score: 1, Informative

    Bzzzzzzt.... Wrong answer!

    Interfaces are _not_ multiple inheritance. They're virtual classes. You can emulate multiple inheritance with interfaces and a stub for every inherited method, but this is _extremly_ tedious.

  49. Re:Limitations of Generics in Java. by mrright · · Score: 2, Informative

    An anonymous inner class in java can only refer to final variables from the local scope. So you define a final array with one element to copy something out of the inner class context.

    Here is a good example:
    http://c2.com/cgi/wiki?ClosuresThatWorkAroundFinal Limitation

    --
    Private property is the central institution of a free society (David Friedman)
  50. Re:Where can I get C#? by ChatHuant · · Score: 3, Informative

    Free C# compilator? Right here: .NET Framework SDK

    Or here: Mono project

    Free IDE? Here: Sharp Develop

    Or, if you want to test .NET 2.0, go here:
    .NET Framework 2.0 SDK

    As you see, you don't have to pay anything to try C#; since you say you're convinced, go for it!

  51. Re:Mistake by Fnkmaster · · Score: 2, Informative
    Hmm, I just found this bit, admittedly from the lead architect of C#, so I'll take with a grain of salt, but if this is true, it's a bit lame (I also found this, which is from a somewhat more trustworthy source). Damn.


    Also, another piece from Bruce Eckel here. This is even more clear in its skewering of Java Generics. It really sounds like Sun dropped the ball on this one.

  52. Java:JVM != .NET:C# by DoubleReed · · Score: 2, Informative
  53. Operator overloading by evilpenguin · · Score: 3, Informative

    Say Amen!

    Just because operator overloading can be used for evil is no reason to throw the baby out with the bathwater.

    Java lacks a Currency class, so I wrote a Money class some time ago that I use for common financial calculations, and it takes care of the pesky problem (and newbie mistake) of using floating point types for money.

    BUT, in Java, you have to have add(), sub(), mult(), and div() methods. Reading RPN style caclulations consisting of sequenced and nested method calls instead of algebraic operators is painful. Operator overloading is wonderful in those cases.

    Operator overloading certainly can be evil: What does it mean to increment an Employee? Do I really want to know? But for new types that you can actually do algebra with, it is quite helpful.

    And there are other cases.

    In my C++ days I wrote a FileHash class that kept an index of offsets to the start of each text line in a text file. Then I overloaded the array subscript operator so that a text file could used like an array of char pointers (or a String class if you liked). That was a perfectly good use of overloading.

    Moreover I think overloading the array subscript on ordered collections also makes perfect sense.

    I often wish Java had this feature. I agree with every simplifying choice they made except this one.

  54. Re:I code C# for a living by angel'o'sphere · · Score: 4, Informative

    For covariant and contravariant exist several definitons depending on context (inheritance versus template parameters, e.g.)

    Suppose you have a class like this:

    class A {
    A method() { return new A() }
    }

    And another class like this:
    class B extends A {
    B method() { return new B() }
    }

    This construct is called covariant. The class B is ingeriting from A, while the method method() is overwritten in B. Not only is the mthod redefined but also the return value is. As it is redefined to the taype of the class, this is called covariant.

    If the method in A would return a B and the method in B an A, it would be called contravariant.

    For template parameters there are similar definitions, but they are a bit more complex.

    angel'o'sphere

    --
    Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  55. 101 reasons why Java is better than dotNet by Anonymous Coward · · Score: 1, Informative

    this guy wrote an interesting list.

    read the 101 reasons
    here

  56. Re:I code C# for a living by elgaard · · Score: 2, Informative

    >Can somebody explain what you mean by the covariant and contravariant things.

    In an OO language with objects and types we may say that a type, ST is a subtype of T.
    The meaning of this is that an object of type ST can be used where an object of type T is expected.

    Objects of type ST can have more operations (functions) than objects of type T, but it must have the same operations as objects of type T. These operations must have the same number of arguments and results as operations in T. But the arguments to those operations does not necessarily have to be the same type.

    Say T has an operation (signature): ft(a1:Ta) -> (r1:Tr)
    ST must then have an operation: ft(a1:STa) -> (r1:STr)

    Results are easy. A program that do:
    foo:T
    bar:Tr = foo.ft(...)

    requires that bar have a type that are a subtype of Tr therefore
    STr must be a subtype of Tr.

    Arguments are more tricky: A program can do:
    foo:T
    ba:Ta ...=foo.ft(ba)

    foo can be of type T or ST therefore ba must work as an argument to ft in objects of type ST.
    This means that Ta must be a subtype of STa.
    This is contravariance.
    One consequense is that Array[T] is not a subtype of Array[ST] or the other way around. Because Array (or any other collection) must have both a set(T/ST) and get->(T/ST) functions and because of contravariance T must be a subtype of ST and ST a subtype of T, i.e. T==ST.

    It does not work quite like that in Java, because in the foo.ft(ba) the "ft" function defined in the base class, T, would be used.

    But in Java an array of a supertype is considered a supertype of an array of the subtype.

    Object[] objects = new FooClass[10];
    objects[0] = new Object();

    Will give a runtime ArrayStoreException

  57. Re:Java is a 32-bit language; C# is a 64-bit langu by kaffiene · · Score: 2, Informative

    Pure and utter FUD

    from http://www.manageability.org/blog/stuff/why-cant-m icrosoft-deliver-64-bin-dotnet/view

    Despite having a research and development budget that is almost 7 billion dollars a year, Microsoft apparently can't deliver .NET for 64-bit Windows 2003. Infoworld in a recent analysis explains:

    The lack of a 64-bit implementation of the .Net Framework means that the hard work many Windows developers have put into migrating to the .Net development model is for naught on Windows on Itanium.
    In the meantime, IT shops that wish to employ 64-bit Windows as an application server or Web services platform will be forced to revert to the older, Windows DNA (Distributed Internet Applications) environment.

    In stark contrast, BEA Systems and Sun have been shipping JRockit and J2SE with Itanium support ever since JDK 1.4.1 was released. Furthermore, according to the reports 64-bit Opteron support is expected at the same time JDK 1.5 is released.

  58. Re:Mistake by cakoose · · Score: 2, Informative

    The CLR VM knows about generics so it can safely get rid of the casts. The Sun idiots chose not to modify the JVM bytecode to accomodate generics, so the casts need to be there. You don't see the casts because "javac" inserts them for you, but they're still in there, doing what they do best: kill performance.

    While the 50%-70% improvement is definitely not typical, if you do some intense algorithms on collection classes, then you'll probably see that kind of speed up. Just don't expect that kind of speedup for a real-world application.

  59. Re:and how is this insightful? by generalpf · · Score: 2, Informative

    You press CTRL-Break. It's undocumented but it works, even when you're surrogate-debugging a COM object.