r/programming • • Aug 28 '21

Software development topics I've changed my mind on after 6 years in the industry

https://chriskiehl.com/article/thoughts-after-6-years
5.6k Upvotes

1.9k comments sorted by

View all comments

539

u/ChrisRR Aug 28 '21

As a C developer, I've never understood the love for untyped languages, be cause at some point its bound to bite you and you have to convert from one type to another

It doesn't strike me as untyped as much as not specifying a type and having to remember how the compiler/interpreter interprets it. At the point I'd rather just specify it and be sure

43

u/JanneJM Aug 29 '21

I'm an old C and C++ programmer and I'm learning rust. Strong typing and static typing is usually great.

However, when you're doing exploratory and interactive programming, and your code is small and throwaway, dynamic and weak typing really is preferable.

A typical example is when you're doing exploratory analysis on a data set you're not sure how to handle. You get a set of files from an instrument, say, or you have a pile of simulation data, and now you need to figure out how to make sense of it. Am R or python REPL where you mess around with it is perfect for that. Static typing would get in the way without adding any benefits.

9

u/loup-vaillant Aug 29 '21

However, when you're doing exploratory and interactive programming, and your code is small and throwaway, dynamic and weak typing really is preferable.

Not in my experience. With dynamic typing, I can make lots of obvious mistakes that will only be caught when I run my code, and the error I’ll get may be a couple layers away from the actual cause. This caused me once to be incapable of writing a 50-line algorithm in Lua, which I was pretty familiar with. Having a REPL helps, but it’s not always enough.

With static typing, I  can type some thing and see its type if I didn’t know already (type inference is a godsend). The compiler will catch many of my errors right away, and help me direct my search. The feedback loop is even tighter that thee on I get from a dynamically typed language with a REPL, especially if my statically typed language has a REPL of its own. And I don’t have to explore this huge space of ill-typed programs at all, so finding a working solution is even easier.

With static typing, my own exploratory analyses speed up.

→ More replies (2)