Papers
Topics
Authors
Recent
Gemini 2.5 Flash
Gemini 2.5 Flash
167 tokens/sec
GPT-4o
7 tokens/sec
Gemini 2.5 Pro Pro
42 tokens/sec
o3 Pro
4 tokens/sec
GPT-4.1 Pro
38 tokens/sec
DeepSeek R1 via Azure Pro
28 tokens/sec
2000 character limit reached

A functional scripting interface to an object oriented C++ library (2312.13295v1)

Published 17 Dec 2023 in cs.PL

Abstract: The object oriented programming paradigm is widely used in science and engineering. Many open and commercial libraries are written in C++ and increasingly provide bindings to Python, which is much easier to learn, but still partly encourages the use of object oriented programming. However, scientific ideas are much more directly and meaningfully expressed in the purely functional programming paradigm. Here, we take a best practice example, CERNs Python binding for its ROOT library, designed to handle the enormous amounts of data generated by the worlds largest particle accelerator, and translate a simple segment of its tutorial into Clojure, a functional language from the Lisp family. The code examples demonstrate how a purely functional language straightforwardly expresses scientific ideas. Subsequently, we develop a compiled Lisp-C++ interoperation layer to access the ROOT library exclusively via functional code. To preserve the expressivity of the Lisp code, the type hints necessary for C++ code generation are stored in a separate file. The interop system presented here is a generic framework that, when provided with a suitable file of type hints, facilitates access to methods of arbitrary C++ libraries and platforms like real-time microcontrollers.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (18)
  1. Root—an object oriented data analysis framework. Nuclear instruments and methods in physics research section A: accelerators, spectrometers, detectors and associated equipment, 389(1-2):81–86, 1997.
  2. Structure and interpretation of classical mechanics. The MIT Press, 2015.
  3. Functional differential geometry. The MIT Press, 2013.
  4. The role of programming in the formulation of ideas. AI Memo, Artificial Intelligence Laboratory, MIT, 18, 2002.
  5. Rich Hickey. The Clojure programming language. In Proceedings of the 2008 symposium on Dynamic languages, pages 1–1, 2008.
  6. Jeaye Wilkerson. The jank programming language. https://jank-lang.org. Accessed: 2023-12-09.
  7. CERN ROOT Manual. Passing Python callables to C++. https://root.cern/manual/python. Accessed: 2023-12-09.
  8. Clojure.org. State of Clojure 2023 results. https://clojure.org/news/2023/06/30/state-of-clojure-2023. Accessed: 2023-12-09.
  9. Efficient and accurate automatic Python bindings with cppyy & cling, 2023.
  10. Nurullah Akkaya. Ferret programmer’s manual. https://ferret-lang.org. Accessed: 2023-12-09.
  11. Markus Kloimwieder. LisRoot. https://github.com/kloimhardt/LisRoot. Accessed: 2023-12-09.
  12. Meta and community. React. https://react.dev/learn. Accessed: 2023-12-09.
  13. Cython: The best of both worlds. Computing in Science & Engineering, 13(2):31–39, 2010.
  14. Metosin. malli. https://github.com/metosin/malli. Accessed: 2023-12-09.
  15. The role of interpreters in high performance computing. Technical report, Fermi National Accelerator Lab.(FNAL), Batavia, IL (United States), 2008.
  16. D Liebgold. Functional mzScheme DSLs in game development. Commercial Users of Functional Programming, 2011. http://cufp.org/2011, Accessed: 2023-12-15.
  17. Potential of the Julia programming language for high energy physics computing. Computing and Software for Big Science, 7(1):10, 2023.
  18. Paul Graham. Revenge of the nerds. http://www.paulgraham.com/icad.html. Accessed: 2023-12-09.

Summary

We haven't generated a summary for this paper yet.