Home > Digital technologies > Development > C, C++ and C#... What are the differences between these programming languages?

C, C++ and C#... What are the differences between these programming languages?

Published on 27 May 2021
Share this page :

They often appear together at the top of the most popular languages rankings, and for good reason. Here's a quick look at the advantages (and disadvantages) of C, C++ and C#.

Difference between C C++ and C#

The C, C++ and C# programming languages have similarities that suggest a family relationship. And indeed, C was the precursor and was followed by C++ and C#, each bringing interesting developments albeit in different directions.

C, the language of performance

Invented in 1972 to accompany the creation of the UNIX system, the C language made its authors, Kernighan and Ritchie, a household name. It was first standardised under the name "ANSI C", then by ISO standards. One version followed another, and the programming language continued to evolve.

C gives the developer fine control over the machine and direct access to memory. When it was invented, it was a much more readable language than anything else available at the time. Today, it is considered to be a low-level language, but if it is used correctly, it can nevertheless be used to create a wide range of applications, writing high-performance programmes that are close to the hardware. It is used to write all the building blocks used in other technologies (starting, for example, with Java virtual machines).

Its syntax has been adopted by many successor languages. C uses a sequential approach. This means that instructions are executed in sequence. An entry point in the application is called "main". The code can be organised into functionswith input, input-output and feedback parameters. It therefore supports so-called "procedural" programming. Global variables are allowed.

Finally, C code very often manipulates allocated memory slots directly. This makes for very precise management... but requires a great deal of attention from the developer.

Its latest stable release is C17 from June 2018. The latest version preview is the C23 of April 2023.

C++, an object-oriented language

The C++ language was developed by Bjarne Stroustrup in 1979. Compatible with C, but designed as an object-oriented languageit can be used to implement higher-level abstractions than C.

C++ remains a multi-paradigm language: it allows imperative, object-oriented and functional programming. The template concept enables generic programming. The language is still strongly typed, and compilation can be fairly strict, but a large number of options are available, leaving the programmer largely in charge. The main pitfall of the language remains access to memory, via pointers, and the obligation on the developer to free all the resources he has allocated. Memory is allocated either on the stack or on the heap, at the developer's discretion.

Recent versions of the language and the standard library (from 2014 to 2020) have considerably improved the readability and reliability of the code.. In particular through the implementation of patterns (smart pointers) and the increased use of generic programming. Standardised since 1998 by the ISO, this language has undergone several evolutions, the most important of which is C++11. Its most immediate difference from C is the support for classes and object-oriented principles. C++ compilers are generally stricter than C compilers. Many developers have therefore used C++ just to encapsulate C libraries. Note that there is a managed C++ that is used exclusively on the .NET platform...

Its latest version is C++20 from December 2020.

C#, .NET and Microsoft

The C# language, pronounced "C sharp", was launched in 2002. It is intended to be the main language for Microsoft's .NET platform. It is largely based on Java syntax, while adding all the elements of IL, the intermediate language used by the virtual machine component (CLR) of the .NET architecture.

With this technology, developers have access to a very extensive standard library. Successive upgrades, up to and including C# 11 today, have kept pace with developments on the .NET platform. C# can therefore be used with all kinds of applications, from console applications to web applications. The link with C++ is obvious - as it is with Java. Its syntactic characteristics are therefore intermediate between Java (a strict and simple syntax) and C++ (a complexity linked to the direct use of memory, operator overloading).

C# offers a lot of syntactic sugar, i.e. simple syntax elements that generate relatively complex code. For example, the delegate, which is the implementation of an observer, but which is presented as a C function pointer, or the management of properties, which are nothing more than the getter and setter of C++. Generic programming was introduced in C#, offering the possibility of creating families of classes that adapt to types unknown at the time they were written.

The big difference with C++ is that it respects the constraints of the .NET architecture.. Its aim is to write trusted applications that are controlled by the CLR. In particular, because memory is managed by a garbage collector whose role is to keep memory available. Note the absence of variables and global functions in C#, which makes it a much more pure-object language than C++...

The latest version is C# 11 from November 2022.

In conclusion?

Knowing all this, it becomes easier to choose between these three programming languages. Opting for C is a guarantee of learning the basics, but perhaps in a rather rough way, because of its complexity. Beginners are welcome, as long as you stick with it!

With C++, on the other hand, object concepts and generic programming expand the possibilities, and the standard library, which has been greatly enhanced in recent years, makes life easier in certain cases.

Finally, with C#, the latest in the series, we have an advanced language that simplifies many aspects of application construction... Especially as it is based on the .NET framework. Now all you have to do is decide which of these languages is best suited to your project!

Our expert

Fabien BRISSONNEAU

Software and web development

As an architect, developer and trainer at Eixa6, he has been involved in many projects over the years, from desktop to [...].

associated domain

associated training