Related
I'm not interested in starting another "who has the bigger member" VB vs C# debate (https://stackoverflow.com/questions/158229/what-are-the-pros-of-vb-net seems to cover that already) though I am interested in indirect differences which may influence developing in one vs the other. All my commercial .NET development was desktop apps in VB until the last 3 months where I had a web project and decided it was a good opportunity to force myself to learn C#. In the course of doing so I've noticed a few non-technical differences:
A lot more mature open source apps and thorough examples are available in C# than for VB.
Third party vendors of add-ins for things like refactoring and documentation tend to support C# better than VB (if at all), with VB support for similar features from comparable C# versions often lagging behind or absent.
ASP.NET jobs targeting C# seem to pay around 15-20% more on average than otherwise identical jobs in VB (at least in Australia, looking on seek.com.au and careerone.com.au for reference).
The jump to ASP.NET, MVC and C# presented a lot of speed humps at once but I think was well worth it. The decision I need to make now is whether to put more energy into pursuing C# for future .NET development or if I might as well stick to VB. Are there any other points of difference between the language (other than direct language feature comparisons already covered) that one should consider in this instance?
I find that VS does more automatic code completion for VB than C#.
It's very useful to know both languages and I personally have to get better acquainted with C# so that I'm comfortable applying for C# jobs which should triple my options.
At the Microsoft 2009 Mix Web
developer conference, all the
presentations that I attended
included code examples in C#, not VB.
In StackOverflow, notice how
questions tagged c# largely outnumber vb.net and
vb.
John Skeet wrote C# in Depth, not VB in Depth.
One thing that has been widely stated when I have participated in hiring (both as a hiring manager, as well as a candidate) is that C# and Java are close enough that converting a candidate from one to the other is fairly easy, and that this is not true for a VB.NET candidate to C#, or Java. This statement has even been extended to C++, saying training a C# or Java developer (to code in C++) is easier than a VB.NET developer.
Though I tend to disagree (I think it is more about how the person sees programming in general) I know that several large, reputable firms will accept candidates for C# or Java jobs that list C++, C# or Java experience. These same firms will in general not look at candidates who only list VB.NET, or list VB.NET as their primary language.
Specifically for web development, becoming proficient in C# made writing javascript (and doing complex things using jQuery) much easier because the syntax is so similar.
I agree with your points, particularly the first. I would add that it seems there are more C# developers out there than VB.NET. If you are looking to hire another developer, you may get more (quantity or quality) from the C# pool. And employers, perceiving that C# is more popular, will go in that direction, and there will be more demand for C# programmers (hence the higher salaries/rates you noticed)
I know that this is an old post but I'd like to add one other factor: all the new stuff gets done in C# first. This comes from my experiences with early WPF development. All the examples where in C# and we were working in VB.Net. It just took extra time to translate. Another example is lambdas, initially you could use expressions (single line) or statements (multi-line) in C# but only expressions in VB.Net.
When .Net was first rolled out, I think that there were a lot of VB6 folks who didn't really get .Net and that it was a whole different animal. I think that those people were partially responsible for the negative perceptions of VB.Net. But that was 10 years ago now and no longer a factor.
Is anyone attempting to implement C# for the JVM? As a Java developer, I've been eyeing C# with envy, but am unwilling to give up the portability and maturity of the JVM, not to mention the diverse range of tools for it.
I know there are some important differences between the JVM and CLR but is there anything that is a showstopper?
There are very significant differences between the CLR and the JVM.
A few examples:
Java doesn't have user-defined value types
Java generics is completely different to .NET generics
Many aspects of C# depend on elements of the framework - delegates etc. You'd need to port the library as well, even for language aspects.
Java doesn't support things like properties and events at a JVM level. You could fake some of this, but it wouldn't be the same.
I don't believe Java has any equivalent to pass-by-reference parameters, even at the JVM level
Subtleties to do with the different memory models would quite possibly bite, although I'm not sure how much is in the C# spec.
Unsafe code in general probably isn't possible in Java
Interoperability with native code is very different between JNI and P/Invoke. This probably isn't much of a problem for you.
You'd have to fake operator overloading and user-defined conversions
You could probably port a lot of C# - but you'd be left with a pretty unsatisfactory experience, IMO.
Going the other way, are you aware of IKVM? It allows you to run Java code in .NET.
Visit http://code.google.com/p/stab-language
The code below if a Stab language code for JVM
using java.lang;
using stab.query;
public class Test {
public static void main(String[] args) {
// Sorts the arguments starting with "-" by length and then using the default
// string comparison
var query = from s in Query.asIterable(args)
where s.startsWith("-")
orderby s.length(), s
select s;
foreach (var s in query) {
System.out.println(s);
}
}
}
Bytecode transpilers
Grasshopper can take a CLR bytecode and transpile it for JVM. Intended primarily for web apps, it does not provide e.g. JVM implementation of Windows Forms classes. Seems somewhat dated, though. The web talks about ASP.NET 2.0, Visual Studio 2008 and so on. First mentioned by #alex
XMLVM can take CLR or JVM bytecode as input and produce either as output. Additionally it can output Javascript or Objective-C. No releases yet, only Subversion. "Experimental development version that is not to be used in a production environment."
IKVM goes in the other direction than OP wants. It provides a JVM implementation running on CLR, a JVM to CLR bytecode transpiler and a CLR library method stub generator for Java. http://www.ikvm.net/uses.html Mentioned by #Jon Skeet
RPC
Why not have CLR and JVM running alongside and make the communication as much frictionless as possible? This is not what the OP wants, but some other answers are already quite off topic in different ways, so let's cover it.
RabbitMQ, has a free option, it is a RPC server written in Erlang with API libraries for C#, Java and more.
jnBridge, the licence may be too expensive for some prospective users.
gRPC, and similar modern RPC libraries offer wide language support, code generation for client libraries in these languages, language independent wire format for data, advanced features like cascading call-cancellation and so on.
Programming languages
Write once, run everywhere ;)
Haxe, compiles to C#/CLR, Java/JVM, Javascript, Flash, Python, … Provides interop mechanisms for each of the target languages. Can be thought about as an ActionScript3 successor to some degree. Seems pretty solid stuff, with at least one company actually depending on it. Much more trustworthy than Stab, mentioned next.
Stab brings some C# features and Java interoperability. Not very useful, you get some C# features, but what you interact with is Java code which does not use them. https://softwareengineering.stackexchange.com/a/132080/45826 The language is relatively obscure, possibly abandoned, with little promise to become better. First mentioned here by #Vns.
Gust of fresh air for the JVM platform ;)
Scala, Kotlin, others, are fairly nice languages running on top of JVM which bring features that a C# programmer may miss in Java. Especially Kotlin feels like a reasonable alternative to C# in the JVM world. Scala may be a bit too large language for a programmer to get comfortable with in a short time.
Mono
That is certainly an option too. Why transpile to JVM if Mono can run it as it is. First mentioned by #ferhrosa
NEW YORK — Nov. 12, 2014 — On Wednesday, Microsoft Corp. reinforced its commitment to cross-platform developer experiences by open sourcing the full server-side .NET stack and expanding .NET to run on the Linux and Mac OS platforms.
According to this press release from which the quote comes, Visual Studio 2015 will add Linux/Mono as a supported platform.
This is a blog written by the Mono project people about it, from the other side: .NET Source Code Integration (November 2014).
.NET Core
A Windows/Linux multiplatform version of (some of) .Net governed by Microsoft. 'nuff said https://github.com/dotnet/core.
Conclusion
It would be now necessary to give these tools/frameworks a try and see how much friction there is. The OP wants to write in C# for the JVM, which may actually work quite well using Grasshopper.
Doing this with the goal to mix C# and Java world libraries in a single codebase may not work so well.
Sources
http://blog.pluralsight.com/new-course-making-java-and-c-work-together-jvm-and-net-clr-interop
It might be simpler to write a converter from IL to bytecode. That way you'd automatically get support for any .NET language on the JVM.
However, this is such an obvious idea that if this hasn't already been done, it's probably extremely hard, or hard to do well/usefully.
Look at Grasshopper. It is a Visual Studio-based SDK and patented .NET to Java converter that enables you to run .NET Web and server applications on Linux® and other Java-enabled platforms.
An option for cross-platform development in C# could be mono: http://www.mono-project.com/
You can use a source-to-source compiler to translate C# into a language than runs on the JVM. For example, there are several C# to Java converters that would allow C# applications to run on the JVM after being translated into Java.
This answer may be late for you, but this one is just new. You may want to checkout Kotlin programming language. It offers the syntactic sugars which C# has and its the closest to C# syntax too, other than any Non-Java JVM language. Its from JetBrains.
I can see two reasons why this isn't getting much enthusiasm.
The first thing to realise is that, when it comes to the actual features of the language, C# and Java are very close. Not only are C# amd Java close, they are also moving in similar directions. There are some features that the JVM won't currently support out of the box, but that's not the real problem. You can always fake what is missing. I think people prefer waiting for Java to get some more sugar, than to create an Almost-Java from scratch. By the time the port is ready, Java may have decided to catch up.
Secondly, the reason why developers prefer C# isn't so much the language itself, but the tools around it, their two-way relationship with C# and how Microsoft supports the whole thing. For example, the C#-XAML combo is friendlier than JavaFX, because C# and XAML were hacked for eachother (e.g. partial classes in C#, bindings in XAML and more). Using C# on JavaFX doesn't improve much. To get the C# experience on the JVM, you need to also port the tools, and that's a much bigger project. Not even Mono will bother.
So, my advice to a Java developer, who wants to use a fancier language ontop of familiar tools, is to check out the existing JVM languages.
Mono is an option too, but I have always been skeptical of it. Even though it is C#-.NET and cross-platform, things built with Microsoft's tools won't generally work on Mono. It is essentially its own thing. We'll see what happens now that Microsoft said they'll be collaborating.
We Want to Run Our C# Code on the JVM
My company has a large C# code base. Well over half of this code is our core engine for creating, reading, modifying, calculating and writing Excel workbooks. We frequently get questions from customers and potential customers asking whether we are going to build a Java version of our engine - many of them are not at all interested in the UI. We even have a few customers who have taken the trouble to use our .NET library from their Java applications.
So, we would like to build a Java version of our core engine, ideally without maintaining a separate Java source code base.
Eric Sink described this problem very well. I am in a similar position except for the fact that our software license includes royalty free deployment, making Eric's choice of Mainsoft a nonstarter for us.
I have been Googling the likes of "c# to jvm" every few months for several years now with no joy. Having spent ~7 years developing similar software for Java, I am confident that the .NET APIs we use in our core engine could easily be encapsulated and we could accomplish everything we need using the Java libraries. So, if we only had a C# -> JVM compiler we could build our core engine for Java and we would no longer have to turn away Java developers who would like to use it.
I am not asking for the technical reasons why Sun does not do a C# compiler. I recognize that Java has no properties or an unsigned 64 bit long, etc... For the sake of argument, just assume that all of these technical issues could be dealt with by extending the JVM and / or other means.
And I am not asking for yet another debate on why one language / stack might be better than the other. The reality in our business is that there are plenty of potential customers using each.
Why Should Sun do a C# Compiler? (IMO of course)
Making it easier to run C# code on the Java platform means more developers and more software for the platform. Is there anything more important to the success of a platform? Jonathan Schwartz is a software guy. I will leave it to others smarter than me to decide whether or not he took on an impossible job as President and CEO of Sun, but having met with Jonathan shortly after he joined Sun my impression is that he understands software and the need for a large base of developers.
So Why Doesn't Sun do a C# Compiler?
NIH syndrome?
The ghost of Scott McNealy?
Too many Java developers dislike or distrust anything related to Microsoft?
They agreed not to as part of taking the big bucks?
???
There must be a good reason. I just cannot for the life of me figure out what it is...
Firstly Sun has zero incentive to implement a C# compiler on the JVM because they have something very similar called the Java programming language.
Its also not really as simple as just implementing a compiler as the Java standard class libraries are not the same as the .net Base Class Libraries. You would end up having to change all the .NET API calls to Java API calls.
Micrsoft had a product called J# which was meant to be for Java to .NET conversion but in the end no one used it as the API was limited to pre Java 2 API so it was mostly useless. It would be the same if Sun implemented parts of the .NET BCL, as only the core portions of it are standardised and royalty free. Parts like ASP.NET and WPF, WCF etc are not part of the ECMA standards and so Sun would need Microsofts permission to implement those API's.
If enough customers want a java version to make business sense to port your application to java then do it, you just wont ever get any help from Sun via a C# to JVM compiler.
Joe Erickson wrote:
Making it easier to run C# code on the
Java platform means more developers
and more software for the platform.
This is an untrue statement. Running C# code on the JVM does not create Java programmers, it creates C# programmers who can execute on a JVM. It only expands the reach of C#, assuming the JVM also translates any microsoft specific calls (i.e. win32) into something that is platform neutral. So if Sun translates IL to Java Bytecode, the only group it helps is: Microsoft. And, given Sun's history with Microsoft during the original C#-Java schism/Visual J++ lawsuits...
Plus, you have to face the technical infeasibility, whether you want to or not. There are fundamental differences in the way the bytecodes are executed that are far more important issues than whether or not there's an unsigned long datatype.
If you must have C# on a non-Microsoft platform, use Mono
Why doesn't Microsoft do a C# to Java byte code compiler? Why don't you do it? There are open specs on each side...
"So, we would like to build a Java version of our core engine, ideally without maintaining a separate Java source code base."
Basically, you want to compile your C# code unmodified, and have it run in a Java-only environment.
IKVM is not what you want. IKVM is three main things.
a. ikvm - CLI implementation of a Java virtual machine (note that this uses Classpath (now OpenJDK) for the Java class library).
b. ikvmc - Compiles java bytecode to CLI bytecode.
c. ikvmstub - Generates java stub classes that call CLI code.
Note that all of these tools depend on CLI at runtime. What you want is exactly the opposite of IKVM, which is of course MVKI (Most Venerable Kompiler Intermediary) :):
a. mvki - Java implementation of a CLI virtual machine (presumably this would use Mono or DotGNU for the class library).
b. mvkic - Compiles CLI bytecode to Java bytecode.
c. mvkistub - Generates CLI stub classes that call Java
Note that none of these would require an existing implementation of the .NET Framework at runtime, so they should be satisfactory to your Java-only customers.
Unfortunately, as far as I know MVKI does not exist, so you're best off doing a manual port (which would inevitably be cleaner, albeit more work).
Edit: Based on the description of Mainsoft, it appears to be similar to MVKI, though I'm not sure what they do for the class library, and unlike IKVM it's not FOSS.
http://jsc.sourceforge.net/ is a c# cross compiler that can convert .NET code to Java (amongst other things).
Expose your .NET API as ASMX web services and you should be good to go.
EDIT: For more heavy-usage scenarios, it would be worth looking into Windows Communication Foundation (WCF). This has built-in, configurable support for security, streaming, different transport scenarios (HTTP, TCP/IP, local named pipes). You are not restricted to SOAP message encoding, but that would probably be the easiest way to interop with Java.
I'm not too sure about your exact scenario, but if you're dealing with large files and the .NET code and Java code are both running locally, you can just save the file to the user's hard drive using .NET and then fetch it from your Java app.
There must be a good reason. I just cannot for the life of me figure out what it is...
It is easy to believe that companies are non-profit organisations which have your interests at heart. It is easy to forget that the only purpose for a listed company is to make money for it share holders. This is a legal obligation and directors/executives have been sacked/sued if share holders don't believe they have failed to do this.
Sun makes Java free because it helps sell their hardware which how it makes money from Java. IBM makes Java free because it helps them make more money on their consulting.
If Sun were to spend money on a C# converter how would it make that money back and make a profit. Imagine you have to convince Sun's share holders. If you can, Sun will make a C# converter.
I wonder whether the Mono project could have made less work for themselves by targeting the JVM instead of developing and maintaining their own virtual machine from scratch. Development effort could have focused on a C# cross-compiler and porting clean-room implementations of the .NET libraries to the JVM. Sort of like an open-source version of what Mainsoft has done. You could then enable inter-language calls between Java and C# code in the same JVM, and deploy Applets and Java Web Start applications written in C#.
I know this might not be what your looking for, but here are some possible alternatives that (if not to you) could be useful to others.
C: You could port as much as possible to C. Now you can make a wrapper in C# and Java (and any other language that can communicate with C) that makes it feel native to their language while programming. The problem now is that you (or them, depending your license) has to build the C part for each platform.
Fantom*: A programming language that according to their home page,
is:
Portable: Write code portable to the Java VM, .NET CLR, and JavaScript in the browser.
Familiar: Syntax Java and C# programmers will feel at home with Fantom's evolutionary syntax.
Object Oriented: Everything subclasses from Obj. Value types when you need the performance.
Functional: Functions and closures are baked in.
Static and Dynamically Typed: Don't like the extremes - take the middle of the road.
Haxe*: (pronounced hex) is cross platform language that compiles to other languages. Soon C# and Java will be supported. It currently supports:
Javascript: You can compile a Haxe program to a single .js file. You can access the typed browser DOM APIs with autocompletion
support, and all the dependencies will be resolved at compilation
time.
Flash: You can compile a Haxe program to a .swf file. Haxe is compatible with Flash Players 6 to 10, with either "old" Flash 8 API
or newest AS3/Flash9+ API. Haxe offers very good performance and
language features to develop Flash content.
NekoVM: You can compile a Haxe program to NekoVM bytecode. This can be used for server-side programming such as dynamic webpages
(using mod_neko for Apache) and also for command-line or desktop
applications, since NekoVM can be embedded and extended with some
other DLL.
PHP: You can compile a Haxe program to .php files. This will enable you to use a high level strictly-typed language such as haXe
while keeping full compatibility with your existing server platform
and libraries.
C++: You can now generate C++ code from your Haxe source code, with the required Makefiles. This is very useful for creating native
applications, for instance in iPhone development.
Haxe Community. (2011, March 11). Haxe Introduction. Retrieved January 29, 2011, from http://old.haxe.org/doc/intro
You can learn more about why Haxe is useful here.
*I have never used this language and I don't know how well this would work.
I made a comment that should really have been an answer:
It is just not technically possible at this point to implement the C# spec on the JVM. C# supports pointers, unsigned types, user defined value types, true generics, passing by reference, and loads of other things. For a very C#-like JVM language, check out Stab.
Mainsoft fakes it. I am sure it takes enormous effort on their part.
Have fun.
Must break checked exceptions.
Must find a way to implement delegates (which are like single-method interfaces added no earlier than load time).
You can run your .NET code and Java code in the same interpreter! See the IKVM .NET-based JVM, and the Boo and Java wiki page for an example use case (using the .NET-based Boo language to write applications using Java libraries).
Joe, I suggest you investigate IKVM. You might find something there that scratches your itch
If i was doing something like cross platform cross language support, I would create a 'common api' since the languages are similar in syntax you could make a translator easy enough. Then instead of calling java or .net apis directly from the core, you would call your 'common api' which would re implement the java and .net apis you would need. In this way you could create a cross language sandbox if you will. Since the main differences in java and c# are object definitions, I would get those by reflecting the C# dlls, and then reconstruct the constructs, then it would be easy to have an interpreter run through and implement the function bodies and convert properties to getters setters already knowing the structure of the files. This of course is assuming .net 2.0, some of the features in 3.0 and 3.5 become very difficult to 'interpret'
It would be complex, but probably not as complex as reconstructing a core in java by hand, and having to have 2 teams working on them seperatly. If this idea sparks some inspiration i might create one. I would really rather see a simpler stable mono installation for mac.
Basically I think a code level interpreter based on a set of common api classes is something very possible to write with a team in a week or two.
Simple. Because Sun would rather not be sued by Microsoft. And while we as programmers might see no viable reason for a suit, keep in mind that Microsoft is quite a bigger company than Sun and has the power to boss them around.
Sun fortunately is in the position of being quite more open than Microsoft however. If such a demand exists, either open source or a third-party could make this compiler for Java and Sun wouldn't have to take the heat.
JACIL is an apparently dead project that attempts to do the reverse of IKVM. Perhaps some motivated folks could use it as a starting point for a viable .Net to JVM compiler.
I guess the better question is why don't you write a C# to Java byte code compiler, if you want one to exist. Waiting for corporate overlords to do something is a bad idea.
A suggestion for creating such an implementation: take Mono's or .GNU's C# front end. Don't bother writing your own.
I think you will find that the Mainsoft, Enterprise Edition tool allows you to run most/maybe all your .NET code under the Java JVM... Seems to be focused more on ASP.NET but will allow C#. It has been available for some time, pity they don't publicize it better!
Warning blurb follows....
Mainsoft® is Java-.NET
interoperability software that enables
IT organizations to move to
Java-enabled platforms such as Linux
while preserving existing investments
in .NET code and skills. The software
integrates seamlessly into the Visual
Studio® development environment,
enabling C# and Visual Basic
developers to rapidly develop and
maintain server and Web applications
that run on Windows, Java EE platforms
or both, thereby reducing application
development and maintenance costs,
time-to-production and total cost of
ownership.
I've been jumping from C# to Java an awful lot and the "differences" between the two are a bit of an annoyance.
Would it be possible to write a set of extentions/plugins that would merge the two languages syntaxes.
I'm talking about adding either IDE support or using language constructs that would for example:
treat these two lines equivalently:
System.out.println("Blah");
Console.out.writeline("Blah");
Automatically notice that when you type in string you mean String
Recognise common API calls and translate them in the background.
The end goal being to be able to write a java/C# program and to pick at compile time which VM/Runtime you are targeting.
If you could do this would it be a good idea?
If not why not?
The two languages are so similar it's painful in some aspects but in other aspects they are really different.
I've seen Code that will translate a C# project into Java and I'm assuming there is probably the reverse, what I am proposing is a middle ground, so we can all just "get along".
No, absolutely not. Certainly not in the languages themselves (as implied by the title) and preferably (IMO) not in the IDEs (as requested in the body).
They are different languages. The idioms and conventions are subtly different. I don't want to be thinking in Java when I'm writing C# or vice versa. I believe developers should be actively encouraged to separate their thinking. It's not too hard to switch between the two, but that switch should be present, IMO.
While I totally agree with Jon Skeet, if you must have this why not create your own library of Java API so you can create System.out namespace which has a method call printLn which calls Console.Writeline()?
That gets you close to what you want.
Just because Java and C# share some similar syntax you need to see past this and think in terms of Java Platform and .NET Platform. The two are distinctly different, so my answer is definitely not.
There actually already is a Java language for the .NET framework, developed by microsoft: J#
This way you get the java-syntax but you are still developing with the .NET framework.
But i am not recommending anyone to use it.
I knew Java before i knew C# so i tried out J# because i thought it would be an easier transition. At first I liked it but after I tried C# I'm never going back. First of all, nobody uses J# so it's kinda hard to find examples and tutorials. Second, C# has (IMO) much more convenient syntax, specially for events, properties, lambda, anonymus methods and alot of other things, it's also being updated every now and then with even more syntax sugar which i don't think J# is.
Maybe if you often write Java and sometimes have to write a .net app it might be a good option.
I think no. I also switch from java to c#. But if the syntax is identical was is to stop someone from trying to compile c# in a Java compiler, or vice-versa.
Visual Studio actually ships with a Java to C# converter, which tries to do some of the things you mention. Unfortunately it fails miserably (1) for anything beyond the simple hello world application.
Despite being very similar on the surface, there are many significant differences between Java and C#, so you would achieve very little by doing what you suggest imo.
(1) To be fair, it actually does a fairly good job if you consider the limitations given for such a task, but in practice the resulting code is of limited use and you have to do a lot of clean up after the conversion.
Firstly what you are describing is not a difference in language syntax but a differences in class libraries. Both languages are relatively simple in terms of keywords and features but understanding or knowing the libraries and how they operate requires considerable learning.
The mistakes you are describing are things that the developer should not be making to begin with - the IDE should not be guessing. There are going to be many cases where you can't easily / trivially translate between java or dotnet. In the end a skilled developer learns and knows when and which class libraries to use.
Actually in the beginning there was no dotnet - microsoft was behind java. They however proceeded to change java in ways not compatible with the java plstform standard. To paraphrase sun sued microsoft and won I'm court. Following that ms proceeded to create dotnet and particularly c# which became microsofts VM platform. Of course along the way a whole stack of things got changed. Microsoft introduced many things which broke Javas run anywhere etc. They have done the same thing with dotnet which have cause problems for the mono team to be able to faithfully reimplemwnt everything for other non windows platforms.
• String vs string.
• lowercase method names (java) v uppercase method names(dotnet).
• Giving java keywords new names - "package".
In the end dotnet was microsoft response so they can control the platform and do their own thing instead of following a standar
I learned Java in college, and then I was hired by a C# shop and have used that ever since. I spent my first week realizing that the two languages were almost identical, and the next two months figuring out the little differences. For the most part, was I noticing the things that Java had that C# doesn't, and thus was mostly frustrated. (example: enum types which are full-fledged classes, not just integers with a fresh coat of paint) I have since come to appreciate the C# world, but I can't say I knew Java well enough to really contrast the two so I'm curious to get a community cross-section.
What are the relative merits and weaknesses of C# and Java? This includes everything from language structure to available IDEs and server software.
Comparing and contrasting the languages between the two can be quite difficult, as in many ways it is the associated libraries that you use in association with the language that best showcases the various advantages of one of another.
So I'll try to list out as many things I can remember or that have already been posted and note who I think has the advantage:
GUI development (thick or thin). C# combined with .NET is currently the better choice.
Automated data source binding. C# has a strong lead with LINQ, also a wealth of 3rd part libraries also gives the edge
SQL connections. Java
Auto-boxing. Both languages provide it, but C# Properties provides a better design for it in regards to setters and getters
Annotation/Attributes. C# attributes are a stronger and clear implementation
Memory management - Java VM in all the testing I have done is far superior to CLR
Garbage collection - Java is another clear winner here. Unmanaged code with the C#/.NET framework makes this a nightmare, especially when working with GUI's.
Generics - I believe the two languages are basically tied here... I've seen good points showing either side being better. My gut feeling is that Java is better, but nothing logic to base it on. Also I've used C# generics ALLOT and Java generics only a few times...
Enumerations. Java all the way, C# implementation is borked as far as I'm concerned.
XML - Toss up here. The XML and serialization capabilities you get with .NET natively beats what you get with eclipse/Java out of the box. But there are lots of libraries for both products to help with XML... I've tried a few and was never really happy with any of them. I've stuck with native C# XML combined with some custom libraries I made on my own and I'm used to it, so hard to give this a far comparison at this point...
IDE - Eclipse is better than Visual Studio for non-GUI work. So Java wins for non-GUI and Visual Studio wins for GUI...
Those are all the items I can't think off for the moment... I'm sure you can literally pick hundreds of items to compare and contrasting the two. Hopefully this lists is a cross section of the more commonly used features...
One difference is that C# can work with Windows better. The downside of this is that it doesn't work well with anything but Windows (except maybe with Mono, which I haven't tried).
Another thing to keep in mind, you may also want to compare their respective VMs.
Comparing the CLR and Java VM will give you another way to differentiate between the two.
For example, if doing heavy multithreading, the Java VM has a stronger memory model than the CLR (.NET's equivalent).
C# has a better GUI with WPF, something that Java has traditionally been poor at.
C# has LINQ which is quite good.
Otherwise the 2 are practically the same - how do you think they created such a large class library so quickly when .NET first came out? Things have changed slightly since then, but fundamentally, C# could be called MS-Java.
Don't take this as anything more than an opinion, but personally I can't stand Java's GUI. It's just close enough to Windows but not quite, so it gets into an uncanny valley area where it's just really upsetting to me.
C# (and other .Net languages, I suppose) allow me to make programs that perfectly blend into Windows, and that makes me happy.
Of course, it's moot if we're not talking about developing a desktop application...
Java:
Enums in Java kick so much ass, its not even funny.
Java supports generic variance
C#:
C# is no longer limited to Windows (Mono).
The lack of the keyword internal in Java is rather disappointing.
You said:
enum types which are full-fledged classes, not just integers with a fresh coat of paint
Have you actually looked at the output? If you compile an application with enums in in then read the CIL you'll see that an enum is actually a sealed class deriving from System.Enum.
Tools such as Red-Gate (formerly Lutz Roeder's) Reflector will disassemble it as close to the orginal C# as possible so it may not be easily visible what is actually happening under the hood.
As Elizabeth Barrett Browning said: How do I love thee? Let me count the ways.
Please excuse the qualitative (vs. quantitative) aspect of this post.
Comparing these 2 languages (and their associated run-times) is very difficult. Comparisons can be at many levels and focus on many different aspects (such as GUI development mentioned in earlier posts). Preference between them is often personal and not just technical.
C# was originally based on Java (and the CLR on the JRE) but, IMHO, has, in general, gone beyond Java in its features, expressiveness and possibly utility. Being controlled by one company (vs. a committee), C# can move forward faster than Java can. The differences ebb and flow across releases with Java often playing catch up (such as the recent addition of lambdas to Java which C# has had for a long time). Neither language is a super-set of the other in all aspects as both have features (and foibles) the other lacks.
A detailed side-by-side comparison would likely take several 100s of pages. But my net is that for most modern business related programming tasks they are similar in power and utility. The most critical difference is probably in portability. Java runs on nearly all popular platforms, which C# runs mostly only on Windows-based platforms (ignoring Mono, which has not been widely successful). Java, because of its portability, arguably has a larger developer community and thus more third party library and framework support.
If you feel the need to select between them, your best criteria is your platform of interest. If all your work will run only on Windows systems, IMHO, C#/CLR, with its richer language and its ability to directly interact with Windows' native APIs, is a clear winner. If you need cross system portability then Java/JRE is a clear winner.
PS. If you need more portable jobs skills, then IMHO Java is also a winner.