Programming is a Concept not a code, that we learn its syntax and go away. Through years, programming has great developments. We have gone from programming using punched cards to programming without code. One of the most remarkable achievements is the Microsoft .NET framework. It simply makes the programmers’ main concentrate on the logic of the software being developed, not how to implement it. In other words, MS .NET framework threw away all the syntax overhead from the programmer and provides us with a great collection of implementations that we can easily re-use. In these series of posts, I’m going to discuss some of the important topics in .NET framework. So, Let’s Start!
We will begin by investigating how programmers develop software before the .NET framework was released.
Life of Zeros and Ones
In the first eras of computing, the main tool for computing was a mechanical device that performs very basic calculations. It used the binary encoding to represent numbers. For example, 5 was represented as 0101. Refer to this Wikipedia article for complete reference of using binary numbers. To give that mechanical device a number, we push a punched card. The punched card is like a piece of paper that represent zeros and ones. A zero was represented by presence of a hole and a one was represented by absence of it. In this way, the mechanical device (a computer at that moment) could read that number “5”. In the same way, we could define operations (like: add, subtract …etc.) using this notation and punched cards.
A step forward, capacitors was invented. It was a great revolution which caused many technological achievements. Capacitors have the ability to store electrical signals. Using this capability, in conjunction with transistors, we could represent zeros and ones as high and low volts. Capacitors and Transistors still getting smaller and smaller. Now, we also have semi-conductors that are used in each computer device nowadays.
Using the approach of zeros and ones is very powerful. However, the problem is that it’s difficult for a human to write and read effective software using this approach. So, the need for a more simpler way to represent data increased and the assembly language appeared.
Assembly language is more readable for human. It consists of machine instructions.That is, instead of writing a binary code (e.g. 10100101) to represent the add operation, we simply write an instruction ADD and give it parameters not in binary (ADD operand1, operand2). This simplified the operation of writing programs. Each machine (processor) has its own instructions, depending on the operations it supports. Two approaches appeared: Reduced Instruction Set Computing (RISC), which uses a small number of instructions to perform operations (32 instructions at most), and Complex Instruction Set Computing (CISC), which uses a more complex instruction set that provide us with easier way to perform operations (actually, we may have much more operations).
Then, we write assembly source code -> pass it to the Assembler -> which in turn convert it into machine zeros and ones.
Using assembly language improves the process of software development. However, the problem is that assembly programing is -low-level, which requires us to posses knowledge on every machine with its instruction set.
A high-level assembler was introduced. We could use it to write assembly code that has some high-level programming language features (like: functions, macros …etc.). But, it’s still a low-level approach.
C programming language was a huge jump from low-level programming to high-level. Using C, we developed software for Windows operating system. We used the Windows API to do all tasks. This API hid the complexity of assembly programming and provided some predefined constructs and data types that we use directly. No doubt that a large number of application that we still use today is written using this approach.
However, the problem is that C programming requires us to do all the memory management tasks. It also, includes using ugly pointer arithmetic. Moreover, writing thousands of code lines and functions makes it spaghetti code, which is very difficult to track in debugging. So, a more improved solution is needed.
A layer was added on top of C, which is called C++. C++ provides us with the full benefits of Object-Oriented programming (Encapsulation, Inheritance, Polymorphism) . Introducing C++, Microsoft released a set of C++ classes that facilitated building Windows application. These classes were grouped together and called Microsoft Foundation Classes (MFC). MFC hid the underlying Windows API and provided classes, macros and code generation tools (wizards).
However, the problem is that C++ is backward compatible with C. That is, C++ support all C features, and hence it’s prone to the problems of memory management, pointers and ugly constructs.
Visual Basic 6.0
Visual Basic 6.0 handled these problems and provided us with some great features. We are now able to build complex user interfaces and code libraries. It’s ability to access databases very easily was a very big benefit. In other words, Visual Basic 6.0 hid the Windows API by using code wizards, VB data types, classes and VB-specific functions. Visual Basic 6.0 was a very good choice to build Windows applications.
However, the problem is that VB 6.0 is not full Object-Oriented (like C++). Rather, it’s object-based. That is, it uses the approach of objects to perform operations but not support Inheritance or polymorphism. VB 6.0 doesn’t support multi-threaded applications. If we want to perform some tasks in parallel, we have to use lower level APIs.
Another solution that was provided by Sun was Java programming language. It has a syntax much like C language. So, programmer didn’t find a difficulty in transition to Java. Java is a Pure Object-Oriented, that is it got rid of all structured programming complexities (spaghetti code). Java is platform-independent, that is write and compile a program once and deploy it to any platform that runs a Java Virtual Machine (JVM). In addition to all these benefits, developers are able to write 100% pure Java applications, without the need to use any additional programming languages’ features. All these benefits made Java a very powerful high-level programming language that is still being used in software development.
However,the problem is thatJava suffers from little language integration. That is, we have to use Java front-to-back during the development life cycle and can’t access non-Java APIs. This is a problem as we can’t interact with applications written in other programming languages. And so, we want another solution to this problem.
Component Object Model (COM) introduced a very good solution to Java problem. COM is Microsoft’s previous application development framework. COM stated that: “If you build your types in accordance with the rules of COM, you end up with a block of reusable binary code“. That is, we are free to use any language we want. But, if we need our applications to interact with other ones, we have to write our code in accordance to COM rules. Other applications, that are written with the same approach, can also interact with our application. COM rules are language-independent, that is any language can write code in COM and hence, interact with other applications. Active Template Library (ATL) provides a set of C++ classes, templates and macros that are compatible with COM.
However, the problem is that COM has a complex data type representation that distract programmers from using it.
And So …
We now, need a solution that handles all these previous problems in a simple and powerful way without introducing new problems that prevent programmers from using it. And now, comes Microsoft .NET solution. It based on the following main points:
– Interoperability with existing source code, to provide language integration.
– Support for many programming languages, to make every programmer write his own lovely language.
– Common run-time engine shared by all .NET-aware languages.
– Comprehensive base class library, to simplify the process for programmers to build rich Windows applications.
– No COM, to avoid complexity.
– Simplified deployment model, to make the application runs on any platform.
The above points are what Microsoft seeks in its solution. But, how are these going to be implemented ?! That’s what we are going to see in the next post.
I’ll be very happy to receive your comments and feedback :).