You’ve probably heard of the C programming language. C has been around a long time, being released in 1972. There’s likely some software on your computer written in C. Maybe even the whole operating system.
Then there’s C++, but how does it differ from C? And the confusion doesn’t stop there. There’s also C# and Objective-C. Each of these programming languages is different, but they’re all related. C was the first of these languages, and the rest either extend from it or are based on it.
Below, we’ll take a closer look at the differences between these languages and how to learn more about them.
The need for different programming languages
Why would someone go through the trouble of creating a new programming language based on another one instead of using the original?
First, it makes the new language accessible to the existing language’s user base. Second, it saves developers time since the existing language’s core features don’t need to be recreated from scratch.
Third, technology moves fast. Modern computers have more processing power and RAM than those from a decade ago. As hardware changes, programming languages have to be updated to keep up with technology.
Programming language developers also have new ideas about how the language should function. They believe these changes will improve performance and make the development experience easier — and they’re often right. After all, we once had to write computer programs with punch cards.
Below are some general differences between programming languages that led developers to create alternative versions of C.
Procedural vs. object-oriented
Most programming languages in the earlier days used a procedural programming paradigm. In procedural programming languages — which first appeared in 1957 and included the FORTRAN, ALGOL, COBOL, and BASIC languages — the program’s functions contained a set of steps that were executed in a specific order. Functions can be reused and can also call other functions or even themselves. C is also a procedural programming language.
Another programming paradigm is object-oriented programming which is based on two data structures: objects and classes. In object-oriented languages, you can create a `class` structure that represents a real-world object with variables and methods attached to it. This structure can be used repeatedly to create copies of itself.
For example, your program could have a `User` class that contains data like the user’s first name, last name, and email. It could also have methods like one to email a user. If you create a new user in your program using this class, the new user object will have all the data variables and methods it needs already built-in. C++, Objective-C, and C# code can all be written in a procedural and/or object-oriented programming style.
Software portability refers to a program’s ability to be compiled and run on different platforms. Take Google Chrome as an example. While you can’t run the Windows version of Chrome on a Mac computer and vice versa, all versions of the final executable program are compiled from the same codebase. This is called source code portability.
You can compile the code to run on different operating systems using a compiler for that operating system. For example, C and C++ have source code portability. But there’s also another type of portability called application portability. Portable applications can be moved between environments and run on any.
Java applications are portable in this way, thanks to the Java Virtual Machine (JVM), which is like an in-memory virtual computer that Java applications run in. This way, you can run the same Java application on Windows, Mac, or Linux as long as the environment has a JVM installed for that specific operating system.
C# uses the application portability concept like Java, but instead of a JVM, it has a .NET common language runtime.
Syntax and language features
Programming languages have different syntax and features. The syntax is the set of rules that define the combination of symbols you have to use to define the code you’re writing. For example, functions in C are surrounded by brackets, but functions in Python are defined using indentation.
The languages in this article all use the C programming language syntax, except for Objective-C. Objective-C uses the same syntax as C for all of its non-object-oriented functionality. But for objects, it uses a syntax like another programming language called Smalltalk.
The features of a language can apply to a lot of things. A major feature difference in the C family of languages lies in how they execute the code referenced by a method. In all of these languages except Objective-C, the method being called is bound to the section of the class where it’s located when the code is compiled. In Objective-C, a message is sent to the class at run-time and is resolved while the application is running.
So in Objective-C, the called method has complete control over how to handle the action. But in the other C languages, it’s hard-coded when the application is compiled.
What is the C programming language?
C is a general-purpose, procedural programming language that was first developed by Dennis Ritchie in 1972. Ritchie created this new programming language based on existing programming languages: ALGOL, BCP, and B. He took features that worked in those languages and combined them to create C.
Up to that point, all operating systems were created in a programming language called Assembly, which is the lowest-level language you can write to interact with the hardware in a computer. Low-level languages are more complex and typically involve using many more symbols than the programming languages you’re familiar with. But, because of C’s power and flexibility, version 4 of Linux became the first operating system written in a programming language other than Assembly.
C quickly grew popular because, compared to the other programming languages that existed at the time, it was a lot easier to read, understand, and code. C gave programmers all the performance that comes with manipulating hardware at a low level, along with the ability to do so in a readable syntax.
The other programming languages in this article have replaced C in many places, but it’s still widely used by developers who’d rather not deal with the complexity and multiple subsets of the C++ programming language. The team that develops the kernel of the Linux operating system still only uses C, which allows control over the hardware.
What is the C++ programming language?
C++ is a general-purpose programming language created by Bjarne Stroustrup in 1985 to extend the C language. It has all of C’s low-level memory manipulation features but added the object-oriented programming paradigm.
While the other members of the C family have replaced C in some applications, C++ is the most common replacement for C. In fact, it’s a direct replacement in most cases.
C++ is used where performance is at a premium and low-level control over the system’s resources is needed. It’s commonly used to develop operating systems, video games, database software, web browsers, and embedded systems.
Probably the highest concentration of C++ developers work in the game development industry, where the language’s control over computer GPUs is unmatched, allowing for the life-like 3D graphics we see in modern video games. It’s also a popular language for IoT devices where code interacts directly with custom hardware.
What is the Objective-C programming language?
Objective-C is a programming language that was developed in 1984 by Brad Cox and Tom Love. They saw the need to add the object-oriented paradigm to the C programming language but used the Smalltalk language as their guide.
This led to one of the major differences between this member of the C family and the others in this article. Most of the syntax in Objective-C is similar — except when it comes to creating or handling objects.
The rights to Objective-C were acquired by a company called NeXT, which used it in a custom programming platform called OpenStep. In 1996, Apple acquired NeXT and used OpenStep in its new operating system, Mac OSX.
Most of Apple’s current Cocoa API is based on OpenStep, and Apple’s Xcode is based on NeXT’s Objective-C development tool. Objective-C quickly became the programming language for Apple products, and for the most part, exclusive to Apple products.
By 2014, when Swift was released, Objective-C was mostly unchanged over the previous 40 years, and there had been a lot of advancements in programming language development. Swift is interoperable with Objective-C (which means it can run alongside it in the same application), and it’s much faster and easier to write. Apple eventually suggested that developers use Swift rather than Objective-C, which has been in a slow decline ever since.
What is the C# programming language?
C#, like all the other children of the C programming language in this article, is an object-oriented, general-purpose language. Microsoft released C# in 2000, adopting features from Java along with C. Instead of being compiled to run on a specific operating system, C# was compiled to run using the .NET common language runtime, much like Java was compiled to run on the JVM. For more of the differences C# implemented, check out C# vs. C++.
Initially, C# was a closed-source programming language designed to run on Windows. It was used to develop desktop applications for the Windows operating system and server-side applications for Windows servers. It’s also the most popular language used in ASP.NET development.
But in 2014, Microsoft released C# as free and open-source and offered builds for both Linux and Mac OSX. It’s since found use in game development and web service development, making C# a widely used language on all popular operating systems.
Now you can tell the differences between the programming languages in the C family. It’s a pretty diverse family, but all these languages owe their existence to C.
C is still a popular language, especially with embedded systems and places where object-oriented programming isn’t needed. Try our Learn C course if you’re interested in learning the basics of the language.
Still, most developers opt to use C++ instead because of its additional features. To learn both, you only really need to learn C++ because it’s a superset of C. Supersets are programming languages that contain all the features of another language — and then some.
To get started with this popular high-performance programming language, check out Learn C++. Or, if you’re already familiar with the language, then our intermediate course, C++ for Programmers, will take your skills to the next level.
Since Swift has mostly replaced Objective-C — even Apple recommends using it — we suggest taking our Learn Swift course if you plan on writing code for Apple products. If you want to use a higher-level programming language than C++ and plan on creating Windows desktop applications, video games, mobile apps, or web services, then C# is an excellent choice. Our Learn C# course will teach you the fundamentals of C# and how to build applications.