After several decades of programming in C , I switched to C# and am now firmly in love with the language. A person’s favorite programming language is, of course, a very personal thing. It’s a tool that one uses many hours a day over long periods of time. It has to be comfortable and easy to use. But it must also give you the programming tool you need to create your intended functionality.
My journey started with the C programming language. It was so simple and elegant and “close to the metal”. But it wasn’t object-oriented, and for larger projects I needed the features of an object-oriented language that would allow me to encapsulate and decrease the complexity of my code. As a result, I moved to C . I loved its object-oriented features, and that it maintained the C syntax and semantics. But C also added a lot of complexity, including such things as multiple inheritance and operator overloading. Still, it was fun to learn all the details of its ins and outs.
A person’s favorite programming language is, of course, a very personal thing. It’s a tool that one uses many hours a day over long periods of time. It has to be comfortable and easy to use.
Clearly, we already had C , which was a C-like object-oriented language, and C had been in heavy use for over a decade. But the new language would be different is several ways. Unlike C , the language would compile to intermediate code, like Java, and the final translation would be done by a run-time interpreter, again like Java. Additionally, it would interface with Microsoft’s newly developed Common Language Infrastructure (CLI) platform and class libraries.
Like C , the new language was strongly typed and, with minor exceptions, the syntax and semantics were almost identical to those of C . This similarity would make it easy for C programmers to switch to the new language. But the language itself was also simplified, making the language easier to learn for new programmers.
One way in which the new language was easier to use was that memory management was performed automatically, freeing up the programmer from having to deal with memory management aspects of the code. A related simplification was that the feature of explicit pointers was excluded from the language, thus avoiding one of the major stumbling blocks of C . Newcomers to C are often stumped by pointers, and even for seasoned C programmers they can sometimes be a source of frustratingly hard to find bugs—so removing explicit pointers was a huge thing.
Another major difference between C and C# was the target platform. C is compiled to machine code and C compilers have been created for every major operating system and platform. C#, however, was designed to work with the CLI platform, which had been specific to Windows and has, until several years ago mainly been limited to programming for the Windows platform. (More about this below.)
Version 1.0 of the language was released in 2002 along with the .NET Framework 1.0 in Visual Studio .NET 2002. It was pretty basic compared to today’s version of the language. It looked like a light-weight version of C and was very similar in features to Java,but it was elegant in its simplicity. Version 2.0 of the language was released in 2005, and significantly beefed up the features of the language. Among these features were generics (this was huge), anonymous methods, iterators, nullable types and others.
Over the years the language became a complete tool box for the programmer. The most important features were Language Integrated Query (LINQ) and native support for asynchronous programming. The first of these, LINQ, allows the programmer to specify searches in a declarative format that is very much like SQL. This is an extremely powerful feature, and is a declarative island in an imperative language. The second feature is the native support for asynchronous programming. This allows the programmer to specify their asynchronous code in-line, in a very natural manner, rather than requiring callback code that is separated out into another method, as had been required earlier.
As C# continued to become more popular, a community of Linux programmers began to want to use C# on platforms other than just Windows. The Mono platform was developed to meet the need for a cross-platform version of C# and the .NET platform. This met with some success, but eventually the engineers that created Mono formed Xamarin, a company that extended Mono to concentrate on building a framework that allowed programmers to use C# to produce a common code base for their programs targeting Windows, Android and macOS. In 2016, Microsoft bought Xamarin, ensuring the continued success of C# in cross-platform development.
C# is powerful and flying high. Although the popularity of programming languages is always in flux, C# has remained in the top 5 favorite languages for a number of years. It is a clean and elegant all-purpose programming language that can be used to build desktop applications, mobile apps and web pages. It continues to offer the programmer more features and allows coding for multiple platforms. By all indications it will only keep getting better.