C / C++
Last Updated: 2022-02-08
C vs C++
C and C++ are related but 2 different languages.
Read more: C vs C++
Style Guide
Google C++ Style Guide: https://google.github.io/styleguide/cppguide.html
Compilers and Build tools
- Compilers: Clang (preferred) and GCC
- Build tools: no standard, CMake is probably the most popular; Gradle also supports C++; Google open sourced Bazel.
File Extensions
- header files:
.h
,.hpp
- source files:
.c
,.cpp
,.cc
It does not matter which file extension to use.
Include
If a source file c.cc
includes a header b.h
, which includes a.h
, c.cc
can use all symbols declared in a.h
Standard Template Library (STL) vs Standard Library
The original STL was developed separately, and was proposed to be included in C++ standard. Only part of it actually went into the standard, some parts were rejected while others were redesigned. That is why wikipedia says it "influenced many parts of the C++ Standard Library". You will not find the term "STL" in the standard, instead usually STL refers to container library, iterator library and algorithm
IDE
- VS Code (free, code editor)
- CLion (not free, full featured IDE)
- Xcode (on macOS)
Where is C / C++ being used
- OS: Linux is implemented in C (but NOT C++)
- other languages: CPython is written in C; OpenJDK is using C++
- Web Browser: V8, the JS engine is in C++, used by node and Chrome
- graphics and games: Vulkan, which replaces OpenGL, is written in C; Unreal Engine is written in C++; Unity's runtime is in C++ (though programmers write C# on top of Unity)
- servers: many companies, including Google and Facebook, use C++ extensively to build their servers.
- databases: the most popular databases are often using C/C++: MySQL, Postgres, Redis, MongoDB
Links
Libraries:
- Boost (https://www.boost.org/)
- Google: abseil (https://github.com/abseil/)
- Facebook: folly (https://github.com/facebook/folly)
Others:
- Tips: https://abseil.io/tips/
- https://isocpp.org/
- isocpp annual survey: some interesting stats.
- https://cppinsights.io/