courses
Articles
11.05.09
Six C# features Java developers will kill for...
Ran Kornfeld
C# is called Java on steroids, and everyone agrees that...
11.05.09
Six Java features C# developers will kill for...
Ran Kornfeld
Not everything on the .NET framework is perfect, and Microsoft...
Articles
Training Materials
Get free access to high quality training materials
Trainologic's platform
Trainologic's platform is a great opportunity for professionals to make money from their expertise
Articles & referrals
Six C# features Java developers will kill for...
Ran Kornfeld
May 11, 2009
C# is called Java on steroids, and everyone agrees that it is based on some long-time Java ideas and concepts. But, there are differences, and some of them make C# very powerful compared to Java. Here are six of them.
This year, Java celebrates its 14th birthday. During those 14 years Java was known for its powerful yet simple syntax, allowing developers to accomplish any task with ease and grace. But, this simple syntax is also a limitation, since many developers are now professionals with years of experience and are not afraid of complex syntax and rich feature lists.
Here are 6 features that are available in C# (and other .NET languages), but are missing from the Java language. These are features that can make a developer happy, and his code shine. I must mention that you can accomplish everything without using any of those features - but why??
So, here they are:
| 1. | The @ symbol for strings - so simple, so useful. Instead of dealing with all kind of annoying escaping, just mark the string literal with a @ symbol and it tells the string constructor to ignore escape characters and line breaks. |
| 2. | Operator overloading - This features is missing from Java with the excuse of simplicity. It can make your code look so nice and useful, that we do not want any excuses! |
| 3 | Indexers - They seem strange at first sight, but when you check their use with the String class for example, you can really understand their power. "Access string characters with the [ ] operator? I thought strings are objects..." (Overwhelmed Java developer). |
| 4. | Conditional compilation - Tell the compiler what to compile and what to ignore. How come no one thought of that before? (Actually they did). How hard it is with Java to add trace statements to your code, when you want those statements to just disappear from the final product and have no performance influence! |
| 5. | Partial classes - same class, two source files. Can be very useful for automatic code generation engines and just general code organization. Brilliant. |
| 6. | Extern aliases - This feature really overcomes a Java problem, that make developers sometimes lose their hair. In Java, if you have two versions of the same class library (same qualified names for different classes) you are in trouble. The way the Java class loader works, applications can fail with strange errors, and there is almost nothing you can do to solve it. Using external aliases for assemblies (or in Java - jar files) really solve this gracefully. |
There are more features that I have not included: different useful operators, properties, structures and more. Being a Java developer that moved to C#, I can tell you that I was amazed to discover this world. I just hope the guys at the JCP (Java Community Process - responsible for the Java specs) will add some of those features to their next versions.
For the sake of Java developers around the world...
Community Development
We have created a unique development process that harnesses the power of a worldwide community an...
High quality courseware
Get constantly updated and optimized courseware for your courses at attractive prices
Wish to develop a new course?
Browse the syllabi at Trainologic's site and find an undeveloped topic that fits your expertise (...
blog
16.06.09
rank
Managing WebSphere 6 Resources with JMX - How to (part 2)
15.06.09
Gal Marder
Java 6 Split Verifier
15.06.09
