Interesting Facts about C++.

  • C++ is an object-oriented language.
No. C++ is a multi-paradigm programming language. C++ supports OOP, procedural programming, generic programming, template meta programming and functional programming. It is one of the biggest strengths of C++ that it is a multi-paradigm programming language. Programmers should be free to pick their own programming style, and that style should be fully supported by C++. Why should I define a class just to print “Hello world”?

This quote by Bjarne Stroustrup really makes sense.

    “Certainly not every good program is object-oriented, and not every object-oriented program is good.” 

image source: Wikipedia 

  • C++ is just an extension to C and is a super set of C.
C & C++ both are different programming languages having different rules and standardized by different committees. C & C++ both have diverged since C99. There are many features of C99 and C11 which aren’t officially part of C++ language but some compilers like g++ and clang++ support them as compiler extensions. C++ is not 100% backwards compatible with C. There are many programs valid in C but invalid in C++.

  • Memory management in C++ is error-prone and memory leaks are an annoying issue because C++ lacks garbage collection.
This is an absolutely wrong misconception that mostly Java & C# programmers have about C++. Garbage collection breaks one of the primary design philosophy of C++: "you don't pay for something you don't use." That means if you don't need garbage collection the C++ run-time system should not waste its time cleaning up the whole garbage. C++ programmers must avoid using new/new[]and delete/delete[] most of the time. If you need dynamic array use std::vector. If you need a string then use std::string instead of plain C style char[]/char*.

Bjarne Stroustrup says that:

  Memory is not the only resource. A resource is anything that has to be acquired and (explicitly or implicitly) released after use. Examples are memory, locks, sockets, file handles, and thread handles. A good resource management system handles all kinds of resources. If the release does not happen, we have a leak, and since there is a finite amount of each kind of resource, eventually the system grinds to a halt. You don’t need an actual leak to cause bad effects; excessive resource retention can be almost as bad. For example, if a system holds on to the memory, locks, files, etc., for twice as long, the system needs to be provisioned with potentially twice as many resources.

  • C++ is an outdated and useless language.
C++ is old fashioned language and there is the demand of modern languages like Java, C#, Python etc in the software industry. Right? No, extremely wrong.
C++ is everywhere from the bottom of the ocean to the surface of Mars planet.

C++ is a continuously evolving language since C++11. There is C++14 standard and recent C++ standard is C++17. C++11 feels like a new language as said by Bjarne Stroustrup. C++ standard committee is extremely busy for the next C++ standard which is C++20.

THANK YOU FOR READING.
! HAPPY LEARNING !


Comments

Popular posts from this blog

Happy holi in coding style

How to Start programming.