3 ms·
> A Python/Fortran combination would have made the development of high-performing HPC type applications more accessible to scientists, more fun, and would have
by ghc 3y ago
> A Python/Fortran combination would have made the development of high-performing HPC type applications more accessible to scientists, more fun, and would have given Fortran a more secure future.
SciPy makes heavy use of Fortran. Numpy uses Fortran (but it's optional). f2py compiles fortran into python modules with little fuss. Python's ctypes module can directly call fortran libraries.
But to say Python should have been implemented in Fortran rather than C to enable Fortran interop by default -- that doesn't make sense. Python was designed as a scripting language for C-based operating systems, so it needed to be able to use pre-build unix libraries written in C, and it also needed to be embeddable in C programs. At the time neither of these things was easy via Fortran (cpython predates the Fortran 90 standard).
- nologic01 3y agoCython got started in 2007. F90 was very mature by then. In any case its not a binary choice C vs Fortran, and definitely not about a Fortran implementation of Python itself. It is about the ease of integrating performant bits written in something other than C/C++, not by HPC specialists but domain scientists. The examples you mention show that this is possible but its not what people have been doing in the broader data science area. There might be other benefits for adopting C++ instead of F90 as the computing layer but overall it might have been a missed opportunity.
- ghc 3y agoCython is not cpython. cpython started in 1990. Edit: In case you're confused, cpython is the de-facto standard implementation of Python. Cython is something entirely different (it compiles Python to C). Here's a good summary of Python's history: https://www.geeksforgeeks.org/history-of-python/ https://www.geeksforgeeks.org/history-of-python/.
- nologic01 3y agoBut I never suggested that cpython should have been implemented in Fortran. The discussion is about how Python could have tapped F90's HPC capabilities instead of relying heavily on C++ for this. Think Cython, pybind11, Boost.python etc.
- ghc 3y agoExcept Python doesn't use C++ at all -- using C++ from Python is not very easy. The reason is that Python's native FFI interface is in C, because the interpreter is written in C. The reason Jython, PyPy, IronPython, etc. never got traction is because of all the Python core libraries written in C. From a Python implementor standpoint, you have to implement Python's interpreter in the language you want to do the tight loops in. So for example, Jython was a reimplementation of Python on the JVM to make it possible to easily use Java for the tight loops. IronPython was the same, but for .NET. You say it's cultural, but it's all about ergonomics and backwards compatibility. Making it easy to write tight loops in Fortran means changing the FFI API to be fortran friendly, which it is not. Just try writing your MPI code with a combination of Fortran and Python. I did it circa 2005 and it was a technical nightmare.