Thursday, January 10, 2008

The Inaugural Post

My name is Max Zilberman and I am currently a Enterprise Software Architect for a Fortune 100 company. I have been doing .NET all the way back when no one really understood what .NET really was. To be precise, I started with the Beta 1 of 1.0 and never looked back since.
Other the years, I have been asked a number of different questions on technical topics, some that have been technically inspiring to learn for my self, others that are fun to answer and write about. I am hopeful to use this blog to talk and discuss various topics including Software Architecture, .NET in the Enterprise as well as down to earth topics that are just plain cool.
I have recently received a question that was cool to answer using complete sentences and not just a blurb fired back:

"I've been learning C#.Net and I'm hoping you can provide some insight on something: I've heard that there are some applications that are currently in C and need to be upgraded .Net. At the am I correct that the Developer would have the choice to pick (or at least recommend) the .Net
language as either VB.Net or C#.Net. Can you think of any reason why it wouldn't logically go to C#.Net. Am I also correct that C is a subset of C+ which is a subset of C++ which is a subset of C#, which is a subset of C#.Net? Are all C# versions various releases of .Net?"

 

Now for my answer:


Let’s start with some language history and background on your questions below:
C – as a language has been introduced in the early 70’s as a way to empower the developers to develop the way they want, and also get very good performance. The actual intention of the language was to do system level programming on Unix OS. One of the first compilers (I believe) was done by Brian Kernighan and Dennis Ritchie at Bell Labs and to this day their book remains a classic reference (although I think it is a bad book to learn from, it is good reference). C in itself is what is called a “imperative, functional language” meaning it does not support objects (but it does support object like structures called: “struct”). C was and is one of the most powerful languages around because of its simplicity to learn and the power of the simple libraries that come with and relative interoperability on different OS’s
C++ - was created by the father of C++ Bjorn Stroustrup. Actually the first C++ compiler was nothing more than just a pre-processor to C. Although you can program in C and compile with C++, at the core if you are doing C++ you are really not doing C. Most things are different including, declaration, object notation, passing by val or by ref, method declaration among a notable few. C++’s power is speed, Most applications that require “cycle counting” performance will most likely be done in C++. For example, although Microsoft created .NET, the entire Visual Studio (with exception of some add-ins) is done in C++. The downfall of C++ is its complexity in its notation and memory management. In the interview given by Bjorn about 5 years ago, he mentioned that initially memory management (what we know as Garbage Collection) was part of the language spec, however it was removed because overhead of that processing was very high and computers were not as powerful as they are today.
C# - C# is one of over 20 languages that are now part of the .NET Languages. The simplicity of .NET is that memory management is done for you. Although many say that VB had that from beginning, VB never had the power of inheritance, memory mapping, type safety and many other aspects that are today very natural and native in ..NET. C# has pointers just like in C and C++, but uses for them are very sparse for a general developer. C# has both the benefits of .NET and the elegance of C/C++.
In .NET, the intent of the language is to describe the semantics of the intent, but not the specific code for execution. To be clear, when one writes in .NET what the compiler is doing is translating the C# (or other) code into an executable language called MISL (pronounced missile). MSIL is what is actually executed when a .NET program runs. There are provided tools like “Reflector” by others, that are able to translate MSIL into any language in .NET, thus if the code was originally written in “managed C++” it can be simply viewed as VB.NET or vice versa. (this is called “intent to code” or “intentional programming”). To date there have been 3 specifications of C# (all of course are part of .NET) and the differences are just syntactical (even IL is the same).
For an example we can look at a the change from C# 1.0 and 3.0 for "property declarations":


In 2.0:

public string _firstName = "";
public string FirstName
{
get
{
return _firstName;
}
set
{
_firstName = value;
}
}


In 3.0, C# team realized that most of the properties look alike and make a short hand notation:



public string FirstName { get; set; }



It must be noted that this is a single example among any other language improvements since the C#1.0, all (most if not all) of the syntax from C#1.0 is compatible with the newer specifications.



Now onto your actual question:



The performance has very marginal differences when one chooses to program in VB.NET over C#, however from a style and readability perspective C# wins because of smaller and fewer keywords to describe a statement. There ARE sure differences in the IL that is being produced because the compilers are different, but in the end those differences are very minor.



Having spoken to developers at other companies, most write C#, when they write ..NET code. C# would be my language of choice as well.



That said, it is VERY important to consider the capabilities and willingness to learn for a given development team, and in the end if the decision to choose VB.NET due to the overwhelming majority of programmers who grew up with VB6.  Then that is the right decision



I hope you enjoyed reading this as much as I enjoyed writing it.





MZ

1 comment:

InnerWorkings said...

Max,

Thanks for the excellent historical review of C, C++ and moving up to modern managed code. I really enjoyed it. If you or your readers are interested in learning more about .NET (VB & C#) all all levels (beginner, intermediate, advanced) I'd encourage you to check out InnerWorkings. We've got some free trials and demo samplers that are self-paced and integrated with Visual Studio:

https://www.innerworkings.com/trial

All the best,

Brian