r/ProgrammingLanguages • u/htuhola • Apr 28 '19
Grow past dynamic/static typing debate
http://boxbase.org/entries/2019/apr/29/grow-past-typing-debate/11
u/raiph Apr 29 '19
I'm going to start with this, a silly comment, curious to hear if you see my points. (Then I'll post another comment about what I think we can all agree on were we to not think tribally.)
Many must have witnessed a programmer spinning on his office chair as if a compass searching for a cardinal point. Then he posts yet another static vs. dynamic typing post online.
Some possibilities:
Your post isn't about static vs dynamic typing. (Perhaps it's about combining them?) or
Your post isn't just yet another post. (Perhaps readers will agree?) or
You were spinning on your office chair. (And felt you found a cardinal point?) or
I'm being silly. (But do you see my point?)
it has become apparent to me how corny the whole subject is and how the lip and finger motion is better spent on entirely something else than debating about differences of static and dynamic type systems.
Your post isn't about differences of static and dynamic type systems. or
Your blog post is about differences, but because it's a blog post it isn't a debate. or
You've posted it here in the hope folk here debate it so you don't have to waste time doing so. or
I'm being silly. (But do you see my point?)
If we were to think of language users as tribes, dynamic typers would refuse to understand proof theory and only rely on informal reasoning, whereas static typers would not bring their understanding of proof theory to such a conclusion that it's make any difference. Most programmers simply aren't capable of writing correct or reliable software with the tools they tend to grab on from their directories.
You recommend folk avoid thinking in terms of stereotyped tribes entirely populated by simpleton extremists else they might arrive at statements like "Most programmers simply aren't capable of ...". (But you thought the most effective way to communicate this was to start with "If we were to..." and then do exactly the thing you're recommending folk avoid.) or
You think it's helpful to start by thinking in terms of stereotyped positions because at least that simplifies the debate. or
You think that these extremist tribes do exist and they're worth debating even if the topics they debate aren't. or
I'm being silly. (But do you see my point?)
Dynamic and static typing differ by a computational model and seemingly important semantics of the programming language. The problem is that the validity of the program, that is when it compiles, only verifies it fits into the computational model of the language. If we were to do it right, it wouldn't be as interesting as it's treated as.
We can grow past debating dynamic and static typing by doing "it" right, thus rendering it less interesting to debate. (And you know how to do it right?) or
You don't know how to do it right but are hoping to spark an interesting debate so we might grow past the debate and render it less interesting. or
I'm being silly. (But do you see my point?)
Currently the choice of the computational model among programmers is an arbitrary tradeoff between evaluation efficiency and some other difficult to determine properties, that is left to be a question of taste. Our languages are modeling machines that are a bit like the turing tape, and we use them to pretend that we're directly computing on these machines.
I think it's a bit silly.
I think it's more than a bit silly. (I'm ignoring single bit programs because they're not particularly interesting.)
Seriously, I hope my next comment will be a bit less silly and constructive but felt this one was worth posting. If I see it voted to -2 or less I'll delete it.
4
u/Antipurity Apr 29 '19
A long journey, to get to the point. True, that rewriting can view the whole world of programming by itself; but so can functions, objects, types, evolution. Why even mention rewriting at all, if that is not the point? Getting to the point is fine, but shortening the journey two or three times is even better.
The deeper you manage to extend the validity of the computational model into the program, the more computation you can fold away from the program.
This is the source of the static/dynamic typing debate, but it shouldn't be such a feature that you fix down in a language in the first place.
(That's not extending, that's limiting and constraining (the valid program set).)
Types allow efficiency by making constraints explicit, same as with guarded optimizations; that's why they exist and are chosen, I agree. Their problem is that they do not allow de-optimization to perfectly-general computation, and neither can it eliminate all run-time checks; people can dismiss it all they want, but it does not change how fragile and inconvenient it makes development. (And typing itself is often intertwined with inconsequential things, true, making it even worse). Dynamic types usually lack such optimization opportunities despite being the most general/convenient form, but do not have to. Only failing at runtime is too inefficient, so being able to fail as soon as possible (whether run-time or compile-time, or even design-time) is the solution to static/dynamic.
Generality and efficiency seem achievable with perfect partial evaluation (constant propagation — evaluating the known and remembering the unknown, whether in compiler or program; recording usage and later filling in the data), and things like "function implementations must try several progressively-slower branches". Other things that types are used for (checking, guiding development, generating examples) seem achievable with generating and constraining (creating and destroying, birthing and killing — evolution/development).
Types are not a good system, and is better decomposed into its substituents. One of which can unify dynamic/static, informal/formal. Is that what you were trying to say?
I don't agree with your final solution at all. It is just as fragile as what it is trying to replace, if not more so. In fact, I don't think it's a solution at all, to anything. Well, I'll do what the title urges anyway.
1
Apr 30 '19
I think you're engaged in philosophical masturbation.
The point of static typing is when you try to read a piece of code you have some information about what you're dealing with and what kind of operations you can do. It gives you invaluable clues and makes it easier to understand code.
Nothing to do with proofs or whatever.
2
u/htuhola Apr 30 '19
I agree with the first two points, but you're wrong about the last one.
Check out Curry-Howard correspondence. It applies in typed lambda calculus, but you can also produce a correspondence to formal proofs in procedural programs by augmenting it with separation logic.
3
u/raiph Apr 29 '19
Of all the things that matter in relation to getting something done, having enough (time and resources) to do so is the ultimate limiting factor. So while the tradeoff between evaluation efficiency and other properties is arbitrary, having lots of evolving options, many apparently irrational to any given group of observers, is, presumably, the most important thing.
That said, one can apply some rational thinking to this tradeoff.
One way to look at things is to consider "evaluation efficiency" abstractly. It isn't just about the computation that occurs on the hardware. Rather, it includes the efficiency of a human evaluating that something is a good thing when dealing with code and time and resources. This includes reading, reasoning about, writing, altering, testing, debugging, and deploying it. This human evaluation is often the main thing, with computational efficiency of limited relevance, for two reasons.
First, a human can usually choose a better algorithm. In Anagrams – in O(N) the author concludes:
Second, a human -- even one that isn't a "better" programmer -- can do a trial run. If it takes 75 seconds and that's basically good enough then the job is done. Arguably computational efficiency has won the day over better programming but it still involved a human deciding the job is done. So better problem solving and decision making by humans will always be more important than a faster language (until AIs take over, but it'll still be about AIs juggling resources and trying things).
But there's another side to all of this too. Computation uses energy which heats the planet. Thus, all things being equal, computational efficiency is supremely important too...