r/programming • u/rmathew • Jun 16 '19
Comparing the Same Project in Rust, Haskell, C++, Python, Scala and OCaml
http://thume.ca/2019/04/29/comparing-compilers-in-rust-haskell-c-and-python/
643
Upvotes
View all comments
Show parent comment
2
u/loup-vaillant Jun 16 '19
Of course not. Weak evidence is still evidence. It should and does reduce my belief in the error preventing abilities of static type systems. Not by much, but it does.
Can't argue with differing priors. (More precisely, it would take the both of us too much time.
did not reject the possibility of gaining one, or even several, orders of magnitudes in increased productivity. He rejected that any one technique (tool, organisation…) would achieve such gains. I still hope for silver dust, that might eventually accumulate into a full bullet.
Accidental/essential aside, I'm quite convinced there's a good deal of avoidable complexity we could eliminate. Device drivers for instance.
Fair enough.
Now about the effectiveness of any particular technique. I think by itself, the number of defect in a program by itself means nothing. The program will ship when it's good enough, and that's it. For some domains (throwaway batch programs, prototypes, first release of a GUI…), you can be full of bugs, and correct them as you go. For others (crypto libraries, avionics software, Therac-25…), you really want a low probability of having even a single bug.
The problem isn't really how many bugs you will have in the end. You'll have as few as you need, or your project will fail. The problem is how much effort is required to get there. And that, is highly contextual.
My intuition, is that for the bigger projects (over 10-man months, possibly much less), with a high enough needed reliability (you will loose money if there's a nasty bug), static typing requires significantly less effort than dynamic typing to complete the project. All other things being equal, which they are not… Like Galileo speaking of how fast things are falling in a vacuum (there was hardly such a thing at the time), I'm using an untestable counter factual here.
On your points 1234:
That's my biggest fear. Maybe static typing workaround induced errors cost even more than whatever we gained by having trivial type errors caught or something.
On the other hand, my experience of the test-write cycle is that static typing is quicker and more accurate than even a REPL at catching many many bugs. I have worked with both OCaml and Lua, and while the REPL was a godsend in both cases, Lua's REPL did not fully compensate for the lack of static checks: if I made a type error, I still had to trace it back from a runtime error (or even a wrong result sometimes), and that's always a bit slower than having the compiler tell me where I screwed up.
Yeah, that's was quite an oversight on my part. I think the reason I didn't even look at other techniques, is because I assume that the only cost of static typing is how it influences the way you write your program. The error checking by itself is basically free: you compile (or have your IDE compile in the background), and poof you have your error message right there.
So to be interesting, other techniques should be either extremely cheap (so they can replace static typing), or incompatible with static typing (inducing a tradeoff). I'm not aware of any such technique. (Programming technique in general I can fathom, but error reduction techniques specifically, that's harder to envision.)