3 ms·
I basically agree (except I will take static typing over dynamic typing any day). I work in computational chemistry, and scientists here don’t necessarily have
by sseagull 3y ago
I basically agree (except I will take static typing over dynamic typing any day).
I work in computational chemistry, and scientists here don’t necessarily have problems actually coding (we’ve been doing it for 70+ years). But the “other stuff” is taking more and more time.
Before, you wrote Fortran, put the files on disks or whatever, and sent them around. Now, you need to know:
C++ and Python (and maybe Fortran too)
git and github and github actions, and packaging (pypi/conda/conda-forge I guess is the standard now).
Documentation? Sphinx I guess, although mixed codebases are still a pain. And where do I host the docs again?
Also better make sure it works on all three OSs.
Wait what is docker? Suppose I better learn make images. And they have to be hosted somewhere? Got to set that up too.
Oh wait again, Python 3.12 broke something. Have to fix that.
Does all of this make “better software”?. I’m coming around to the idea that maybe it doesn’t, at least in aggregate. Either way, scientists don’t have time to really learn all this AND the science they are doing. And it all changes every few years or so.
- dillydogg 3y ago> Either way, scientists don’t have time to really learn all this AND the science they are doing. And it all changes every few years or so. This is how I see it as well. I'm an immunologist, and it feels impossible for me to keep on top of my field of research and just about anything else. I don't have to produce quality software, but it seems difficult to keep your research cutting edge while maintaining software. It's hard enough keeping the research up to date!
- jampekka 3y ago> (except I will take static typing over dynamic typing any day) Why? What exact typesystem do you prefer over Python's dynamic typing? A lot of its idioms, and probably e.g. NumPy/SciPy infrastructure would be about impossible with current static typesystems (look at the mess that is C++ scientific/ndarray libraries). Ditto for much of the autodiff and GPU stuff like pytorch. Julia could perhaps get there, but the implementation has too many warts for it to take over.
- sseagull 3y agoIt's more to do with developer ergonomics. Knowing what something is or returns (and having some guarantees about it) make it much easier to reason about code. Then, knowing (with guarantees) what a variable/object is, knowing right away what I can do with it. > What exact typesystem do you prefer over Python's dynamic typing? I just want to know what various objects are laying around in my code so I don't have to keep it in my head. For example, if you are using a database library like psycopg, you run a query and execute it. What kind of object is returned from the query execution function? How do you check if it was null? You have to go looking at documentation, and often what you find is examples of what you can do. But those examples often don't include absolutely everything, so you have to go looking at the code itself. But library code in python is often pretty arcane. With Fortran/C++/Rust/etc, you get all of that basically for free in your editor's autocomplete. And the compiler will check to make sure you didn't do anything truly dumb. Dynamic typing also encourages some frustratingly bad habits. Lots of code out there will have functions that change return type depending on what arguments are provided. And occasionally someone will forget to return something in some branch and you won't know until you hit an edge case (during runtime) and suddenly you have a None coming from somewhere. My projects tend to be in Python now, but I recently started a side project in C++ again and found it very refreshing. > probably e.g. NumPy/SciPy infrastructure would be about impossible Partly true, but maybe not as true as you think. I've been using the nlohmann JSON library for C++, and it is amazing. The code almost looks pythonic, and its type conversions are done automatically (although at runtime of course). For example, for(const auto &[key, value] : some_json["x"].items()) double d = value["other_key"]; EDIT: Also, I didn't realize how much I missed function overloading until I started the C++ project. Wow is that handy.
- jampekka 3y agoI find that "what can I do with the value" is a lot more important than "what the object is". Especially in scientific context this is usually "can I iterate this" "can I do arithmetic with this" etc. NumPy's broadcasting and support for "any" iterables is a great example of this. And very difficult to accomplish with at least the typesystems you listed. E.g. going from a nested list in a JSON to a Eigen matrix is quite a pain even with (awesome) libraries like nlohmann/json. I often have to resort to C++ for performance or libraries. I make a lot more bugs than in Python. And the bugs are often really tricky and often pass the typesystem (e.g. both nlohmann and Eigen have to really hack the templates and these cause a lot of edge cases). Also serializing stuff in C++ is a real pain even with nlohmann/json because for god's sake there's still no reflection in C++ in 2024. Of course you can abuse the power of dynamic typing. But you can just as well abuse anything else that's remotely powerful (see e.g. Boost).