• Post Reply Bookmark Topic Watch Topic
  • New Topic

Comparing C# to Java 7/8  RSS feed

 
Sayth renshaw
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Was reviewing and learning basic Java and C#, and I have got a base understanding of both. I and am confident in python. Wanting to choose between Java and C#, the main reason in my mind why I would want Java is that it is not tied to Windows/.Net, but in many reviews the libraries of .Net are stated to be some of the best. In my current experience C# is very well integrated in visual studio and seems easy and expressive.

Looking around there are a lot of articles questions about c# v Java but most appear from around 2009 and there has been and is considerable development in Java over that time. In your opinions how does Java compare today and moving forward.

From StackOverflow here http://stackoverflow.com/questions/610199/the-art-of-programming-java-vs-c-sharp

What does C# have that Java doesn't?

•Closures;
•Runtime generics;
•Generics of primitive types (benchmarks of this sorting a list of a million ints vs a million Integer objects have revealed a factor of 3 improvement);
•Delegates;
•Events;
•LINQ;
•Extension methods;
•First-class properties;
•Operator overloading;
•Indexers;
•Anonymous types;
•Expression trees;
•Using blocks;
•No checked exceptions. Hooray!
•Decimal type;
•As of C#: the dynamic type, which is basically duck typing.

And from John Skeet
In my experience of the languages, there's very little in Java but not in C# that I actually want. Enums and static imports spring to mind, but that's about it. There are plenty of things I don't like in Java:

•Type erasure in generics
•Inner classes (as opposed to just nested classes)
•Calling static methods "through" references e.g. myThread.sleep(1000)
•Anonymous inner classes (where a delegate almost always does the job)
•Checked exceptions
There are many things in C# which I wish Java had:

•Language-defined properties (instead of just conventions)
•Delegates and related features:
•Events
•Lambda expressions and anonymous methods (big one!)
•Expression trees
•Extension methods
•Anonymous types
•Methods are non-virtual by default
•Saner handling of readonly/final fields
•Explicit interface implementation
•Iterator blocks
•The using statement
•User-defined value types (such as DateTime, decimal, Guid) and nullable value types to go with them

From Cletus
And Java has:

•WAY, way better enums. C# enums are just ints with a stripe painted down the side. Java treating enums as objects with behaviour is far superior (imho);
•I know this will be controversial: better IDEs, particularly in the realm of code refactoring where Visual Studio (without Resharper) is still lagging far behind Intellij, Eclipse and possibly even Netbeans;
•It runs on Linux. Mono notwithstanding, Windows is by far .Net's biggest achilles heel (imho);
•It's free. Java 6 + Glassfish + Eclipse + Linux costs you... nothing. Now do the same with .Net + IIS + VS + R# + Windows Server...;
•IMHO the Java 5 concurrency utils package is still superior to any sort of concurrency tools that I've seen in C# to date; and
•Significantly more open source projects but that lead is being rapidly diminished.

So basically the site favors at this time C# heavily over Java, with Oracle pushing Java would this still be the same? What do you see as the advantages of Java?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sayth renshaw wrote:•Lambda expressions and anonymous methods (big one!)

This is going to be one of the biggest new features in Java 8.

Nobody said that you have to choose exclusively between Java or C#. In fact, the more programming languages you know, the better a programmer you will be.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sayth renshaw wrote:What do you see as the advantages of Java?

1. Simplicity.
2. final means final.

And that second one is a real showstopper for me. There are several things that I like in C# (first class properties being a particular fave), but the fact that you can override a final method? Atrocious. One of C#'s main developers as much as admitted that it's due to backwards-compatibility (how? when I read the article, C# was only a couple of years old).

When I design a class, I want to know that if I use the keyword final, that's what it means. I don't want to have to seal it, or lock it, or do anything else that, like a Microsoft delete, confirms that, yes, I really want to do this.

On a class, it means I can't extend it; on a field it means it's initialized exactly once; and on a method it means that it can't be overridden. EVER. (or at least, not till I take it off ).

Simple. And for that, I'm prepared to put up with a few "deficiencies".

Winston
 
Sayth renshaw
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From a newbies point I have read and watched differing points of view and videos such as http://redmonk.com/sogrady/2011/02/11/rise-and-fall-and-rise-of-java/

In which redmonk rebuts.
"In November of last year, Forrester analyst Mike Gualtieri published the provocatively titled “Java Is A Dead-End For Enterprise App Development.” This January, the firm’s John Rymer followed up with a more balanced but similarly pessimistic “The Future of Java.” Collectively, these may be considered representative of the conventional wisdom of the enterprise."

Yet even in these ratings it still rates No 1 http://redmonk.com/sogrady/2013/07/25/language-rankings-6-13/

Just want to get peoples point of view in how the languages compare in use and or are people moving not to C# but Go and/or Scala?
 
Sayth renshaw
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:
Sayth renshaw wrote:What do you see as the advantages of Java?

1. Simplicity.
2. final means final.

And that second one is a real showstopper for me. There are several things that I like in C# (first class properties being a particular fave), but the fact that you can override a final method? Atrocious. One of C#'s main developers as much as admitted that it's due to backwards-compatibility (how? when I read the article, C# was only a couple of years old).

When I design a class, I want to know that if I use the keyword final, that's what it means. I don't want to have to seal it, or lock it, or do anything else that, like a Microsoft delete, confirms that, yes, I really want to do this.

On a class, it means I can't extend it; on a field it means it's initialized exactly once; and on a method it means that it can't be overridden. EVER. (or at least, not till I take it off ).

Simple. And for that, I'm prepared to put up with a few "deficiencies".

Winston


So you don't like the operator overloading feature available in C#? It seemed like a convenience in the tutorial I did. But again I am just learning.
 
Sayth renshaw
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The other issue too is that you need to keep learning different ide's as well. Where as c++ with eclipse at least you don't buy then c++ is not a beast I want to tackle.


 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sayth renshaw wrote:So you don't like the operator overloading feature available in C#?

I don't think I mentioned operator overloading (which doesn't even exist in Java); but I have to admit that it wasn't my favourite feature in C++, so I can't imagine I'd feel too differently about it in C#.

It seemed like a convenience in the tutorial I did. But again I am just learning.

Well, you have to understand that it's just my opinion (I thought that's what you wanted); It just happens to be one I hold quite strongly:
I prefer Java's interpretation of final - it's simple and unambiguous. I'm sure that others may feel differently though.

Winston
 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Coming from visual c++ world to Java many years ago. The biggest differrence to me was support and documentation. If you want to learn a new API in c++, you have to look it up in msdn. If you don't purchase msdn you are screwed, and you have to basically use trial and error to figure out how the API works, or pay one of the Microsoft goonsMCPs to train you. Plus the whole attitude of supporting the developer goes into error handling strategies too. C++ gives you cryptic error codes and no contextual information. I was so sick of GPFs. God damn GPFs.

Coming to java, all methods are self documented. Not only that, there was better social networking aspect of support. Everyone is ready to help you. For free. Exceptions that give you stack traces. Good libraries and enhanced features in the language will do you no good if you don't have freely available documentation and no way to investigate problems.

I don't know how things are now. I left that world and was so happy to move to java.
 
Sayth renshaw
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed Winston I appreciate your opinion and that is what I was after.

Jayesh since you came to java, do you think Oracle is improving it, that in some way Java had been left behind?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sayth renshaw wrote:"In November of last year, Forrester analyst Mike Gualtieri published the provocatively titled “Java Is A Dead-End For Enterprise App Development.” This January, the firm’s John Rymer followed up with a more balanced but similarly pessimistic “The Future of Java.” Collectively, these may be considered representative of the conventional wisdom of the enterprise."

Don't believe everything you read on the web, even if it's written by some guy who seems to be a technology news hotshot. Java is everywhere and it is not going to go away anytime soon.
Sayth renshaw wrote:Just want to get peoples point of view in how the languages compare in use and or are people moving not to C# but Go and/or Scala?

Besides Java there are a lot of other programming languages that run on the JVM, and Scala is probably the most popular one, which more and more companies are now starting to use for serious projects.

There's a new version of Java approximately every 2 years. Java 8 is due at the beginning of 2014. It will have lambda expressions and many other new features. For a list of new features and to follow the development, see JDK 8 Milestones.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sayth renshaw wrote:Indeed Winston I appreciate your opinion and that is what I was after.

Great. I have to 2nd all of Jayesh's points too (just FYI, 'GPF' stands for General Protection Fault, which is a 'feature' of languages that allow pointer arithmetic).

The documentation thing is huge: Java was the first language I ever encountered that allows you to document in place, and I still reckon that javadoc should be a major module of any Java course. Unfortunately, many of them skim over it or leave it out altogether, which is criminal.
I honestly don't know how it compares with C#'s doc system, but it's certainly been around longer.

One other thing I'd add is that Java development really can be done with Notepad and the command line - in fact, it's often advised here as the way to start learning the language. And there are tons of other lightweight IDEs around, like JEdit. I wonder how far you'd get with C# with just a source editor and three basic commands?

...do you think Oracle is improving it, that in some way Java had been left behind?

Well, I have to admit not being very impressed with "the great Java 7 scare", especially as it was Oracle's first major release in charge (and 5 years in the making). Doesn't seem to have affected things in the short term though: According to TIOBE, Java's just re-taken the #1 spot (admittedly, by only 0.004% ).

I worry a little that Oracle have a reputation as money-gougers (much of it well-deserved), which may make the language more of a target for crackers; but it's also possible that they'll bring a bit more structure to the release process - Java used to be kind of "Sun's pet project", so release content was a bit haphazard.

Winston
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:I wonder how far you'd get with C# with just a source editor and three basic commands?

There's a command-line compiler for C# too, so I think it wouldn't be a lot different from writing Java in a basic text editor and using javac on the command line.

Winston Gutkowski wrote:Well, I have to admit not being very impressed with "the great Java 7 scare", especially as it was Oracle's first major release in charge (and 5 years in the making).

The "great Java 7 scare"? I've never heard that.

Winston Gutkowski wrote:I worry a little that Oracle have a reputation as money-gougers (much of it well-deserved), which may make the language more of a target for crackers; but it's also possible that they'll bring a bit more structure to the release process - Java used to be kind of "Sun's pet project", so release content was a bit haphazard.

How does Oracle being a commercial company wanting to make money make Java a target for crackers?

Java 7 was delayed a number of times before it was released, that was mainly because it wasn't going very well with Sun, they probably didn't have the time and money to get it out as they originally planned. It looks like Oracle has committed itself to release a new version of Java approximately every two years. Java 8 however has also been delayed and features that were planned originally (such as the module system) have been postponed to version 9 or later.
 
Sayth renshaw
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where oracle is adding utils such as date into Java 8 but leaving the old version as well, will I be warned I am using a deprecated module? And would it be removed or moved to a "legacy" module in 9?
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:The "great Java 7 scare"? I've never heard that.

Check out here.

How does Oracle being a commercial company wanting to make money make Java a target for crackers?

I didn't say it was because it was a commercial company. So was Sun.

MS is a favourite target for crackers because it's seen in many circles (rightly or wrongly) as the "bete noir" of the industry, and also the biggest - and everybody likes to take the top dog down a peg. Sun somehow always managed to keep a reputation as an "honest broker", but I don't think the same is true of Oracle; so I just worry a bit that crackers might try to target Java as a protest. I'm not saying it's right, or even that it'll happen; I just raise it as a possible concern.

Winston
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, you are referring to the security holes that were found in Java a few months back. Those are really only of concern for people who have the Java browser plug-in installed. Java applets are very unpopular these days, so most people don't need the browser plug-in. For server side Java software, those security bugs are not relevant at all. Since Java's biggest use is for server side software, the "Java 7 scare" wasn't a big deal for companies that use Java for their enterprise software. It did not and will not damage Java's reputation for enterprise software.

I don't believe that Java will be more of a target because Oracle is seen as a big, greedy company. Criminals who want to steal money from people will try to hack into people's computers any way they can, and if Java provides ways for that, they will exploit that, and the criminals don't care who owns Java. The only thing they're interested in is stealing money.
 
Chok Sheak Lau
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a short reply to an interesting question. I would say that you can forget about the syntax, and focus on the delivery platform. C# GUIs can only run on Windows, but they tend to have a better quality. You can run C# server apps on Linux using Mono, but I am not sure how much support you can get.

Java is more portable but the GUI quality might not be as good as that of C# GUIs. Java server apps on Linux work wonderfully well.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!