The C Sharp Language and Environment

From Techotopia
Revision as of 15:01, 9 January 2008 by Neil (Talk | contribs) (New page: C# is the latest progression in a never ending quest to make it as easy and efficient as possible for humans to program computers. Whilst it would be easy to simply describe C# as just ano...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

C# is the latest progression in a never ending quest to make it as easy and efficient as possible for humans to program computers. Whilst it would be easy to simply describe C# as just another programming language the fact is that C# is actually an integral part of an entire development and execution infrastructure. There primary object of this chapter of C Sharp Essentials is to provide an overview of both C# and the infrastructure on which it relies. By the end of this chapter it is intended that you have a clear understanding of what acronyms such as CLI, CLR, VES, JIT and .NET mean.

The Brief History of Computer Programming Language

The problem with programming is that computers think exclusively in numbers (the numbers 0 and 1 to be precise) known as machine code while humans communicate using words. In the very early days programmers actually entered machine code directly into computers to program them. This, as you can imagine, was a laborious and error prone process. The next evolution was to associate brief human readable commands with the correspending machine code. For example, a programmer could enter the command MOV to transfer a value from one microprocessor register to another. These commands would then be translated into machine code by a piece of software called an assember, thereby giving this command syntax the name Assembly Lanaguage. Next came a series of high level languages designed to make it easier for humans to write programs. These programs are written using a human readable syntax and then either compiled to machine code by a compiler or interpreted on behalf of the processor by an interpreter. Such languages include BASIC, COBOL, Pascal and Fortran. One other such language is called C which was created at AT&T Bell Labs in the late 1960's and early 1970's. In the late 1970's and early 1980's work started on an object oriented approach to C programming culminating in a new, object oriented variant of C known as C++. The story, however, does not end there. The problem with C++ was that it was incredibly an incredibly easy language in which to make programming mistakes. C++ would quite happily allow a programmer to make coding mistakes that would cause buffers to overflow, memory location to be arbitrarily overwritten and introduce memory leaks that would cause applications to bloat to the point of using up the entire physical memory and swap space on a system. Another problem encountered with C, C++ and all other compiled languages is the fact that the source code has to re-compiled for each different processor type making it difficult to port an application from one hardware platform to another.

In order to address the short-comings of C and C++ Sun Microsystems started work on a new programming language and execution environment in the 1990's. the end result was called Java. Java consists of a programming language withn many of the pitfalls of C++ removed, a portable intermediate byte code format, a runtime environment (called the virtual machine) that execute the byte code and handles issues such as memory management, and vast suite of libraries providing all the functionality required to develop enterprise class applications (such as networking, file handling, database access, graphics etc).

Java gained rapid acceptance and for a time Microsoft began their Java embrace and extend campaign. Sun were happy for Microsoft to embrace Java but reached for their lawyers when they realized that the extend part was a plan for Microsoft to introduce their own proprietary version of the language. Politics ensued and Microsoft eventually walked away from Java. Not long after, Microsoft started talking about something called .Net, following by something else called C#.

What exactly is C#?

"What does all this history have to do with C#?" I hear you ask. Well, the origins of the C# programming syntax can be traced right back to C and C++. If you are already familiar with C or C++ then you have a big head start in terms of learning C#. In fact the same can be said of syntax similarities between Java, C, C++ and C# syntax. In addition, C# also inherits many of the benefits of Java in terms of memory handling (better known as garbage collection) and an intermediate byte code that negates the need to recompile an application for each target hardware platform. C# is also accompanied by a vast framework of libraries designed to provide the programmer with ready made solutions to just about every imaginable scenario.

Despite these similarities there are differences between the Java and C# infrastructures work. The remainder of this chapter will be dedicated to providing and overview of the C# infrastructure.



The C Programming Language is of particular significance because the origins of C# can be traced all the way back it.