Comparative Comparison of C and C++
Comparative Comparison of C and C++
BY
(U21CS1031)
TABLE OF CONTENTS
TABLE OF CONTENTS................................................................................................................ 2
HISTORY...................................................................................................................................... 2
1.1 INTRODUCTION.....................................................................................................................3
1.1.0 PROGRAMMING LANGUAGES................................................................................3
1.1.1 DEFINITION OF PROGRAMMING LANGUAGES...................................................3
1.1.2 BRIEF HISTORY OF PROGRAMMING LANGUAGES............................................3
1.2 C................................................................................................................................................4
1.2.1 HISTORY OF C.............................................................................................................4
REFERENCE............................................................................................................................... 16
2
HISTORY
1.1 INTRODUCTION
about the history of programming languages, especially before the times of our
instructions, develop programs, and write scripts that direct the computer on how to
Though every programming language has a similar interface, which is to allow the
programmers to write instructions, every program has its own syntax, a set of rules
that guide the programmer on how to interact with the machine via this syntax.
According to (Sanjay K M. ( 2023)) The term Programming dates back to the early
19th century and even farther when mathematician Ada Lovelace created an
algorithm for Charles Babbage's Analytical Engine, which is considered the first
computer. However, the first actual programming language was developed in the
3
1950s, called FORTRAN (Formula Translation). This language was used for
ALGOL
1967, a new programming language came into force called ‘BCPL’, meaning Basic
1.2 C
1.2.1 HISTORY OF C
design from the ALGOL tradition, and before C, BCPL existed and was designed and
Thompson. It was known as ‘B’, which combined various features of ‘BCPL’. It was
created using the UNIX operating system at AT&T and Bell Laboratories. In 1972, C
was developed by Dennis Ritchie and Ken Thompson at the Bell Laboratories, created
from ‘ALGOL’, ‘BCPL’, and ‘B’. ‘C’ contains all these languages and much more,
making it unique from the other programming languages. The origin of C is closely
4
assembly language on a PDP-7 by Dennis Ritchie and Ken Thompson, incorporating
developing utilities for the new platform. Initially, he tried to write a Fortran
compiler, but soon gave it up as it wasn't giving the desired results. Instead, he created
a cut-down version of BCPL, which was still relatively new at the time. Thompson
modified the syntax to be less wordy, and similar to a simplified ALGOL known as
porting to new machines. However, few utilities were ultimately written in B because
it was too slow and could not take advantage of PDP-11 features such as byte
more powerful PDP-11. A significant addition was a character data type. He called
this New B (NB). Thompson started to use NB to write the Unix kernel, and his
richer types were added to the NB language: NB had arrays of int and char. Pointers,
the ability to generate pointers to other types, arrays of all types, and types to be
returned from functions were all also added. Arrays within expressions became
pointers. A new compiler was written, and the language was renamed C. Initially, ‘C’
was limited to UNIX OS, but it gradually spread worldwide, and many compilers
were released for cross-platform systems. But Just Like many things in the evolution
constraints, and that’s when C++ and many other languages come in.
5
1.3.1 HISTORY OF C++
According to (Frank van den Beuken. 2023) C++ was developed by a Danish
computer scientist Bjarne Stroustrup at AT&T Bell Labs in 1979, seven years after
the introduction of C. Its origin stemmed from Bjarne’s analysis of the UNIX kernel
he discovered that the implementation did not scale well, so eventually the simulator
was rewritten in BCPL. For his work at AT&T Bell Labs, Stroustrup decided to
Simula-like classes into regular C code that could be compiled with existing
compilers. The new language was initially called "C with Classes." From the start, the
objective was that the new language could be used for everything that C could be used
compilers already were available for many platforms, it inherited C's portability,
which to this day is one of its important quality attributes. Another objective of the
language was to provide better alternatives for unsafe features of C while maintaining
its efficiency and direct access to underlying hardware features. Because of that, it is
6
1.3.2 C with Classes provided:
Classes
Derived classes
Friend classes
Inline functions
Default arguments
At this point in C++ history, the language didn’t have a proper name. For some time,
it was called C84, but that was kind of confusing. Eventually, it was computer
scientist Rick Mascitti who suggested the name C++, which helped many aware of the
7
LANGUAGE DESIGN PRINCIPLES AND PARADIGMS
Earlier on, I stated that C followed a structure, which was that of ALGOL.
Programming language design involves defining the syntax, semantics, and other
features of a language, providing the rules and conventions necessary for software
its intended use, target audience, and design goals and constraints. These factors guide
the development and documentation of the language, ensuring it meets the needs of its
features, all of which play a crucial role in expressing complex ideas and algorithms
while ensuring ease of learning and usage. Syntax dictates the rules for naming
variables and functions, punctuation usage, and code organization, while semantics
8
govern the logic of the code and its interpretation by the computer, including
of detail, with mechanisms like data abstraction hiding implementation details and
control abstraction representing complex operations as single units. Data types define
the types of data usable in programs, determining their size, representation, and
allowable operations.
Effective error handling mechanisms detect, report, and handle errors and exceptions
9
2.2 Programming Paradigms
Before Delving into the The intended uses of C and C++ their objectives and
constraints, let’s talk about their Programming Paradigms and what paradigms mean.
paradigm consists of certain structures, features, and opinions about how common
Ever wondered why there seem to be a huge influx of Programming Languages in the
world? Well this is because their many Programming Paradigms that exist alongside
them, these paradigms have different structures, a way of solving problems and also
Note, Programming paradigms are not languages or tools that can be used to program,
no. They're like a set of ideals and guidelines that many people have agreed on,
And Programming languages aren't always tied to a specific paradigm. There are
languages that have been built with a certain paradigm in mind and have features that
facilitate that kind of programming more than others (Haskel and functional
But there are also "multi-paradigm" languages, meaning you can adapt your code to
fit a certain paradigm or another (JavaScript and Python are good examples).
10
Like earlier mentioned the list of Programming Paradigms are exhaustive, but having
C and C++ as our case study, we would only talk about the paradigms that are used in
them.
1. Imperative Programming:
Imperative programming consists of sets of detailed instructions that are given to the
statements that change the program's state, is the foundation of both C and C++.
2. Procedural Programming:
3. Object-Oriented Programming
(OOP). The core concept of OOP is to separate different use cases of a particular
behaviour into entities which are coded as objects. Each entity will group a given set
of information (properties) and actions (methods) that can be performed by the entity.
OOP makes heavy usage of classes (which are a way of creating new objects starting
out from a blueprint or boilerplate that the programmer sets). Objects that are created
from a class are called instances. C++ is a multi-paradigm language that fully
11
supports object-oriented programming, while C can emulate some OOP concepts with
struct and function pointers. In OOP, programs are structured as collections of objects
that interact with each other. Key OOP concepts include abstraction, encapsulation,
So what is the intended use of C? and what were it’s constraints which prompted
uses and the Constraints around them that lead to developers seeking better options.
To analyse what C++ came to solve that at the time of it’s creation C could not solve.
Looking at our introduction to C++ and it’s history, it was clear that Despite Simula
not being as capable as C, C definitely had it’s Limitations, which led to the extension
Though C is still very much in use today in many industries and not just limited to
technology and computer science, so first of, let’s look at what makes C a force to be
reckoned with.
languages.
C is a very efficient language that can write code that is both fast and reliable.
12
C is a well-established language with a large and active community of developers
C program syntax is easy to learn and read; this makes debugging code more
C programs are relatively short compared to other languages, which reduces the
C has been around for many years (it was first released in 1979), so many
Creating Other Languages, for performing high computational Tasks like making
Limitations of C
extensively.
The process of debugging is difficult. And doesn’t provide strict data type
checking. (i.e. integer data type can be passed for floating datatype)
It uses ASCII character set which is only able to support 256 characters because it
It is unable to support some languages like Chinese, Japanese that have more than
256 characters.
13
It doesn’t provide binding or wrapping up of data as a single unit.
C++ has many features that are not directly available in C, allowing developers to
write more expressive, efficient, and maintainable code. Here are some things you can
allow for better code organization, abstraction, and reusability, making it easier to
3. Standard Template Library (STL): C++ includes the STL, a powerful library of
generic algorithms and data structures such as vectors, lists, maps, and algorithms like
sorting and searching. The STL provides high-level abstractions and reusable
write robust and reliable code that can gracefully handle errors and exceptional
14
conditions. Exceptions provide a structured mechanism for propagating and handling
5. Function and Operator Overloading: C++ allows for function and operator
to organize code into logical groups and avoid naming conflicts. Namespaces help
naming structure.
7. Inline Functions: C++ supports inline functions, which are expanded inline at the
point of invocation rather than being called through a function call mechanism. Inline
functions can improve performance by reducing function call overhead and enabling
compiler optimizations.
Overall, C++ offers a rich set of features and libraries that enable developers to write
programming paradigms.
Though simply put even witheir differences in syntax, libraries and more, there is
15
REFERENCE
Frank van den Beuken. (2023, Nov 29). A Brief History of C++.
https://www.perforce.com/blog/qac/misra-cpp-history#:~:text=C%2B%2B%20was
%20invented%20by%20Danish,was%20working%20on%20his%20Ph.
https://www.upgrad.com/tutorials/software-engineering/c-tutorial/history-of-c-
language/
https://pwskills.com/blog/difference-between-c-and-c/
languages-past-present-future-mohindroo-/
https://bootcamp.uxdesign.cc/programming-language-design-
a649513dbcf7#:~:text=Programming%20language%20design%20is%20the,software
%20in%20a%20specific%20language.
Germán Cocca. (2022, May 2). Programming Paradigms – Paradigm Examples for
Beginners.
16
https://www.freecodecamp.org/news/an-introduction-to-programming-paradigms/
.https://tutorials.freshersnow.com/cprogramming/c-features-limitations/
#:~:text=Limitations%20of%20C%20Language,usability%20of%20source%20code
%20extensively.&text=It%20uses%20ASCII%20character%20set,byte%20to
%20represent%20a%20character.
Ravikiran A S. (2023, May 17). Use of C Language: Everything You Need to Know
https://www.simplilearn.com/tutorials/c-tutorial/use-of-c-language#:~:text=The%20C
%20programming%20language%20was%20created%20with%20the%20intention
%20of,development%20of%20multiple%20operating%20systems.
https://www.simplilearn.com/tutorials/cpp-tutorial/top-uses-of-c-plus-plus-
programming
https://codeinstitute.net/global/blog/what-is-a-programming-language/
17