A quick guide for developers coming from JavaScript, Python, C#, Java, and web development.
Developers coming from JavaScript often think of a project as a collection of source files plus a runtime such as Node.js or a browser. Python developers think in terms of scripts, packages, and modules. C# developers are used to Visual Studio projects and solutions.
A modern C++ project is much more than a collection of .cpp
files. It includes source code, headers, build scripts, dependencies,
tests, documentation, and generated build artifacts.
Unlike interpreted languages, C++ must transform source code into native machine code before it can run. This introduces several additional concepts that every C++ developer must understand.
MyProject/
│
├── src/
│ ├── main.cpp
│ ├── Engine.cpp
│ └── Renderer.cpp
│
├── include/
│ ├── Engine.hpp
│ └── Renderer.hpp
│
├── tests/
│
├── docs/
│
├── third_party/
│
├── build/
│
└── CMakeLists.txt
Unlike JavaScript projects where most files are directly executed or bundled, many directories in a C++ project exist solely to support the compilation process.
A JavaScript developer thinks in terms of source files and a runtime.
A C++ developer must think in terms of:
The complexity exists because C++ provides direct access to native machine code, offering maximum performance and control.
One of the biggest differences from JavaScript is the separation between declarations and implementations.
// Engine.hpp
class Engine
{
public:
void Start();
};
// Engine.cpp
#include "Engine.hpp"
void Engine::Start()
{
// implementation
}
Think of headers as contracts. They describe what exists. Source files provide the actual implementation.
Every source file is compiled independently.
Before compilation, the preprocessor expands all included headers, producing a translation unit.
The compiler never sees individual files. It only sees the final translation unit after preprocessing.
Building a C++ application involves several stages.
The preprocessor handles directives such as:
#include
#define
#ifdef
#ifndef
Included header files are literally copied into the source code.
g++ -c main.cpp
g++ -c Engine.cpp
g++ -c Renderer.cpp
Each source file becomes an object file.
main.o
Engine.o
Renderer.o
g++ main.o Engine.o Renderer.o -o MyApplication
The linker combines all object files into the final executable.
Object files contain compiled machine code but are not yet runnable.
The linker's job is to resolve those references.
.lib (Windows)
.a (Linux)
Linked directly into the executable.
.dll (Windows)
.so (Linux)
.dylib (macOS)
Loaded when the application starts.
Real-world C++ projects rarely invoke compilers directly.
Build systems automate compilation, linking, dependency management, testing, packaging, and deployment.
cmake -B build
cmake --build build
Today, CMake is considered the industry standard.
This is one reason large C++ projects can have long build times.
| JavaScript | C++ |
|---|---|
| Runtime Execution | Native Compilation |
| Modules | Headers + Translation Units |
| npm Packages | Libraries |
| Bundler | Compiler + Linker |
| Node.js / Browser | Native Executable |