HomeC# Visual C#.NET, Part 1: Introduction to Pro...
Visual C#.NET, Part 1: Introduction to Programming Languages
Learn today what you need to get started with Visual C#.NET. We'll be taking a look at the .NET Platform, the .NET Framework, as well as a quick look at Visual Studio.NET. We'll also take a brief look at the history of programming languages, including machine code, assembly language, as well as high-level languages, such as C#. This is the first chapter of Michael Youssef's book Visual C#.NET (The Absolute Power), printed here with the permission of the author.
Welcome to the first chapter of my book Visual C#.NET (The Absolute Power). I hope that I will add something to your knowledge of Microsoft technologies.
Before we begin with programming languages we must talk about our spoken languages (ie: English, French, etc.). Any language is a set of keywords or symbols (words) that mean something understandable by the people who speak the language. For example the following sentence:
I need a cup of Tea.
When I say this to any one of my friends they will bring me a cup of Tea. What we understand here is that this sentence contains 5 keywords (Keyword meaning a word preserved by a language that has meaning) and because my friends speak English their brain will compile and compute the sentence into something it can understand and execute.
If we convert this example to the computer programming languages world we can say that any programming language contains keywords and that we use these keywords to create a computer program. We can call this set of keywords that we will write to form a program "The Program Code". So, programmers write code to form a program.
Let's complete our human-computer languages analogy again. Any human can understand his own native language and the same applies with a computer. A computer can only understand its own machine language.
NOTEThere are 3 major types for programming languages: Machine, Assembly, High-level languages. Machine language for any computer is created by the hardware designers so it's considered to be the natural language of the computer.
But life is not so easy; English people have to communicate with others who speak different languages, and if we relate this in terms of computer languages we can say that the natural language of the computer, machine language, is very complicated, tedious, and error prone. So languages such as C# were developed to overcome the downfalls of machine language -- it also makes our lives a lot easier!
Let's take for example two people -- one English; the other German. If they want to understand each other the German-speaking person will write a sentence in German and attempt to translate it into English. After the translation is complete, he/she will send it to the English-speaking person. In our human languages analogy we will assume that we write a program in C#. As was mentioned earlier that computers only understand their own machine code language the C# code must be compiled into machine code. At this point the computer will understand and execute the program.
In today's computing world, there is a wealth of various programming languages available to us; however, they can each be categorized into one of the three major types:
Machine Languages
Assembly Languages
High-Level languages
Machine Languages
As was mentioned earlier, a computer can only understand its own machine language. The machine language is the language that the hardware designers create and is quite complicated if you decide to use it to create a program, simply because it consists of sets of numbers (0s and 1s). Machine language uses these sets of numbers to perform various operations.
NOTE In our Human-Computer programming languages analogy if two English-speaking people speak to each other their brains will compile the code and understand it directly. If you are a machine code programmer then you will write the code that the computer will understand directly and execute the program.
Assembly Languages
Programmers found that developing even the simplest programs, using sets of numbers, was a very complicated process so they developed assembly languages. Assembly languages use keywords and symbols, much like English, to form a programming language -- I can personally say that this is much better than the huge amount of numbers used in the machine languages -- but at the same time introduces a new problem. The problem is that the computer doesn't understand the assembly code, so we need a way to convert it to machine code, which the computer does understand.
Programmers developed assemblers which are programs that convert assembly language code to machine language code. By using these assemblers programmers can write code in assembly language and convert into machine code.
High-Level Languages
Computer scientists found that computers were quickly becoming popular all over the world, so they needed faster, easier, and more powerful programming languages than what was currently possible using assembly languages. They designed "high-level" languages and they called them high-level languages because when you develop applications using a high-level language you don't have to deal with low-level details like machine code, which allows you to write keywords that are much easier than assembly and that can perform multiple operations. An example of a high-level language is C#.
A lot of beginner programmers who learn C# don't care to understand what .NET is all about? But, as we will see, they are setting themselves up for failure.
I can't simply jump into a technical discussion about Microsoft.NET, as I'm assuming that you don't know much about programming. I will not use any technical expressions in this section, so when you finish the book please read appendix A -- "About Microsoft.NET".
Today there are more than 400 million computer users in the world, and most of them use the Internet daily for shopping, chatting, business, and many other things. Still, there are a lot of things they can't do by using the Internet, such as comparing prices from various airlines to find the cheapest flight to Paris, or finding the nearest car rental companies and comparing their prices to find one that suits your budget, as well as many other tasks that will make our lives much easier (ie: sending a message to my car via .NET instructing it to unlock its doors in five minutes).
Before Microsoft.NET all these services were simply a dream, and did not exist as there were no platforms that were capable of dealing with these types of services. Also vendors used various techniques for describing their information, and developing the code necessary to integrate such services was a very complex process. Microsoft realized that the future for Internet -- especially these types of services - needed to be improved, so they spent three years creating the .NET platform and released it in July, 2000.
Microsoft considered creating these web services as the future of selling computer applications. For example, if your company specializes in creating services for car rental companies, they would be interested in your products for their own services. Also of note is that there are also various free services offered by a number of companies. You can think of these web services as a new way of executing business logic. Here are some examples of these services:
Service for specifying the nearest Car Rental Companies in my area based on ZIP code.
Service for comparing books prices.
Service for providing times; for example, a service that will provide the local US time for other countries.
Service for comparing airline ticket prices based on the information entered by the user.
Service capable of searching for Internet users between specified intervals.
This is a very simple list of web services that companies can implement; this list can grow enormously in size. Microsoft and a number of other companies have already begun developing such services. Some will be offered at no charge, while others will charge various fees (ie: subscriptions, one-time, etc.).
Applications will be produced that will make use of these services to further extend their capabilities. For example, we have a service that will retrieve the car rental companies based on a ZIP code, so we must develop an application that will use this service and return the results to the user of the application. With thousands of these services and applications to use, users will have rich and powerful applications at their fingertips.
In order to create these powerful applications there must be a programming platform capable of using these services through a powerful international network, such as the Internet, and make the world an integrated unit. This is what Microsoft.NET is about.
NOTEThe concept of Microsoft.NET may not be clear right now, but when you learn more about C# and when you work with Web services you will see the big picture. Do not worry as we've only started wetting our fingers.
In the.NET world these services are known as Web Services. Web Services are connected through the Internet in order for multiple applications to make use of them. There is a part of the .NET puzzle known as the .NET Framework, which provides developers with an easy way to access Web Services. The .NET Framework is the development platform that we will use to develop .NET applications. In a few words we can say that the Microsoft.NET platform is the group of technologies and products that Microsoft spent the last few years, and about 80% of its budget, in research and development. I think you will understand much more after we talk about the components of this gigantic platform.
Most of you will think that the Microsoft.NET Platform is just C# and Visual Studio.NET, but C# and Visual Studio.NET are just a part of the big game. As I said before, Microsoft.NET is just a name for a group of technologies. In the book we will cover C#, Visual Basic.NET, Visual Studio.NET (VS.NET) and the .NET Framework (which we will discuss in the next section), which are all parts of the Microsoft.NET Platform.
To get the whole picture in your mind you must know that there is a group of servers (Microsoft SQL Server 2000, Microsoft Application Center 2000, Microsoft Mobile Information Server 2000 and many others) that Microsoft has dubbed '.NET Enterprise Servers'. These are also another part of the Microsoft.NET Platform. Also, as a part of the Microsoft.NET world and Platform there are a number of new non-PC devices like Pagers, Mobile phones, PDA, and many others that are also a part of .NET technology. How? These devices will be able to run.NET applications made specifically for them. There are also a number of services called .NET Services, which also make up the Microsoft.NET Platform.
Now that you have a good overview of the.NET Platform, we must understand two major components of this Platform.
.NET Framework
MSDN and many other books describe the .NET Framework as "The .NET Framework is a new computing platform that simplifies application development in the highly distributed environment of the Internet", or ".NET Framework is a completely new application development platform". Actually, if this is your first programming book then you may not understand the .NET Framework as being that at all.
When you develop applications using C#, or any other language that complies to the .NET specifications, there must be a way for the Operating System to understand the applications and execute them, and that's the role of the .NET Framework. Let me explain it this way: we have some programming functionality in C# (I'll try to use simple expressions) that enable us to generate random numbers in our programs. So, when we write this function's code, how will C# talk to the operating system (Windows Platform) to generate that random number?
This is pretty easy using the .NET Framework. The .NET Framework knows how to talk to the Operating System in order to generate the random number. Think of the .NET Framework as the programming framework for C# (actually for all .NET Languages). When you program using C# the .NET Framework will understand the code you wrote and talk with the Operating System to execute your program.
Now when we say "The .NET Framework is a new computing platform that simplifies application development in the highly distributed environment of the Internet", we understand that the .NET Framework is a new platform that will help us develop applications quickly and easily while abstracting a lot of complex Operating System details.
Let's get back to our example of generating a random number. If you want to generate it using non-.NET languages you must develop a complex mathematical calculation and you will also need to get the system time of the Computer for this calculation. In other words, you, as the programmer, will deal with Operating System. But, with the .NET Framework we don't have to know these Operating System details and simply use the functionality provided by the Framework to generate the random number. Now that you have a good simple understanding of the .NET Framework you need to know two central components.
For now think of this as the programming functionality and capability that we will use to develop our applications. In our random number generator we use a function to perform the number generating. This function is part of the Class Library. Also, as a note, you can develop Windows applications, Web applications, network applications, and more using this one common library.
NOTEWe haven't studied the concept of classes yet, so don't worry if you find yourself confused. Just understand that the FCL contains the programming functions that you will use to develop applications using .NET.
.NET Common Language Runtime (CLR)
This is a major part of the .NET Framework, but before we know what its role in .NET is, we must understand what Runtime means.
Runtime is the time when you execute your program, meaning the time when your program is running in memory. As its name implies it is the language responsible for running and executing .NET applications, as well as managing memory. Before .NET memory management was the programmer's responsibility and, believe me, it was one of the worst nightmares for programmers. Now with .NET, the CLR will manage memory, which will result in improved applications performance and stability.
NOTEBecause this book focuses on C#, and not the .NET Framework, we will not discuss the Framework much longer. If you need more information about the .NET Framework there are many books available as well as the MSDN resources offered by Microsoft. When you finish the book you can read Appendix: A -- "About Microsoft.NET" -- as it will provide you with background information on .NET.
Visual Studio.NET is a major and important component of Microsoft.NET. Microsoft has spent many years developing Visual Studio.NET.
When you write C# applications you can use the command-line C# compiler, but it can be a very complicated and tedious process, even when dealing with the simplest C# application, so Microsoft developed Visual Studio.NET. Using this powerful tool can save you a lot of time when writing applications. VS.Net provides a drag-and-drop style where you can drag a button and drop it on a form, in the exact position you want, without writing any code; however, if you are using a text-based editor you will have to write many lines of code just to place the button on the form. Visual studio.NET is the Microsoft development environment for .NET applications, so when you develop .NET applications you will prefer to use Visual Studio.NET.
Figure 1Displaying VS.NET development environment when you open it.
Conclusion
In part one of this article series, we've taken a look at the .NET Platform, the .NET Framework, as well as a quick look at Visual Studio.NET, the development tool of choice for .NET developers. We also had a brief look at the history of programming languages, including machine code, assembly language, as well as high-level languages, such as C#. In the next installment, we'll take a look at compiling .NET code, managed code vs. unmanaged code, an overview of the C# language, and much more.
blog comments powered by Disqus