AgainstTyping

ThoughtStorms Wiki

Of course I'm not against typing in all its forms. This is really the page for noting and discussing my general rabid prejudice in favour of LateBinding, weakly or dynamically typed programming languages.

Here's a relatively balanced thing I wrote in 2021 at https://clojureverse.org/t/does-it-make-sense-to-use-clojurescript-on-front-end-and-haskell-on-back-end/7944/28?u=interstar

Well, yes. What happens in Haskell is that errors get caught at compile time and stop you running anything.

The real question is “how useful is a half working program?”.

Is a program that works 90% of the time and fails 10% of the time, on certain data / values, more or less useful than a program which works 0% of the time because it won’t compile?

For some applications, sure. Failure at runtime is such a bad thing that you’d rather have no program at all than one which blows up at runtime.

For other applications, the reverse might be true.

There’s no single answer that suits all applications. That’s why we have different languages that make different trade-offs.

So the real question about “should I write my server in Haskell or Clojure?” is not “How many lines of code is it?”

It’s “what’s its profile in terms of failure? How catastrophic / costly are certain types of bugs, and how much is it worth paying the extra cost of being forced to fix all my bugs before I can get any part of it working?”

The trade-off between static and dynamic typing should be thought about like the other trade-offs, optimizations etc. In a sense, static typing is like premature optimization. It’s forcing you to fix certain bugs before you may really have to.

That’s the hidden cost on the flip-side of “I know that if it compiles it’s working” claim. Yeah, but it won’t be compiling for a while longer. The cost of dynamic typing turns up in the form of runtime bugs. The cost of static typing turns up in the opportunity cost of code that never got to a state where it could run at all.

Transcluded from DeathBySpecificity

Another way of thinking about typing is this. Strong Typing essentially forces you to think about the wider scope of your problem. When you're writing a routine to receive a parameter you have to think about the role that that parameter plays in the wider taxonomy of types of things in your system. Conversely, run-time typing lets you think only about what you need from it.

A quote from JamesGosling : In some sense, the brilliant thing that Tim Berners-Lee did was simply to say, "I don't care." For 20 years people had been failing to solve {problems of broken links} in any large-scale way. Berners-Lee decided to just do the simple obvious thing that solves the problem he needed, namely, getting ahold of a resource. And that's actually an easy problem. Coming up with those names, URLs, is a relatively straightforward thing. He did that, and that enabled a lot of what the Web is today. But the Web has all these problems. What happens if a Web page moves or gets deleted? That is exactly the problem of maintaining or managing the configuration of any large scale distributed system. On the one hand, the URL design has made the Web somewhat fragile. Broken links are all over the place. On the other hand, if they had tried to really solve that problem, the Web never would have happened, because the problem is just too hard. (. http://www.artima.com/intv/visualize.html . Also JackPot)

My first thought. Gosling gets it. But doesn't seem to have got the analogous case of strong typing.

Second thought. Why do I think that forcing strong typing on people is like forcing them to manage the complexity of preventing broken links? It's a very strong intuition for me. But maybe I need to explore this further, and see if it's really true or not.

Obviously it's something to do with OneWayLinks. When you force strong typing on the programmer, you force her to pay that cost of managing the co-ordination of the typing in different parts of the program. And as the program gets larger and more complicated, so those co-ordination costs explode ...

Counter

On ProgrammingWithAI I point it that AI assisted fitting may be encouraging me to use more types

Semi-related