August 4th, 2024

ICPP – Running C++ in anywhere like a script

ICPP is a tool that enables execution of C++ code similarly to scripting languages, supporting Standard C++23, remote execution, hot-loading, and module management, enhancing developer productivity and flexibility.

Read original articleLink Icon
ICPP – Running C++ in anywhere like a script

ICPP is a tool designed to allow the execution of C++ code in a manner similar to scripting languages like Python, eliminating the need for traditional compilation and linking. Built on the Unicorn Engine and Clang/LLVM compiler, ICPP supports Standard C++23 and Boost libraries. It features both local and remote interpreters, enabling the execution of C++ code on various systems, including mobile platforms. The tool also supports hot-loading of scripts, making it ideal for testing, profiling, and plugin development. Users can manage third-party modules easily with the `imod` tool and utilize an interactive REPL for executing C++ snippets. Installation instructions are provided for multiple operating systems, and prerequisites include CMake, Python, and the LLVM toolchain. Example commands demonstrate how to run C++ source files and access the REPL. ICPP is particularly beneficial for developers seeking a more dynamic approach to C++ programming, enhancing productivity and flexibility.

- ICPP allows running C++ code without traditional compilation.

- It supports both local and remote execution of C++ scripts.

- The tool includes features like hot-loading, module management, and REPL support.

- Installation is straightforward with detailed instructions for various operating systems.

- ICPP enhances productivity for developers by providing a script-like coding experience.

Link Icon 7 comments
By @bsenftner - 2 months
Why interpret at all? Back in the mid to early 90's I started embedding C++ compilers into the game engines I wrote, where the "game scripting language" was just #define macros hiding the C++ syntax so the game level developers, who worked in this script, could be basically anyone that could code. Their "script" would compile to a DLL that was hot loaded. What they were doing in their scripts would compile in under 5 seconds, and they were good to go. If they ran into problems, one of the game engine developers would just run their "script" in the IDE debugger.

Borrowed this idea from Nothing Real, the developers of Shake, the video/film compositing system.

By @mindblah - 2 months
Folks who like this kind of thing should definitely check out CERN's Root framework. I've been using its C++ interpreter in a Jupyter notebook environment to learn C++. It's probably also quite a bit more mature than this project. https://root.cern/
By @Jeaye - 2 months
Along the lines of scripting is interactive programming. I'm working on a native Clojure dialect on LLVM with C++ interop, qalled jank. It can JIT compile C++ code, can be embedded into any C++-compatible application, and is a full Clojure dialect which doesn't hid any of its C++ runtinme. So you can do inline C++, compile C++ sources alongside your jank. and require them like a normal Clojure namespace. Worth a look if you're using C++ but you're craving something more interactive. https://jank-lang.org/
By @bobajeff - 2 months
I wonder if I can use this to learn a large c++ codebase like Chromium. One of the issues I had trying to learn chromium was that in order to play and experiment with their classes/functions I needed to spend several minutes to link my little test code with their static libraries just to be able to see if my understanding of them was correct. Which is just too long of time for such experiments so I gave up.
By @celrod - 2 months
How feasible would it be for something like gdb to be able to use a C++ interpreter (whether icpp, or even a souped up `constexpr` interpreter from the compiler) to help with "optimized out" functions?

gdb also doesn't handle overloaded functions well, e.g. `x[i]`.

By @ranger_danger - 2 months
This is really cool...

https://github.com/vpand/icpp-qt

Ok now things are getting interesting. I think this could be used to add easily shareable/hackable plugins to existing C++ projects.

By @Klasiaster - 2 months
Related is cargo script for Rust: https://doc.rust-lang.org/cargo/reference/unstable.html#scri... (nightly only)