3 ms·
Look at it the other way. In fact, you can do a blind test. Try writing in a strongly, (well[0]) dynamically-typed language for a while, and count the number o
by brandonbloom 13y ago
Look at it the other way. In fact, you can do a blind test. Try writing in a strongly, (well[0]) dynamically-typed language for a while, and count the number of times your code fails at the REPL due to a type error.
Each of those would likely have been a compile time error in a language like Haskell.
Just earlier today, I was writing some C++ (I normally write Clojure) and I was bitten by this. I'm used to evaluating code in the REPL as I work, telling me up front when I try to concatenate a string and an integer, or when I misspell a variable name.
Yes, there are other ways around this (and proofreading your code before you write it is a good practice, in addition to tests). But dynamic typing can make development much faster[1].
Even if you claim that you would have caught all of those bugs in a type system (which I simply don't believe - no real-world project has types that are that precise), it's much better to catch bugs at run-time, because (unless you're writing Go) your compiler takes much longer to run than your REPL does to eval.
[0]: I qualify this to rule out Python, which has weak typing as well as mutability issues to complicate things, and JavaScript, which just has a terrible REPL period.
[1]: In some sense this is all a moot point, because any difference in development speed between statically-typed and dynamically-typed languages is dwarfed by one's familiarity with the languages in question. The only real way to test this would be to use a dynamically-typed language that has an optional type system as an external tool, luckily quite a few languages do this in a way that'd be straightforward to do a blind test (Typed Racket, Typed Clojure, Erlang w/ Dialyzer).
- vilhelm_s 13y agoYou can have a REPL in a statically typed language too---Haskell has one.
- brandonbloom 13y agoGHC's REPL wraps all expressions in a giant do-block with an IO monad. It's practically useless without the meta-language of the colon commands. That said, truly modern versions of GHC have deferred type checking for REPL use, which is impressive, useful and, ultimately, a simple emulation of a dynamic language. Never mind that not even Python or Ruby, and especially not JavaScript, provide sensible useful REPLs with sane code reloading semantics. People who shit on crappy type systems turn around and then shit on crappy REPLs in broken dynamic languages. I'd take a statically typed language over a language with a bad REPL any day.
- singingcheese 13y ago> You can have a REPL in a statically typed language too---Haskell has one. And so does Scala...
- nousernamesleft 13y ago>In some sense this is all a moot point, because any difference in development speed between statically-typed and dynamically-typed languages is dwarfed by one's familiarity with the languages in question I dunno, I have 11 years of python experience, and almost a year of haskell experience. I am more productive in python when doing small (<100 lines) scripting type tasks. But I am noticeably more productive in haskell when writing bigger things. Haskell has a relatively crappy web ecosystem, yet I'm still more productive with snap+postgresql-simple+digestive-functors then I have ever been with any python framework (from zope way back in the day to django and flask). Tasks that are more skewed to haskell's strengths like highly concurrent network servers make the difference even more pronounced.
- mercurial 13y ago> Each of those would likely have been a compile time error in a language like Haskell. Why do you consider this a hindrance? Haskell has a lot of issues, but that's really not one of them. You can write a Haskell program and be relatively confident that it's going to work right in a way you simply won't be with, eg, Java. And you don't have to wait until compiling. With ghc-mod and vim/emacs configured, you'll be notified upon saving if you blew up something in the current file. You don't need to run your code in a REPL to find out about it, although GHCi is pretty good. You spend a lot less time figuring out what goes wrong at runtime, although I'll grand you that the tooling is poor enough that you have a bad time doing when it happens. > I qualify this to rule out Python, which has weak typing Excuse me? You rule out Python due to weak typing and mutability but disqualify Javascript due to its REPL? This must be sarcasm. I have no comment about Javascript's REPL (which one? node's?), but Python is most certainly not weakly typed, not in the way "weak typing" is commonly understood. As for mutability, they are comparable (except that Python has at least the good grace to throw an exception at runtime if you attempt to access an attribute which does not exist).
- cryptolect 13y agoI tried Go after a few years of Ruby, and compile-time errors is what annoyed me the most. Bzzt that variable is defined but not in use, fail. Bzzt that function is defined but not used, fail. Bzzt that library is included but not used, fail. Felt like I was getting a rap across the knuckles with each failure as I was trying to learn Go. The try/fail/modify/repeat cycle of REPL-driven-development is what appeals to me. I "get" the value of strongly typed languages, but I'd prefer to opt-in to strictness, rather than have it forced upon me.
- virtualwhys 13y agoInteresting, felt the same way, and then something changed, rather than feeling punished by the type checker, the type checker became my ally, teaching me about my mistakes at compile time. Other than for quick scripts I have no interest in dynamic languages now, fully converted to the Typed side ;-) Ruby and Scala are quite similar in some ways: terse syntax, functional, MOP capable (implicits), mixins (traits), etc., but yes, you have to prove to the type checker that your intentions are correct/sound.
- thesz 13y agoHaskell will give you REPL-driven development and strong typechecking (an optional one in the last haskell compiler). BTW, Go is not that strongly typed. It seems Google engineers don't like strongly typed languages.