Svar: A Tiny C++ Header Brings Unified Interface for Multiple programming Languages

08/19/2021
by   Yong Zhao, et al.
1

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 can be accessed by different languages and this paper demonstrates how to import and use a Svar module in Python and Node.js. Moreover, the Svar modules or even a python module can also be imported by C++ at runtime, which makes C++ easier to compile and use since headers are not required anymore. We compare the performance of Svar with two state-of-the-art binding tool for Python and Node.js, and the result demonstrates that Svar is efficient, elegant and general. The core of this project is one single tiny modern C++ header with less than 5000 lines code without extra dependency. To help developers using Svar, all the source codes related are public available on http://github.com/zdzhaoyong/Svar, including documentations and benchmarks.

READ FULL TEXT
research
12/21/2021

AmPyfier: Test Amplification in Python

Test Amplification is a method to extend handwritten tests into a more r...
research
11/01/2022

Excel Spreadsheet Analyzer

Spreadsheets are widely used in various fields to do large numerical ana...
research
07/13/2018

The Dune Python Module

In this paper we present the new Dune-Python module which provides Pytho...
research
02/28/2021

PyCG: Practical Call Graph Generation in Python

Call graphs play an important role in different contexts, such as profil...
research
04/17/2018

Metaclasses and Reflection in Smalltalk

Many Object Oriented Programming Languages provide reflective features w...
research
10/01/2019

Mμl: The Power of Dynamic Multi-Methods

Multi-methods are a straightforward extension of traditional (single) dy...
research
10/13/2021

libdlr: Efficient imaginary time calculations using the discrete Lehmann representation

We introduce libdlr, a library implementing the recently introduced disc...

Please sign up or login with your details

Forgot password? Click here to reset