Preface


My first real contact with .NET started late in 2001. Since March 2000, I have been hosting a fortnightly Java- related column sponsored by Sun Microsystems (Singapore) in the Computer Times . A friend from Microsoft Singapore approached me and handed me a CD containing the beta version of VS .NET so that I could take a look at it and 'maybe write something interesting' if I so desired.

Of course by that time I had already heard of this new infrastructure from Microsoft. Microsoft had been marketing .NET aggressively for ages, and I had once written a relatively superficial introduction to the C# language. At that time, details were sketchy at best and there wasn't even a prototype C# compiler then.

And so I got my hands dirty with VS .NET Beta 2. After getting an understanding of what .NET is all about, I decided to pick up one of the several languages that support it. Naturally C# became my choice. In fact, my personal opinion is that anyone really interested in developing using .NET has only three choices: C#, VB .NET, and J#. In theory you can develop .NET applications using any of the twenty or so '.NET-enabled' languages (including modified versions of Eiffel and even COBOL). Nevertheless you can forget about all except those that came bundled with VS .NET and are supported by Microsoft. I suppose your project manager will not be very pleased if you submit your (albeit working) .NET module in COBOL codes.

Of the three, I chose C#. This is a powerful object-oriented language with its roots in C++ and Java. (Officially, C# has been touted as the offspring of C and C++ only. Despite the fact that Java isn't mentioned once in the C# Language Specification and other Microsoft literature, it is quite evident that the makers of C# had indeed studied and `inherited some features from Java.) With C#, you can do anything that can possibly be done within the .NET CLR. VB .NET is a significant improvement over VB 6 with the addition of real object-oriented features such as class inheritance and polymorphic method invocation. Nevertheless, there are tasks which a C# program can do that are beyond the reach of a VB .NET program. C# allows the developer to write unsafe codes . You can't do that with VB .NET or J#. The creators of .NET had written huge chunks of the .NET BCLs using C# itself. To me, C# means lots of power, while VB .NET is Microsoft's way of allowing VB 6 developers to migrate to .NET with as little pain as possible. J#, on the other hand, reeks of Visual J++'s failure.

Learning a new programming language from scratch can be an awesome task. Imagine learning a whole new development platform or multi-tiered infrastructure! Nevertheless, it should be noted that most parallel (or competing) technologies are based on similar computer science concepts, and it will be much easier to learn, say, a new object-oriented programming language once you have a good foundation in another object-oriented programming language ( assuming you really understand the fundamental concepts behind object-oriented technology).

During my experimentation with .NET Beta, I realized that learning the CLR is easy if you already know what a JVM is. Similarly, picking up ASP .NET is easier if you have done JSP programming before.

As I was learning about .NET, I couldn't help but compare the differences between C# and Java, ASP .NET and JSP, the CLR and the JVM, .NET and the J2EE framework. I am an experienced Java developer and trainer, and as I was reading through books and documentation, I couldn't help noticing that C# and Java are syntactically very similar. I could have skipped a significant portion of the text - if only I knew which sections to skip.

I didn't want to read about how to use the switch/case keywords in C# again because I already knew that from my Java knowledge. All I wanted to know was that in C#, switch can take in not only numeric types but strings too. That's the difference, and that's all that I needed to know if I wanted to use the switch/case keywords in a C# program. I had to read a whole paragraph just to understand one small point. If only there was a book which highlighted just the differences between C# and Java!

Later that year, Microsoft invited me to a public forum and lecture during the Microsoft's Developers' Festival. While I was preparing my talk, entitled '.NET for Java Developers', I made a list highlighting the differences “ syntactical and otherwise “ between C# and Java. Eventually I decided to turn it into a book (which you are reading now).

The objective is to enable the reader to use current knowledge and experience in Java and J2EE to pick up C# and .NET concepts as quickly as possible. Instead of repeating what I think an average Java developer should already know, I will highlight the differences between Java and C#. This book will not explain what an exception is all over again “ I shall zoom straight in to how C# treats exceptions differently from Java.

As such, this book assumes a working knowledge of the Java programming language, familiarity with the Java syntax, and experience with basic coding concepts such as exception handling and object-oriented programming.

I have tried to present each section using clear simple examples [1] that are short and to the point. Each section is meant to be quite independent of others, and where such dependent knowledge is required to understand a particular point, I state so. I have assumed that it is your responsibility to integrate all the knowledge gained in the separate sections to make use of the language's features in a complex complementary way. My code examples will avoid doing that for clarity purposes.

[1] Have you ever seen tutorial examples which require you to have extensive knowledge of another topic? Such examples really irritate me. I don't like to read long pieces of code just to understand a simple principle, and that's why I have tried to keep my code examples short yet comprehensive.

In order not to clutter up the real meat of each section, I have placed my personal observations, comments, and URLs where you can obtain more relevant information in footnotes.

I hope you find learning about C# and .NET as enriching an experience as mine.

H.N.  Mok  (mok@ieee.org)
July  2002



From Java to C#. A Developers Guide
From Java to C#: A Developers Guide
ISBN: 0321136225
EAN: 2147483647
Year: 2003
Pages: 221
Authors: Heng Ngee Mok

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net