What is C#?

DevToolsGuy / Tuesday, May 20, 2014

What is C#?

C# is an object oriented programming language developed in 2000 by Anders Hejlsberg at Microsoft. Anders has an impeccable heritage in this area, having previously worked on both Turbo Pascal and Delphi. Since creating C#, Anders has moved onto the development of TypeScript, a Microsoft project to create an enhanced version of JavaScript.


The C# language was designed to be platform independent and borrows its syntax heavily from both Java and C++. Indeed one of Anders original design goals was to create a language to address what he saw as many of the flaws in these older languages.


In 2000 O'Reilly editor John Osborn conducted an interview with Anders, in which he discussed the inspirations behind C#:

“We tried to stay much closer to C++ in our design [for C#]. C# borrows most of its operators, keywords, and statements directly from C++. We have also kept a number of language features that Java dropped, like enums.”


C# was developed for use within Microsoft's .NET development framework, which comprises a large library of prebuilt code classes (for things like data access, data connectivity, and network communications) and a software environment called the ‘Common Language Runtime’ (CLR). The CLR is a ‘just in time’ compiler, meaning it converts C# code into suitable machine code as it runs.


The framework actually supports a wide range of languages, including C++ and even Visual Basic, but C# has seen particularly wide use. As you might expect .NET is primarily designed for the Windows platform, although an open source project called Mono provides a runtime and development framework for Linux and Mac operating systems. As a result of .NET, C# is seen as a particularly strong language with which to develop Windows desktop applications.


The ECMA, which approved version 2.0 of C# (the current version is 5.0) as a standard independent of Microsoft, have stated seven key design goals for the language. These include but are not limited to the following:

  • C# is intended to be simple, modern, general purpose, and object-oriented
  • C# should support strong type checking, array bounds checking, and automatic garbage collection
  • C# is not intended to compete with C or assembly language for size (of compiled programs) or performance.


Advantages of C#

As Anders has publicly stated, C# tries to build on much that is good about the C++ and Java languages. C++ has been around since 1983, and is considered by many to be a fairly complex language to master, especially for those starting out in programming. It lacks many of the memory management features of modern languages, like automatic garbage collection (something both Java and C# support) which can make writing very efficient code difficult. C# does feature automatic garbage collection, meaning developers have more time to focus on solving problems with their code rather than implementing good memory management techniques. C# is also strongly typed, meaning it is somewhat easier for developers to adhere to coding best practice, and to find and eliminate bugs.


The dominance of C# on the Windows platform has seen a large and very active community build up around it, and this in turn has helped to foster numerous help and support resources. A quick search of the web will surface a wealth of well implemented, freely available code libraries and samples.


Areas for Improvement

At launch many felt C# was simply a Microsoft version of Java, developed to avoid explicitly licensing a third party product, but over time the two languages have diverged, and C# has found its own feet. It has moved away from its original platform independence, and become a core tool of the .NET framework.


The ‘just in time’ nature of its compiler has lead some developers to question its performance, when compared to other languages. Whilst there is some truth to this (ECMA themselves have stated C# isn’t a performance rival to the likes of C or pure machine code) it is not something that affects 99.99% of well written code running on modern hardware. Indeed the wide variety of code libraries available as part of the .NET framework means that many familiar problems already have efficient and fully tested solutions available.


The Future of C#

In April 2014, at its BUILD developer conference, Microsoft formally announced it was releasing the .NET C# compiler ‘Roslyn’ as an open source product. This was a big step for Microsoft, who had previously developed the .NET framework as proprietary technology. Roslyn is part of a larger initiative called the ‘.NET Foundation’ which aims to open source much more of .NET over time. Whilst it is early days for these initiatives, they are a positive move towards greater cross platform support for .NET, and the wider use of C# on non Windows devices (like smartphones and tablets).


Infragistics offers a number of development tools that make it even easier to write high quality C# code and applications. Find out more here.