by rockmeamedee · 13y ago · 0 comments
When thinking 'static types', does everybody just think C/C++/Java? Is it upfront costs? My first ML program, I took half an hour to write a function that output all the words in a trie. It gets easier, and more interesting afterward, but I might have given up had it not been for a class. Are static types too rigid for prototyping? Scala, Haskell and OCaml have REPLs.
Some of the "experimental features of static type systems" like dependent types are really powerful; you can make some strong proofs about the logic of your program. I'd be willing to give up (or at least try going without) duck typing for that.
Also, sometimes in Haskell it's so hard to write a function that mostly-works (because they type system sees your mistake but you don't) that you can't get enough of your half-baked idea down so that you can see it clearly enough to figure out how it's supposed to really work correctly
Also, I've seen plenty of programs that provably have no bugs, but still grow to exhaust all system memory or occasionally take several hours to return from a function call for no apparent reason. And those are a major pain to diagnose.
I think you mean programs that type checked, not programs that provably had no bugs.
Or, to put it another way: our existing type systems don't make code "provably correct", and when people say that it does (like the commenter above), they're trying to talk you into something.
That is what I am telling you.
>and when people say that it does (like the commenter above)
They said no such thing.
Yes, it is nice to be able to write proofs and have them checked mechanically. However, for nontrivial programs, even stating correctness (to a level of precision a proof checker can understand) is often very difficult. Once you've figured out how to do that, you still have to take the time to write the proof. There is also a cost associated with this capability even if you don't exercise it: dependent type systems (aside from things like Dependent ML, which restrict type indices to a much smaller language) tend not to play nicely with side effects like mutation, I/O, exceptions, nontermination, etc. So the proof system is not just something that's there for those times when you need it and fades away when you don't.
Compiling and running a possibly incorrect program that seems to work is more rewarding than trying to figure out how exactly it was that your compiler inferred a type different than you intended.
Well certainly soup. And nuts. And everything in between.
Plus washers and ball bearings and my son's head for haircuts. Solids, liquids and gasses need to implement the Bowlable interface. Just to be <type> safe, vacuums should probably implement Bowlable as well.
I've got some classes to write and inheritance to track. Then all that's left is to implement Microwavable, Edible, Spoonable, and Unhealthy. Then I can enjoy my Maruchan Ramen.
Bad things will happen if I put a can of Rustoleum in my Microwave and power it up on high for five minutes. So I'm not saying type safety doesn't matter. Just that it is not always better.
A lack of understanding. People get very upset when you say this, but I have yet to see a single person argue against static typing accurately. Every single argument (oh look, a bunch have been posted in reply to you even) I've seen has been based on exactly this fallacious reasoning:
>When thinking 'static types', does everybody just think C/C++/Java?
Yep. Including the people who write dynamically typed languages even: