4 ms·
I used to think this too, but realised that it is not quantitatively different to me whether I spend the time getting something to compile, or spend the time ge
by vidarh 13y ago
I used to think this too, but realised that it is not quantitatively different to me whether I spend the time getting something to compile, or spend the time getting it to execute correctly.
I tend to prefer dynamic typing these days as a lot of what I do feels easier to achieve when I can throw something together to test ideas without thinking about types, and then refine the idea based on actually using a cobbled together prototype, and I feel static typing often got in the way of that.
Especially coupled with Smalltalk style runtime inspection / modification on error (e.g. for Ruby I use "pry" which lets me drop into a shell anywhere in the program and modify or inspect state and then continue execution).
- dllthomas 13y agoI think better guidance and inspection in figuring out type errors would be of huge value in Haskell.
- mietek 13y ago> I used to think this too, but realised that it is not quantitatively different to me whether I spend the time getting something to compile, or spend the time getting it to execute correctly. When do you determine you've gotten it to execute correctly? Achievement Unlocked: You Can Stop Testing Now?
- coldtea 13y agoThat you get the results you expect. How is that any different from Haskell? You think that merely lining up types and having it compile determines that it also "executes correctly"? There are also algorithmic and other mistakes.
- asdasf 13y ago>How is that any different from Haskell? With haskell, the compiler verified tons of possible errors to guarantee against them. With smalltalk, you verified those tons of possible errors yourself. People make mistakes.
- vidarh 13y agoPeople make logic mistakes that'll fly straight past a type checking compiler too. In my experience, most of the type related errors I make in Ruby "fall out" when testing functionality anyway, so that the amounts of tests that actually need to care explicitly about typing tends to be tiny.
- tel 13y agoYou'd be amazed how few do. I'm frequently amazed. Furthermore, when you start getting into advanced types it's amazing how many errors become simply impossible since your types encode the logic your program is intended to represent. For an example, here's a blog article linked elsewhere on this page which talks about encoding various "dimensions" of infinitesimals in an automatic differentiation program that thus eliminate a whole class of value errors. http://conway.rutgers.edu/~ccshan/wiki/blog/posts/Differentiation/ http://conway.rutgers.edu/~ccshan/wiki/blog/posts/Differenti...
- vidarh 13y agoIn my experience the most problematic bugs are the bugs in peoples thinking about the problem. Those bugs are easy to translate into "working code", because they carry through all the way from the top. Then I much rather want a program that is easily malleable, than one where the flawed logic is encoded in the types. If the problem space is known in detail upfront, then sure. But then writing test cases to cover them is just as simple. Not least because if you really want to, writing test cases and type checks to enforce typing is trivial to do in dynamic languages too. In fact there are quite a few examples on how to do advanced type checks on Ruby code. With the level of introspection Ruby does, you can e.g. easily "wrap" every method with detailed enforcement of type invariants. You need to run some functional tests to exercise the code paths to trigger said type checks, but you need functional tests anyway. People don't tend to use those methods because in practice they turn out to rarely capture many interesting errors once you write functional tests anyway.
- tel 13y agoI think it's a genuine weakness of static types that they inhibit prototyping when you first begin. HM type systems tend to be liberal and powerful enough that once you learn them well they're easier to prototype in—but that comes with time. In particular, type-driven-development is wonderful. You can write light, compiler-checked specifications of code you haven't bothered to write yet and see if your logic all typechecks even without implementation. I can run through lots of ideas that way very quickly since the only thing I have to produce is the high-level type skeleton of my program. Then I just go through and implement it all. It's a lot like test driven development except that your executable tests are much more lightweight and carry a strong sense of the logic of your program. If your tests don't hang together, you'll find out eventually. If your types don't hang together, your compiler tells you immediately.