|
1 | 1 | # Interactive C++ Development Through Persistent Execution Contexts: A Notebook-Based Approach |
2 | 2 |
|
| 3 | +**cpp-notebook** is a native interactive C++ notebook environment that lets you write and run C++ code cell by cell with persistent state — no Python or Jupyter backend required. It's built with Dear ImGui, Markdown cells, and real-time execution context. |
| 4 | + |
3 | 5 |  |
4 | 6 |  |
5 | 7 |  |
|
9 | 11 |
|
10 | 12 | ## Abstract |
11 | 13 |
|
12 | | -We present **cppnb**, an interactive notebook environment for C++ that fundamentally rethinks how compiled languages can be used for exploratory programming. Unlike traditional C++ development workflows that require complete program compilation, our system enables cell-based execution with persistent state—similar to interpreted languages like Python, but maintaining C++'s compile-time guarantees and performance characteristics. |
13 | | - |
14 | | -The core innovation lies in our execution engine that maintains a global context across cell executions. When you define a variable in one cell, it remains accessible in all subsequent cells. When you update that variable, the change persists. This seemingly simple behavior requires solving a fundamental incompatibility: C++ is compiled, not interpreted. You can't just "remember" variables between compilations like you can with Python. |
| 14 | +**cppnb** brings Jupyter-style interactive notebooks to C++. Write code in cells, run them individually, and watch variables, functions, and classes persist across executions—just like Python, but with C++'s compile-time safety and zero-cost abstractions. |
15 | 15 |
|
16 | | -Our solution reconstructs a complete C++ program for each cell execution, incorporating all previously defined variables (with their current values), functions, and classes. This approach eliminates the traditional compile-link-run cycle while preserving type safety and enabling the use of templates, operator overloading, and other C++ features that make the language powerful. |
| 16 | +The key challenge: C++ is compiled, not interpreted. When a program exits, everything is gone. We solve this by maintaining an execution context that tracks all variables, functions, and classes. For each cell execution, we regenerate a complete C++ program incorporating the entire context plus the new cell code, compile it with g++, run it, and display results. To the user, it feels interactive. To the compiler, each run is a fresh, valid C++ program. |
17 | 17 |
|
18 | | -Built on ImGui for immediate-mode rendering and SDL2 for cross-platform support, cppnb provides a modern interface with syntax highlighting, markdown documentation cells, variable inspection, and comprehensive error reporting. The system demonstrates that compiled languages can support interactive workflows without sacrificing their core strengths. |
| 18 | +Built on Dear ImGui and SDL2, the system includes syntax highlighting, markdown documentation, variable inspection panels, and real-time error reporting. No Python. No Jupyter kernel. Just native C++ from start to finish. |
19 | 19 |
|
20 | 20 |  |
21 | 21 |
|
22 | 22 | --- |
23 | 23 |
|
| 24 | +## Quick Start |
| 25 | + |
| 26 | +- **Install dependencies:** `brew install cmake sdl2` (macOS) or `sudo apt-get install cmake libsdl2-dev libgl1-mesa-dev` (Linux) |
| 27 | +- **Build:** `git clone <repo> && cd cpp-notebook && mkdir build && cd build && cmake .. && make -j4` |
| 28 | +- **Run:** `./cppnb` and start writing C++ code in cells |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## 🛠 Version 0.1.0 — First Release (March 2025) |
| 33 | + |
| 34 | +This is the inaugural release of cpp-notebook: a native, interactive C++ notebook environment that brings persistent state and exploratory workflows to compiled C++. |
| 35 | + |
| 36 | +### ✨ What's Included |
| 37 | + |
| 38 | +**Core Features:** |
| 39 | +- Interactive notebook UI powered by Dear ImGui & SDL2 |
| 40 | +- Cell-based C++ execution with persistent global context |
| 41 | +- Variables, functions, and classes survive across cell runs |
| 42 | +- Automatic program regeneration and compilation pipeline |
| 43 | + |
| 44 | +**Editor & Documentation:** |
| 45 | +- Syntax-highlighted code editor (C++20 support) |
| 46 | +- Markdown cells with live preview toggle |
| 47 | +- Native keyboard shortcuts (Cmd+C/V/Z, Shift+Enter to run) |
| 48 | + |
| 49 | +**Developer Tools:** |
| 50 | +- Real-time variable inspector showing types and values |
| 51 | +- Function and class outline panels |
| 52 | +- Execution timing and error reporting |
| 53 | +- Color-coded output (green for success, red for errors) |
| 54 | + |
| 55 | +**Build System:** |
| 56 | +- CMake-based cross-platform build |
| 57 | +- macOS and Linux support |
| 58 | +- Dependencies: SDL2, Dear ImGui, ImGuiColorTextEdit |
| 59 | + |
| 60 | +### 🚧 Known Limitations |
| 61 | + |
| 62 | +- No true debugger (breakpoints/stepping) |
| 63 | +- Limited multi-file support |
| 64 | +- Compilation can be slow for large contexts |
| 65 | +- No package manager integration |
| 66 | +- Error messages need better line number mapping |
| 67 | + |
| 68 | +### 🎯 What's Next |
| 69 | + |
| 70 | +- Save/load notebook files (`.cppnb` format) |
| 71 | +- Export to standalone `.cpp` or markdown |
| 72 | +- ImPlot integration for visualization |
| 73 | +- Auto-completion and IntelliSense |
| 74 | +- Precompiled headers for faster compilation |
| 75 | + |
| 76 | +--- |
| 77 | + |
24 | 78 | ## 1. Introduction |
25 | 79 |
|
26 | 80 | ### 1.1 The Problem with C++ Development |
|
0 commit comments