On 09/10/2009, James Taylor jmon.monster@googlemail.com wrote:
Mono is an awesome open source implementation for .net - You could try getting Mono for windows and keep writing in Visual Studio but running in Mono, then when you port to Linux it isn't so much of a surprise. I actually develop in VC# express for my linux box.
I'd quite like to try Mono/C# to see what all the fuss is about, but I don't know the language. There was an interesting Java -> C++ transition document I read years ago. Is there some similar C++ -> C# document that you would reccommend?
To be honest, a Java -> C# tutorial might be better - couple of quick things first.
What we're talking about is .Net. .Net is a compiled language called CLR, which you then write in any language you like in, that compiles to that CLR. So I can write in C#, you could write in VB, someone else could write in J# and we could all use each others libraries and classes as if they where written in our own langauge... So when I talk about C#, some times I am talking about it as a langauge (i.e. its syntax) and sometimes I'm talking about how .Net works.
<the following is my opinion only I'm not looking to start a flame war. Also Java has had another major release since C# has released - the two languages cause each other to become better>
C# is better then Java because basically, its younger. it was invented about ten years after Java and got to avoid all the mistakes that Java happened (through standards in naming conventions through to much more complex things. Microsoft pumped a lot of time and effort into deciding how it would work, instead of other languages which have "evolved", this has had a very clear design iteration to it.
On one level, it works just like Java - its requires a virtual machine to run in, although instead of Java saying "write once, run eveywhere" .Net decided to go down the line of "write once, and understand that some bastard might be running it somewhere else" so there is a very clear delineation where you can write something like this:
if(!HttpListener.IsSupported) { throw new ApplicationException("Windows XP SP2 or Server 2003 minimum required to use HttpListener Class"); }
Now, this bit of code means that my code *will* run in Linux or a Mac (or even Windows XP SP1) but when It reaches that line I'm able to detect it, and either fall over gracefully, or provide an alternative (in this instance, I've thrown an app exception which for this app probably means game-over.
The other great advantage over Java is the use of unmanaged. I've been writing C# full time for about five years now, and had been writing bits here and there before that, and in this time, I've only ever written two classes which where unmanaged, and they where hardware interface classes - if you're a hardware hacker, then you will probably do a lot more.
The difference is that in Managed (normal), C# acts and feels like Java - you don't have pointers, you have references. When something goes out of scope, the garbage collector eats it up. In Unmanaged, you have access to things like malloc. Now, you loose a lot of power of C# protecting you, but you gain the power of being able to do your own funky small efficient nasty code. To swap into unmanaged is a simple one word tag.
Downside of C# is that it has lost its Forced Exceptions (controversial!!) The reason I call this a downside is that there is no way to (at compile time) see which functions *might* throw an exception. If a programmer (especially of a class in another dll) has not documented (and there is a funky .net documentation feature javadoc but using XML tags), then that can goes unnoticed until that exception is actually thrown.
I'd rather not spend a lot of money on a C# book that spends > 50% of the time teaching you what a for/do/while loop is and what if statements are, or what objects are.
Try:
http://www.harding.edu/fmccown/java1_5_csharp_comparison.html http://www.25hoursaday.com/CsharpVsJava.html