Svar: A Tiny C++ Header Brings Unified Interface for Multiple programming Languages
Yong Zhao, Pengcheng Zhao, Shibiao Xu, Lin Chen, Pengcheng Han, Shuhui, Bu, Hongkai Jiang

TL;DR
Svar is a lightweight C++ header that provides a unified, efficient interface for multiple programming languages, enabling dynamic reflection and easy cross-language module sharing without heavy dependencies.
Contribution
Introduces a minimalistic C++ header that unifies multi-language interfaces with reflection, dynamic loading, and efficient data handling, simplifying cross-language integration.
Findings
Svar achieves comparable performance to existing binding tools.
It enables runtime module sharing across C++, Python, and Node.js.
The core implementation is less than 5000 lines of modern C++ code.
Abstract
There are numerous types of programming languages developed in the last decades, and most of them provide interface to call C++ or C for high efficiency implementation. The motivation of Svar is to design an efficient, light-weighted and general middle-ware for multiple languages, meanwhile, brings the dynamism features from script language to C++ in a straightforward way. Firstly, a Svar class with JSON like data structure is designed to hold everything exists in C++, including basic values, functions or user defined classes and objects. Secondly, arguments are auto cast to and from Svar efficiently with compile time pointers, references and shared\_ptr detection. Thirdly, classes and functions are binded with string names to support reflection, this means all functions and classes in a shared library can be exported to a Svar object, which also calls a Svar module. The Svar modules…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsComputational Physics and Python Applications · Parallel Computing and Optimization Techniques · Scientific Computing and Data Management
