Versus
    32-bit vs 64-bit
    Annotations vs Decorators
    BigQuery vs Bigtable
    Block Storage vs File Storage vs Object Storage
    C vs C++
    Canvas vs SVG
    Constructor vs Init() vs Factory
    Containers vs Virtual Machines (VMs)
    DOM vs Virtual DOM vs Shadow DOM
    DQL vs DDL vs DCL vs DML
    Dagger vs Guice
    Data Mining vs Machine Learning vs Artificial Intelligence vs Data Science
    Flux vs Redux
    GCP API Gateway vs Cloud Endpoint
    GCP Cloud Run vs Cloud Functions vs App Engine
    GCP DataFlow vs Dataproc
    Google Analytics 4 vs Universal Analytics
    Google Internal vs Open Source
    HEIC vs HEIF vs HEVC vs JPEG
    Java vs C++
    Jetty vs Netty
    Kotlin vs Java
    LLVM vs JVM
    Linux vs BSD
    Microcontroller vs Microprocessor vs Computer
    Node.js vs Erlang
    POSIX vs SUS vs LSB
    Pass-by-value vs Pass-by-reference
    Proto2 vs Proto3
    PubSub vs Message Queue
    REST vs SOAP
    React vs Flutter vs Angular
    Rust vs C++
    SLI vs SLO vs SLA
    SRAM vs DRAM
    SSD vs HDD
    Software Engineer vs Site Reliability Engineer
    Spanner vs Bigtable
    Stack based VM vs Register based VM
    Stateless vs Stateful
    Static Site Generation vs Server-side Rendering vs Client-side Rendering
    Strong Consistency vs Eventual Consistency
    Subroutines vs Coroutines vs Generators
    Symlinks vs Hard Links
    TCP vs UDP
    Tensorflow vs PyTorch
    Terminal vs Shell
    Vi vs Vim vs gVim vs Neovim
    WAL vs rollback journal
    gtag vs Tag Manager
    stubs vs mocks vs fakes

C vs C++

Updated: 2022-03-20

C++ is NOT a superset of C

C++ began as a fork of an early, pre-standardized C.

Incompatibilities can be found in the wiki page: https://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B

Release Cycles

  • C++: every 3 years (C++98, C++03, C++11, C++14, C++17, C++20, C++23)
  • C: updated much slower than C++ (C99, C11, C17, C23)

Procedural vs Object-oriented

  • C++ is object-oriented.
  • C is procedural.

C headers vs C++ headers

  • C Header: with .h suffix, e.g. <time.h>
  • C++ Header: with c prefix, e.g. <ctime>

Differences:

  • C does not have namespace. C headers will go into the global namespace, C++ style headers will go into std namespace
  • C headers don't have overloaded functions, e.g. C++ header <cmath> has overloaded sqrt functions for int and for float, but <math.h> only has one .

Some C headers do not have C++ version, e.g. <stdatomic.h>.

Takeaway: C++ program should avoid any C-Style headers <xxxx.h> if possible. (e.g. use cstdio instead of stdio.h):

#include <cstdio>

int main() {
  std::printf("Hello World\n");
}

Overloading / Overriding

  • C++ supports both
  • C does not support either

Memory Management

  • C++ new/delete and smart pointers
  • C: calloc() / malloc() and free()

Read more: C / C++ Memory Management

Security

  • C++ supports encapsulation.
  • In C, data can be accessible by other entities.

Type cast / conversion

  • C-style cast: conversion (int)3.5; cast (int)"hello"
  • C++-style cast: static_cast, etc.

Strings

  • C-style string: char*
  • C++-style string: std::string and std::string_view (since C++17)

Build tools

Both can use Clang and GCC.

They have different standard libraries:

  • C: libc. Implementations: glibc (GNU C Library), musl(a lightweight implementation for Linux)
  • C++: libc++ in Clang, libstdc++ in GCC.

reference variable

  • C++ supports the reference variable
  • C doesn't support the reference variable

Functions in Structure

  • C doesn't allow functions in structure
  • C++ allows functions in structure

Use Cases

C++ is more popular with applications level programming. C is more popular in low level systems programming.

  • C is used in
    • operating systems, e.g. Linux Kernel (C++ is not allowed in Linux Kernel)
    • embedded systems.
    • compilers, libraries, interpreters of other languages: CPython (https://github.com/python/cpython)
    • graphics: Vulkan, OpenGL.
    • databases: PostgreSQL, Redis.
  • C++
    • compilers, libraries, interpreters of other languages: OpenJDK, V8
    • game engines: Unity, Unreal Engine.
    • databases: MongoDB, sqlite3
    • server-side programming (used by many companies, like Google, Facebook, etc).
  • many projects use both, e.g. Chrome, MySQL, etc.

Linus Torvalds’ views on C++

C++ is a horrible language. It’s made more horrible by the fact that a lot of substandard programmers use it, to the point where it’s much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do nothing but keep the C++ programmers out, that in itself would be a huge reason to use C.