Code Story

Code Story: Dev Tools

VS Code, CMake, MSBuild, Clang, dotnet CLI, Python

1.0  Development Tools

Every project in Code Story uses a consistent toolchain. This chapter surveys the six tools that appear most often - from editor to build system to runtime - so each subsequent chapter can reference them without re-explaining the setup. The tools split into three roles:
  • Editor - VS Code, the single editor used across all languages.
  • Build systems - CMake (C/C++), MSBuild (.NET and C++), Clang (compiler + tooling).
  • Runtimes / package managers - dotnet CLI (.NET), Python (interpreter + pip).

1.1  VS Code

Figure 1. VS Code with integrated terminal VS Code is a lightweight, extensible editor from Microsoft that runs on Windows, macOS, and Linux. It provides language-aware editing through the Language Server Protocol, so every language extension (rust-analyzer, clangd, C# Dev Kit, Pylance) shares the same UI for completions, diagnostics, and go-to-definition. Extensions used across Code Story projects:
  • rust-analyzer - Rust: type inference, borrow checker feedback, inlay hints.
  • clangd or C/C++ Extension Pack - C++ with CMake integration.
  • C# Dev Kit - C# with .NET SDK project navigation and test runner.
  • Pylance - Python: static type checking via Pyright, import resolution.
  • Error Lens - Inline diagnostic messages on the offending line.
  • GitLens - Blame annotations, branch history, commit diff in the editor.
The integrated terminal eliminates context-switching: build, test, and run commands all run in the same window. The built-in debugger connects to each language's debug adapter without requiring a separate IDE.

1.2  CMake

CMake is a cross-platform build-system generator. It reads a CMakeLists.txt description and generates native build files for Make, Ninja, MSBuild, or Xcode. All C and C++ projects in Code Story use CMake so the same source tree builds on Windows, Linux, and macOS without modification. Typical workflow: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release cmake --build build ./build/my_app
  • -S . - source directory (where CMakeLists.txt lives).
  • -B build - out-of-source build directory; keeps the source tree clean.
  • --build build - invokes the underlying generator (Make or Ninja or MSBuild).
  • -DCMAKE_BUILD_TYPE=Release - enables optimizations; use Debug for debug symbols.
CMake 3.15+ supports presets (cmake-presets.json) that record compiler selection, build flags, and test configuration in version-controlled JSON rather than per-developer shell scripts.

1.3  MSBuild

MSBuild is the build engine for Visual Studio and the .NET SDK. It reads .csproj, .vcxproj, and .sln files. You rarely write MSBuild XML directly - the .NET SDK and VS generate it - but knowing the key flags matters when scripting builds or debugging build failures. msbuild MyApp.sln /p:Configuration=Release /p:Platform=x64 msbuild MyApp.csproj /t:Rebuild /p:Configuration=Debug
  • /p:Configuration=Release - selects the Release configuration (optimized).
  • /p:Platform=x64 - targets 64-bit; omit for SDK-style projects that default to AnyCPU.
  • /t:Rebuild - clean then build; /t:Build is incremental.
  • /m - parallel build using all CPU cores.
For .NET 5+ projects, the dotnet CLI (section 1.5) wraps MSBuild and is the preferred command-line interface. Use MSBuild directly for legacy .vcxproj C++ projects or when you need fine-grained control over the target graph.

1.4  Clang

Clang is both a C/C++ compiler and a tooling platform. The compiler produces code comparable to GCC and MSVC. The tooling layer - clang-tidy, clang-format, clangd, and the sanitizers - makes it the most diagnostic-rich C++ toolchain available. Key tools:
  • clang / clang++ - compile with -Wall -Wextra -std=c++20 -O2 as a baseline.
  • clang-tidy - static analysis; catches common bugs, enforces coding guidelines. Run via CMake with CMAKE_CXX_CLANG_TIDY.
  • clang-format - deterministic formatting driven by .clang-format in the project root. Integrates with VS Code's "Format on Save."
  • AddressSanitizer / UBSan - compile with -fsanitize=address,undefined to catch memory errors and undefined behavior at runtime.
  • clangd - language server; powers the VS Code C++ extension with completion, diagnostics, and cross-reference based on compile_commands.json.
Generate compile_commands.json from CMake with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON. Copy or symlink it to the project root so clangd finds it automatically.

1.5  dotnet CLI

The dotnet CLI is the primary interface for .NET SDK projects. It creates, builds, tests, and runs C# projects without requiring Visual Studio. dotnet new console -n MyApp # create console project dotnet build -c Release # build dotnet run # build and run dotnet test # run xUnit / NUnit tests dotnet publish -c Release -r win-x64 --self-contained
  • dotnet new - scaffolds projects; dotnet new list shows all templates.
  • dotnet add package <name> - adds a NuGet dependency and updates the .csproj.
  • dotnet publish --self-contained - bundles the runtime into the output; no .NET install needed on the target.
  • dotnet watch run - hot-reload loop; rebuilds and restarts on file save.
SDK-style .csproj files are concise enough to edit by hand. The CLI and MSBuild share the same project model, so a project built with dotnet build opens without modification in Visual Studio.

1.6  Python

Python 3.10+ is the runtime for all Python implementations in Code Story. The interpreter is also used for scripting build steps, running analysis tools (radon, pylint, cProfile), and driving the AI agent tools in the Code/AI/ directory. Project setup with a virtual environment: python -m venv .venv # create isolated environment .venv\Scripts\activate # Windows - activate source .venv/bin/activate # Linux / macOS - activate pip install -r requirements.txt python src/main.py
  • venv - isolates dependencies per project; avoids version conflicts between projects and the system Python.
  • pip - installs packages from PyPI; pip freeze > requirements.txt records the exact versions for reproducible installs.
  • pyproject.toml - the modern project metadata file, replacing setup.py. Build tools (flit, hatchling, setuptools) read it.
  • pylint / mypy - static analysis and type checking; integrate with VS Code via the Pylance extension and the Problems panel.
Python is the only interpreted language in Code Story. That matters for performance comparisons: CPU-bound tasks run 10-100x slower than compiled languages, but I/O-bound tasks (TextFinder, file search) close much of the gap because the hot path runs in compiled C extensions inside the standard library.