fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

10K
active users

Martijn Faassen

I wrote a lot of code in . Dynamically typed, thoroughly unit tested. I think with a pretty low bug rate. I dared big refactorings. It was like riding my bicycle without hands, and I did that for two decades.

Then in the last 6 years, I slowly stepped into modern static typing. Here I have a lot more safety features. I still write lots of tests, but maybe a few less. And I start wondering whether I would still want to refactor without types and what that means.

1/2

I am older now, so maybe I lean on types to handle cognitive weakness? It doesn't feel that way - it's not like is easy to pick up. Maybe modern types and tooling really are a better way to do it? Maybe the help types offer compensates for the cost of their ceremony?

One explanation is that I always had types in my head anyway - my mental type checker was imperfect but good enough. Now I have a bit of machine help.

So maybe it doesn't matter all that much in the end?

2/3

It all being a wash sounds too convenient though. So I lean towards explaining this by saying the tools surrounding static types got good enough to convince me they are a good thing, more so than their cost.

I think that's what has been happening to JS and Python too - people grumble but the trend is towards tools that type check. I am sure part of the reason is just silly "best practice" - it's there so you must use it, but is that all? I think not: there are real benefits.

3/3

@faassen writing Python was frequently a case of running it and seeing how it blew up at runtime, or having to consider testing much more. With Rust, if I can get it to run it's accurate and works, my modeling and assumptions about the problem might not be correct, but my code reflects that.
That said, how do you feel about MyPy and such that offer seemingly all the benefits of typing during authorship?

@arichtman
I haven't used MyPy but I have used TypeScript a lot. I think these tools are great, but I have two problems with them:

* They are either incomplete or offer very powerful features to express dynamic language behavior. This tends to pull me into lots of tinkering.

* You get the benefit of checks but no benefit of faster code. It's nice to have both.

Now Rust also pulls me into a lot of tinkering, but I feel it pushes my code towards better design more often.

@faassen I think it is a very good idea to not rely on "cognitive strength" when designing software but to have security features in place that steer developers to good results even when they overlook things. Imo software development should be boring and predictable, being smart bites you later on often enough.

@grob
I agree that the answer should rarely be a mere "we should do better/work harder".

But in the dynamic vs static typing debate there are more trade-offs. I am sure you have heard a variety of arguments for dynamic typing before. I don't think those arguments are wrong, but they do need to be weighed on the scale of trade-offs, and the context affects where the scales go.

@faassen I am probably biased at this point since I've had so many instances where static typing could have made work so much easier 🙈

@faassen I wonder if it's also a maturity thing. I feel like I have much more clarity about problem solving and modeling as I've gotten older. All of this has made reasoning about types and program structure to be easier I think.

@dabeaz
Yes, it could well be that my increased experience makes me better equipped to handle types and stuff.

That said there are devs a lot younger than me who seem to handle types just fine, better than me in some cases.

@faassen I feel like I've become very finicky when it comes to typing. I don't mind dynamic typing (ala Python). I also don't mind static typing when it's well integrated into the whole experience. On the other hand, I find myself rather NOT liking the experience of retrofitted or optional types.

@dabeaz @faassen yes, this. I’m happy to use Rust (or Swift or …) but I’m still not seeing the joy in Python typing. 🤔

@carlton @dabeaz @faassen I am not a fan of using typing for typing sake, but the few frameworks/tools that embrace it or some of my favorite libraries to use.

Like Typer makes command line argument parsing go from painful to painless and removes dozens of lines of code.

Versus a Django project that lints with mypy is a really, really painful and arguably bad DX experience. This isn't mypy's fault either.

@webology @dabeaz @faassen sure… introspection and runtime use is cool.

How to convey my feeling, in contrast to real static types…

« Left holding a damp sock » is probably as close as I can get in short form.

@webology

@carlton @dabeaz

Type driven declarative behavior is another benefit of types altogether, where in fact a dynamically typed language makes implementation more easy than using something like Rust macros. That said Rust has some really cool stuff in this area.

I hear Zig has good ideas on making it easier to do macro style stuff.

@webology @carlton @faassen If I'm putting type-hints on Python code, it's almost always for the purpose of helping someone who's staring at the code. That is not necessarily the same as playing whack-a-type with mypy. I'm not doing that.

@dabeaz

@webology @carlton

With static type checking present I find I tend to be drawn into type whack-a-mole. Whether that is worthwhile depends on feeling afterwards that the design has improved or not.

@dabeaz
Yeah, the retrofitted nature of the static typing is what bothers me most. You get some checking benefits but it gets more complicated than it needs to be, or you have holes, and you don't get any performance benefits.

@dabeaz @faassen exactly this. Retrofitting means the old way is also permitted. The lack of an old way to do things is one of the big appeals of Rust.

@scouten @faassen For me, I think it's about the lack of clearly defined boundaries. I think I'd like it better if there was well defined "static Python" and "dynamic Python", but for a single program module, you've got to choose which it is. And it's "all in" on the choice for that module.