Ask HN: Why is scientific programming dominated by dynamically typed languages?
Modern scientific programming is dominated by Python. Beyond this R has some history. Julia is up and coming. Many AI applications used to be developed in Lisp.
Is there something fundamental within scientific programming that makes dynamic typing desirable?
7 comments
[ 2.4 ms ] story [ 28.9 ms ] threadLisp era ai was mostly about inference over databases and not the intense numerics you see today.
Scientific computing is often experimental and ad hoc, it is important to be able to change it up quickly. The inner loops often are highly optimized so if you are using numpy you won't notice that python is slow. C++ is awful to do neural network work in (I have) and the kind of reprogramming supported by python is just what the Dr ordered for that kind of thing.
There are two reasons:
1. The users do a ton of work in a REPL of some sort. Jupyter for Python, R and Matlab have a notebook scheme, as do the CAS's.
So it's common to be running an environment where everything is reified at runtime anyway.
2. Polymorphism without generics. It's bloody hard to implement generics, and dynamic types let you ignore them entirely.
It's also very easy to get it wrong and very hard to make it understandable by a wide range of users.
And to counter a reason to make them early-binding:
Performance this is much less of a problem than you might expect in these domains, because scientific work is often dealing with big matrices and such, and you can heavily optimize those operations.
Even when mixing numeric and textual data it is in a form that's not too difficult to line up. We don't think twice about not providing type annotations in our SQL queries. Most rows from a given relation are similarly shaped and outliers are filtered or conditionally handled. It would be very different if we were trying to operate on a wide range of structured types (e.g. customers, addresses, accounts) as both inputs and outputs. Scientific programming is usually dealing with large aggregates and not about producing individual records.