Java 1.5 vs C#
Here's the list of enhancements to the Java Language:
- Generics (C# 2.0 already supports this)
- Enhanced For-Loop (the foreach construct in C# 1.0, duh!)
- Autoboxing/Unboxing (C# 1.0 already has this, everything is an object, even the primitives - not really, but they do it so well...)
- 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)
- Varargs (C# 1.0's params construct, ellipsis construct in C++)
- 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)
- 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.]
...and let me tell you, java doesn't have to do that much to "catch up" to it.
"Quoting famous computer scientists out of context is the root of all evil (or at least most of it) in programming." - K
Where's the story? Or is this just one person's interpretation of Java vs. C#?
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 ---
Why again can't I mod a story as -1 Flamebait?
--
I'll pay you $10. Really.
I want actual functions, not "activity objects". Almost everyone, except for the extreme OO zealots, agree that OOP is not necessarily the best approach to every problem.
Table-ized A.I.
This would get a -1 Flamebait.
My feeling is that these features are good news. There should be no gloating on the part of C#, it was clearly built on Java's coattails.
Competition is a great thing, ain't it?
Neither are open source.
Both require virtual machines.
Despite being marketed as portable, but have portability issues. Java is not backward compatible with older versions. C# has problems with porting some of the graphics stuff to Linux.
We don't really need them. PHP/Perl serve my needs on the web/server side. C++ and Python server my needs on the desktop side.
They're closely tied to their respective companies.
If you think this is flame-bait, check out this article's title.
Seriously, this looks like an ad for C#, a bunch of claims with very little support/evidence for those claims.
I've worked on C# and Java projects. As far as I'm concerned, C# = MS Java. MS could not control Java, so they abandoned support for it and built thier own "version." It's really a rinse & repeat cycle for MS: see successful software, build own version of said software to try to take over that market as well.
Here's my theory. Along with the ubiquitous slashvertisements and the Microsoft-bash-of-teh-day barrage posts, these are a perfect opportunity to create a story that will generate 1,000+ comments and ten times those many page views and ergo ad impressions.
C'mon, C# vs. Java? Outside of "RIAA sues 86 year-old grandma", "We hate Bush, let's talk" and "Microsoft patents KDE" there is no better source of inflammatory material in the dorkosphere.
Sad, really.
I'm not pleased with the "catch-up" game that Java is playing here. Java was a fairly nice middle-ground betweeen high and low level programming, and what appears to be an effort to become a high level language is rather ominous for those who are interested in testability and performance in Java.
This, BTW, is why you don't want your language to be controled by a company which in turn has a marketing-driven bottom-line. The idea that two languages could co-exist with different target audiences is nonsense to marketing droids, but perfectly reasonable to someone like Guido van Rossum, Larry Wall or any of the other maintainers of truly open-source languages. Open source isn't the only way to maintain this focus, but in today's marketing-driven world, you aren't likely to see too many Bell Labs-like organizations putting out languages like C (which was semi-open source, as was Unix). Java and C# are probably much more typical.
I use DOM within XML as well as the MessageDigest using the MD5 algorithm every day. So I'm letting you know...
Or, is your complaint based on the fact that the libraries that underlie the XML and Security algorithm API's can be swapped out? To me, that's a feature not a bug but YMMV.
Waltz, nymph, for quick jigs vex Bud.
I code C# for a living, so according to your definition, sold (or more appropriately rented) my soul to the devil. (This does not change the fact that I personally prefer free/open source technology. My PDA, my media players, my home operating system are all free/open source based.)
Java is not any more closer than C# to open source technologies. Sun doesn't like open source, just as Microsoft.
It's a very well known fact that Java has been a base (or in other words "the" figure) for Microsoft while developing C#, but that does not imply that "Java is good, C# is bad" or vice versa.
I would be happier personally to code in Java, but professional life yields to disqualify who resists new technology.
Your choice of programming language is not your religion, and it can change continuously through your life. Just like your operating system.
While neither Java nor C# is truly free of being controlled by an Evil Corporation(tm), Java at least has multiple vendors, runs on a wide variety of platforms, and has an open standardization process.
He kind of forgot that there are many programmers and customers who DON'T want to deploy their systems on win32. With Java apps, you don't have to. In fact you can choose almost any operating system and hardware. Anybody who chooses C# over Java for enterprise deployments is truly a MicroWeenie.
:]
I much prefer my 8 processor HP UX box any day
Let me know when stuff like an XML Parser and MD5 are native in Java.
They ARE.
XML package
MD5 and SHA support
The former has been in Java since 1.3, and the later since 1.1(!).
Honestly, Java has every feature and the kitchen sink in its core APIs. And if a feature isn't there, it's very easy to write a library to add it. That's why programmers like Java so much.
Any other features you'd like me to find for you?
Javascript + Nintendo DSi = DSiCade
How do you explain that Sun provides official Java runtimes for Linux (and for that matter sells Linux boxes) as opposed to Microsoft's complete lack of support for anything except Windows?
Sun has always been much more open than Microsoft. They are also allowing open-source implementations without fear of reprisal. We'll see if Microsoft manages the same tolerance with Mono.
Galileo: "The Earth revolves around the Sun!"
Score: -1 100% Flamebait
opinion. broken link... poor grammar... this guy is a joke. He pulls out 7 new features!! What about built-in queue support?
Only thing I agree with is generics has been long overdue.
"In the case of Math, where's the bad style in writing Cos(x) instead of Math.Cos(x)?"
... } can be.
None at all, but I cannot count the number of times I have had to change a co-worker's static members into Object methods because of a side-effect of some other change. And don't even get me started on what a nightmare static {
-fb Everything not expressly forbidden is now mandatory.
This problem is the primary reason that C# exists. If the C++ committee had fixed their language, we wouldn't need C#.
It's a big issue for the open source community. The publicly standardized languages have major problems, and the newer languages are controlled by single large vendors.
My biggest beef with java right now (well Sun, really) is that they are make design decisions in the name of backward compatibility that are leading to poor design choices. Backwards compatibility is an important consideration, but it should not be used as an excuse to make poor design decisions. I use a variety of java programs day to day that only work with certain VM versions due to bugs, features, etc. It seems silly to give this one aspect such heavy consideration as if the current java versions are perfectly backward compatible today when they clearly are not.
The new generics feature is clearly patterned after C++ templates, but in the name of backwards compatibility Sun chose to implement generics using erasure. This means that a generic type loses all of its type information leading to a alot of issues including broken support for arrays. Using erasure keeps much of the potentially confusing syntax of C++ templates and virtually none of the power.
I suppose I would be less upset if the feature had a different name. Maybe something like AutoCasting (like the name AutoBoxing). "Generics" implies things that the feature does not even try to deliver. Adding true generic programming constructs to java would have been a huge leap forward for the language. Instead we are left with a toy feature that allows you to build type safe containers, nothing more. Very disappointing.
SYS 49152
Comparing an unreleased version of C# to the available version of Java is just stupid. Further, with no mention of the provided API any discussion is a waste of time. While JAVA offers a bloated API, it is extensible and great for programming, unlike dot NET 1.1 which seems to be an attempt to build OO on top of a procedural framework that doesn't provide the programmer with the same level of flexability. The other thing to consider is that dot NET means normally a purchase of Visual Studio, while JAVA normally means a free download of the JSDK and JCreator. Also IMHO Java doc is much better then the stuff that comes with dot NET. The rest is rant......
Comparing a released software product that is available almost for free to an unreleased product that costs hundreds of dollars is just dumb. Where is the story here?
Coding standards are a waste of time to have to write and read and you know there will be plenty of people who won't follow them, or will at least gripe about their superiors having sticks up their asses for making those decisions. A language should be succinct enough that there should be no need to create a coding standard that has to specify which features to avoid.
I've read the arguments on the topic, but I don't agree.
Relying on documentation to tell API users what exceptions can be thrown is a really terrible idea if you're trying to write server software that has to actually work. And work all the time, 24/7, not just in a demo. MS still seems to be in the mindset where their developers are mostly making client-side VB applications or tiny ASP sites.
We've had a number of cases so far where C# library methods unexpectedly threw an undocumented exception (that would most likely have been a checked exception in a Java implementation). Now, often if you were smart you'll be lucky and the exception falling through to a general handler won't break anything too badly, but other times something unfortunate will happen.
In my book, when Microsoft's fast-to-develop-cut-all-the-corners methodology meets the real world of SLAs where software actually has to work, something has to give. And yes, you can say "just use Java/Python/Cobol/whatever instead" but the point here is debating whether using checked exceptions is a good idea or not.
I'll be honest - I like a lot of things about C#. It's a good language and their IDE is also good. But deciding that checked exceptions were bad was very unfortunate.
> should be the support it has behind it, in terms
.NET.
.NET Framework ---
> of IDE, tools, api, and longevity of the vendor
Eclipse/IntelliJ/Together
Apache/Tomcat, WebSphere, BEA
RedHat/Suse/Mandrake/Debian
All of these tools and vendors have been around longer than C# and
> 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
You misspelled "FUD."
I think the problem you are seeing is Ravioli Code; a (perhaps excessive) reaction to spaghetti code. Also Java (and probably C#) programmers seem to take Patterns too seriously as well, patterns should be descriptive, not prescriptive.
For enterprise-grade work I still prefer J2EE over
Welcome to planet earth - we also have a language called 'C++', but it is rather different from what you describe.
Here, we have compilers that can do bounds checking - avoiding buffer overflows, if you decide to use them.
However, the template feature of our C++ is so powerful, that when used together with structs and classes, one can produce beautiful code that is extremely powerful, yet so simple that it is easy to ensure it is not susceptible to said buffer overflows (or memory leaks or the thousand other plagues of much of the software that surrounds us).
This is why there is actually not anything fundamentally wrong with our C++. We are some who want template namespaces though, but outside of little issues (that do have workarounds) like that, the only things we really want is additions to the (already powerful) standard library, the STL.
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. This is why we, too, have a lot of problems with software in general - buffer overflows as you mention, among many other problems.
I am sure we can arrange for you to get a copy of our C++ standard - that will allow a clever individual, such as yourself, to write software without the problems we discussed. I would then suggest that we join our efforts, in teaching the unwashed masses how to actually use the language properly, so that we will not have to re-do all software in the world (both ours and yours) by ourselves.
Deal?
Java's primitive types are not objects. There's no reason they couldn't have been (compilers that generated efficient arithmetic code from high level components date back to the '70s) but they're not... which means you have to drop down to C-style types over and over again.
It hinders programming efficiency, and it hinders code efficiency: any place where primitive types can be used, the compiler can infer that primitive code can be generated, any place it can't you'd have had to use object types... but the compiler is MUCH smarter about figuring where casts need to be than average (or even above-average) programmers.
Smalltalk is "OO from the ground up". Java is "OO from the Integer up".
In the same light you're also correct - although idealistic - it would be nice to have a language out there that you wont need to to document, annotate, enforces coding style, etc. --- but that's an ideal (i think) - Knuth is making a stab at it with CWeb, his literate programming stuff (just google: Literate Programming), and in the meantime, the world keeps turning...
"Really Good Ide. "
Eclipse supports most languages including python, php, perl and ruby.
"API."
Perl, Python, Ruby and PHP have enourmous libraries to make whatever you are attempting easy.
"Consistency. "
The languages I have mentioned have been "pretty consistent". No language is completely static and each language is trying to improve the best way they know how but they have all kept backwards compatibility pretty good.
"Open source. This is not an argument. In fact, for enterprise world, open source sounds much more problematic than any of good old microsoft solutions."
Well this certainly explains why nobody is using mysql, linux, apache, bind, jboss or any other open source project in any enterprise whatsoever. By golly I think you have something here. Which leads me to.
"They are GUARANTEED to receive support, "
Gee only if there was one or two companies who provided support for open source projects. Too bad you can't buy support from companies like IBM, Novell, RedHat, Mysql etc. Wouldn't that be cool if you could buy support for open source projects.
BTW I am happy that MS provides GUARANTEED support. All those people who bitch about the crappy MS support and documents are all probably liars or open source racist hippies who enjoy dirty jokes.
evil is as evil does
The can and do, he doesn't know what he's talking about. You don't need multiple inheritance to make circular inheritance.
Well people are here now saying oh java is better and people are saying that c# is better. In my opinion both are good and just like competition should do (assuming MS plays by the rules this time) both products will end up the better because of it. For the longest time java had no real competition (in my opinion) and its development slowed down greatly but now that C# is starting to be used more and more often javas development has finally started to take off again. Nothing but good can come from this so rather than flame each other over this I think we should simply consider what features might improve either language and attempt to talk to communicate with the developers when possible to request these features and improve competition all around.
The java generics system just saves typing and ensures type-safety for collections. But it does nothing about the problem of excessive boxing and unboxing that plagued java collection classes from 1.0 on.
For example if you have an ArrayList<Integer> in java, it internally uses an object[] to store the elements of the array. So everytime you write a new value to the ArrayList<Integer> by e.g. calling list.Add(i), a new object is allocated on the heap.
A List<int> in C# on the other hand uses an int[] internally, so adding or changing an element in the List<int> will result in no boxing/unboxing at all. A List will be just as fast as an int[] since the indexer method will be inlined.
The performance difference is dramatic: try creating an ArrayList<Integer>/List<int> and filling it with 1000000 numbers. The C# code will run 10 to 20 times faster, while the java version will use 20 bytes per Integer instead of 4 bytes per Integer like the C# version.
I am currently not at home, but if somebody is interested I will post a benchmark later.
Private property is the central institution of a free society (David Friedman)
Yes, but are you sure it's stepping you in the right direction?
Seriously, I couldn't care less about better performance. I care about being able to avoid probably 75% of all casting that goes on in our 10.000+ source file project and being able to specify our API even tighter and catch more problems before it hits our customers.
I just wish Sun had done this 3 years ago, but better late than never.
Basically because he makes the point Java is portable and c# is not - no matter what the niceties of c# are, it misses this basic feature. Java is comparable to, if not exceeding the features of c#, in addition to its portability. We can readdress this when mono is finished and both languages are on a level playing field, until then, it's a moot point, Java rules. If MS supported .NET on other platforms, this would be a different discussion and not so cut and dry.
ymmv
I would had prefer Java 2000 over Java 2. The first one is clearly meant to be used for marketing purposes ( I think you Sun guys call it branding ). The later is ambiguous. I can't tell if it's a marketing name or an engineering version name.
I'm not too found of Intellisense, actually. I've found that 99% of the time, it locks up my interface while it searches the browser database for a tag, and or it requires me to move my hands from the alpha keys to the arrows to complete a task. It's mentally exhausting to deal with when all I want to do is stream-of-consciousness programming.
I won't even deal with auto-format which is much worse in my opinion...
But to each his own. Best of luck to you!
-Chris
----
Visual C++ user since 2.0.
I like both Java and C# from a language perspective, however, working for a large company, I would recommend Java over MS's .Net. Java has been _very_ stable and _SECURE_ while the .Net security holes have already started at only version 1.1. We also appreciated the fact that we were able to switch our Java server apps to Linux over Solaris, we could even use MS Windows if we wanted to for our Java app servers; we don't have that same choice or luxury with MS .Net.
If Tyranny and Oppression come to this land,
it will be in the guise of fighting a foreign enemy. -James Madison
Well, that is an API issue, not a language issue.
If you wish to address it as an issue with the Java API, the problem there is that it ignores the question of: if exceptions could be just ignored, what other changes to the Java API would be necessary in order to accommodate this? The API designers could no longer assume exceptions thrown by API methods would be caught. This would certainly have a serious impact on how the APIs are constructed and interfaced with.
Irritable, left-wing and possibly humorous bumper stickers and t-shirts
It's too easy to give C# an advantage about what it adds to Java and forgetting it's a 95% Java clone.
Don't forget It took 7 years of Java and a Borland expert to produce C# !
During this time, Java did conquer most of the enterprise application development market and defined a technology model based on application servers handling component lifecycles.
C# as a language,has taken most of java state of the art paradigms and added some new features which are neat but, despite its huge base library is far from Java versatility and degree of maturity.
Java 1.5 advantages
Java 1.5 Drawbacks
- Client Side:
- Swing (but SWT / Eclipse rocks)
C# advantages- Management aspects
- Still time to have plenty of Microsoft support if you have a interesting project.
C# drawbacksSo, my conclusion is that by now, both technologies are interesting but Java is the most versatile.
I would prefer C# for:Windows Programming ,Attractive Web based interfaces (if an acceptable target platform is Mono or Windows),
Porting existing windows applications to Web,
Simple Self-Contained Web Services
I Would prefer Java for developing:Enterprise Applications,Complex Web Services,Highly interactive web interfaces (through applets),Multi OS client application.
For me, both languages are relevant, it's only a matter of what work has to be done and what resources are available to make it.Most of the time, technology is chosen based on a company resources capabilities!