There has been (and still is) an ongoing debate between Java and C# programmers and fans
about which language is superior. (It has turned quite heated between some people I know.)
I just thought I would post my views on it - and I welcome your own on the matter too
1. People debate that Microsoft(R) only created C# because their other language, J# was a failure
out of the box - and they wanted to rival Java and Oracle.
-> This is total rubbish in my view - C# is an independent language - which borrows syntax
and features heavily in some cases, from C, C++ and Java. The fact that it is a fully OOP does
allow that Java has a fierce rival in terms of what language the programmer wants to use.
Microsoft(R) created C# as a support language for their .NET Framework. It was never intended
to port to Linux and MacOSX - but the fact the Mono project has taken off I feel is a great thing.
If I was an employer - and I wanted a Java programmer - I would almost certainly consider a
competent C# programmer as well.
2. People who value C# do not like the "separate file per class" feature of Java, and point to
languages like C and C++ which use "header files" to store class implementations and declarations.
-> Again - I have to personally disagree here. Let's look at an example.
// C# program namespace Sample { public class Dummy { public Dummy() { // ..... } private int PropertyDummy() { set { // .... } get { return //... } } } public class MainClass { public static void Main(string[] args) { Dummy dum = new Dummy(); } } }
To me - I do not see the point of placing two working class in the same file.
Now I know you can place them separate files using namespaces, but the
fact than the above is legal to me just breaks the idea of data hiding.
If I am working on a large project - I do not want other class's methods
and instances to be visible near other classes. I respect the fact Java
does not allow this - and implicitly declares classes should belong to their
own package. Again - just my personal view.
3. Pointers and References - It is well known that pointers are available in C# and in Java
through external libraries. Ideally, pointers are not an issue with most people as GC does most
of the work within both languages pretty well. In C# you can place pointer notation anywhere in
a program as long as it uses the "unsafe" wrapper.
unsafe { int *ptr = NULL; int total = 100; ptr - &total; System.Console.Write("{0}", *ptr); }
In Java, everything is passed by value. There are no references in Java - apart from the
possibility of mirroring references using arrays. C# people I talk to tell me that Java is
"stupid" for not allowing data to be passed by reference. I think it is a great idea. It
protects the original data in the method from accidental modification. This is all part of
the design of Java - safety.
Well I have rambled on enough. Hope you found it a good read - again post your own views on the
two languages and the ongoing debate between programmers.
Wishes Ada xx