Published in · 3 min read · Jul 21, 2016
--
3 minute cheat-sheet for every beginner out there
Many people claim that C++ is better than C and many the other way round. However, the general belief is that it is good to switch to C++ after having a bit of experience of C, you can continue to code in more or less in C with C++ features.
So, the dilemma persists, choosing between the two. Despite C is the predecessor, here is list of few important advantages of C over C++:
- Due to the absence of Object Oriented Paradigm, there are no operator overloading and function overloading problems in C.
- Static initialization is safe in C but not in C++. Also, Static variables in C need to be initialized with a value known at compile time. This requirement has been removed in C++, and you can initialize them with expressions evaluated at run-time.
- C is by far the most acceptable language for Kernel Programming and drivers development.
- C is friendlier towards powerful command line debuggers such as GDB and DBX.
DBX — DBX is a tool for source-level debugging and execution of programs. It allows you to determine the exact statement that caused a core dump, or to monitor the exact statements that the program is executing currently ( Please find further details here ).
GDB — GDB is a free software software released under the GNU General Public License (GPL). It was modeled after the DBX debugger, which came with Berkeley Unix distributions.( Please find further details here )
5. C supports variable sized arrays on the stack. Which facilitates much faster allocation than on the heap (C99 feature).
IDE — It is a software application that provides lots of facilities to computer programmers for software development. It mainly provides editor, debugger and build automation tool.
6. C requires less runtime support making it more suitable for low-level environments such as embedded systems or OS components.
7. C has a stable ABI (Application Binary Interface) increasing compatibility between different compilers.
8. C is somewhat more efficient than C++ since it doesn’t need for Virtual Method Table (VMT) lookups.
VMT — It is a mechanism used in programming languages to support dynamic dispatch (or Runtime Method Binding).
C has a better community support as an extension language for other high level programming languages (Perl, Python, Ruby, Node.js, Common Lisp etc.). It is observed that for kernel programming C is best language and is also preferable for open source. It gives you better control over what happens when your code is executed. Device driver programs are exclusively written in C when anyone requires to very closely interact with the hardware devices. Major parts of popular operating systems like Windows,UNIX, Linux are still written in C.
- C is somewhat better than C++ in speed and efficiency.
- It is easier to code and debug in C than C++.
- C is default choice for source level programming, like kernel programming, driver development etc.
- Various debuggers, DBX and GDB.
Please Follow “The Bit Theories” for constant updates.