Why was Geant4 (all the code) developed with C++?

Hi, Why was Geant4 (all the code) developed with C++?, in other words, Why wasn´t Geant4 developed with another programming language (s) (Python, for example) ?. Is C++ the best programming language for developing Geant4?

Geant4 Version: 11.2.1
Operating System: Windows 10
Compiler/Version: Visual Studio 2022
CMake Version: 3.29.0-rc2


This can get into some inane fighting between programming language preferences. The first release of C (1972) and C++ (1985) allowed for those code bases to be extensively supported and tested almost concurrently with Geant (first version released in 1974). In high energy physics and computational physics the big decision was between Fortran and C. I may be wrong but the big winner with the transition was object oriented programming which was considered exceptionally well suited for Geant3/4. Python was first released in 1990, with the Tiobe index being only 1% (as flawed as the metric is) as far back as 2002.

Other than causality concerns, C++ has historically been much preferred for high performance computing because it allows explicit access to memory space and multiprocessing/parallel processing while still having extensive OOP libraries. Python until very recently had clumsy multiprocessing/threading/parallel processing because of its Global Interpreter Lock. And generally speaking when using a high performance computational library like scipy, cuda, or numpy, these are just python wrappers for C library calls.

There is more to it than this but those are the big things I can think of at the moment. Being just slightly above Assembly gives more overhead however, and because you can do truly stupid things with memory you are also responsible for managing it and cleaning it up.

Geant4_pybind is still actively maintained and GATE 10 (specialized for medical applications) now wraps everything in python calls if you just want access to python syntax and libraries. The core will likely stay C for the forseeable future.

1 Like

Okay, thank you very much for all the information. So, Could it be said that Geant4 was created using C++ to overcome the limitations of Geant3 (created using Fortran)?. In brief, could it be said that C++ was chosen to create Geant4 to modernize simulation?.