Comment by giancarlostoro
15 hours ago
I always chuckle at how Python became the dominant language for AI / ML / data science etc but wonder why it is that Fortran and Python became the golden combo, it could have been done with any other language, no complaints, I love Python, but its just amusing to me.
For Fortran, I have the concept of 'immortal code' - code that is generally hard to write, is compatible with everything, and implements an algorithm in a way that's impossible to improve on - or at least doing so would be celebrated as a minor breakthrough.
A lot of numerical optimization code is this - it conforms to a strict 'C' ABI - taking (arrays of) simple floats and ints and outputting the same, so binding it to another higher level language is trivial, so rewriting it makes little sense. If the same algorithm were written in Java, most people would not want to bring in Java as a dependency for their Python/C++/whatever project, but since this is just a tiny C object file, it's happily integrated into everything.
They also tend to be very tricky to get right, I remember reading a paper where the author was adamant that changing the order of a multiply and an add (a mathematically invariant operation) would cause the algorithm to blow up due to the different scales of floating point values involved causing a major loss of precision. I'm sure there's tons of stories like this.
This is the sort of code which took PhD's who studied this exact topic years to get right, even though the actual code often looks unassuming, I would dread the day when I was required to touch it (but I never do - since it always does what it says on the tin)
It's really just that it's a pretty easy language to learn that finds a good balance between structure and brevity. It has very good support for the data structures you need and libraries for everything. A lot of people love the language and that built up a lot of momentum and eventually people started adding stuff like numpy and scipy and pandas and before long you had this giant scientific computing environment that almost anyone can get into.
I tried out most of the scripting languages out there (Ruby, Perl, Tcl, Groovy, R, and many more) and Python just seemed to click more and it has a whole lot less to worry about upfront than languages like C# and Java. In comparison to languages like C and C++, it's a godsend for those with typical automation needs.
In my eyes it seems like a pretty straightforward development. There have been plenty of other tools that may have made sense throughout history too. Matlab could have done this, but by that time nobody was going to build out massive libraries for something expensive and partly closed off.
Python is one of my all time favorites, it is quirky, but nowhere near as quirky as JavaScript.
Yeah Python is older than Linux or HTTP. It was virtually unknown in the 1990s, though.
Funny how it’s getting its time in the sun now.
NumPy was pretty early, and it hit the sweet spot for science: free, fast, with a quick and dirty scripting language around it.
Then the whole ecosystem that Python has nowadays was built on NumPy, and sending data from one library to another was trivial because of it.
That's it.
I found R a better language for Data Science, somehow Python won out.
Fortran has been a research language used by people like physicists and mathematicians that know what they're doing and have been developing that tool for decades and Python is perfect for people who have no idea what they're doing.