C vs. C++: The differences

  • By reComparison Contributor
  • comments 0
  • views6651

Difference between C and C++

Both C and C++ are general purpose computer programming languages. C was developed in 1972 by Dennis Ritchie. C++ is an extension of C and was initially called C with classes. It was developed in 1979 at Bell Labs. Both of these languages are extremely popular among software developers and are used to build not only system software but also portable application software. C++ was basically developed to introduce the object oriented approach in a language with syntax similar to that of C. Besides, various concepts like multiple inheritance, virtual functions, operator overloading and exception handling were also introduced in C++. Major differences between these two most basic programming languages are discussed below...

C
C++

Execution speed

It has been observed that C programs are executed faster than those written in C++. But C being faster in math or printing doesn't make it better than C++. A large number of functionalities added into C++ make it far easier for a programmer to build software using it, hence increasing the net speed. Classes, inheritance, virtual functions and many more, make programming in C++ much more efficient. By introducing object oriented techniques through classes in C++, a large program can get rid of redundant code resulting in much simple and precise program.

Design                 

C is a procedural systems implementation language. It can provide low level access to memory using constructs inbuilt in the language which map to the machine instructions. Programs written in C require almost no run time support. C++ on the other hand is a multi-paradigm programming language. Programmer working in C++ can change his style of programming in the best way that meets his requirements. These styles could be procedural programming, object oriented, abstraction or generic programming. As far as platform independence is concerned both the languages are designed to support machine independent programming.  

Memory

Management

There are three ways of allocating memory to variables in C viz. Static, automatic, and dynamic memory allocation. Stack is used in automatic allocation where as heap in case of dynamic. In the latter approach allocation is done using keyword malloc and freed using free. In case of C++, these tasks are done using new and deletekeywords. Garbage collection although was desirable is not built-in in C++ but can be achieved by using smart pointer classes or some external libraries.

Summary

C

  • Was developed in 1972 by Dennis Ritchie.
  • C programs are executed faster than those written in C++.
  • It’s a procedural systems implementation language.
  • Designed to support machine independent programming.
  • Static, automatic, and dynamic are the three ways of allocating memory.

C++

  • It was developed in 1979 at Bell labs by Bjarne Stroustrup.
  • Object oriented programming, multiple inheritance, virtual functions, operator overloading, exception handling are some new features that were introduced in C++.
  • It’s multi-paradigm programming language.
  • New and deletekeywords are used for dynamic memory allocation.
  • Garbage collection can be achieved by using smart pointer classes or some external libraries.
  • C++ is used to build system software, device drivers, embedded software and a large number of computer applications.

Which one has better performance?
  • C
  • C++
 
 

Discuss It: comments

Post a Comment
  • Name*
  • Email*
  • Website (optional)
  • arrow You are commenting as a Guest
  • arrow Your email will not be public
  • arrow Login or Sign Up and post using your reComparison account
  • arrow Facebook Connect