|
Re: Getting Dynamic Productivity in a Static Language
|
Posted: Apr 2, 2009 8:16 AM
|
|
> >> Yes, in the video I talk also about the productivity > >> advantages of static languages. But don't forget there > > >> are some other advantages of dynamic languages too that > > >> I didn't cover. The three main missing ones to me are: > > > >> 1. Conceptual simplicity. The language itself is easier > > >> to understand when you have a model of objects send > >> each other messages, and at runtime if the message is > >> handled it works, else you get an exception. That's the > > >> case in dynamic languages. In static languages, you > >> have more complexity in terms of a type system to > >> understand. > > I'm not sure there is any meat in that statement. If the > static language makes intelligent use of type inference, > the type system is not in the way. In fact the type system > actually *helps*. Consider a method declaration. Without > types on the parameters how do you know what's ok to pass > without having knowledge of the implementation? A type can > be the best form of documentation. And I won't get into > the *huge* benefit of code completion, refactoring, etc. > etc. > I had quite a bit of push back on this one from several people, so it sent me back to the thinking board. But I think that people's objections were mostly talking about how their lives could be complicated by dynamic typing. I really wasn't trying to say that your life would be simpler if you use a dynamic language, but more that the methods as messages model is simpler to understand than static typing, because with static typing you end up eventually needing to talk about type parameters and variance. To be specific, it is easier to understand Python's dynamic method invocation model than it is to understand Scala's type system. There are far fewer moving parts. But in exchange certain kinds of refactorings can be simpler in Scala than Python, figuring out the types of method parameters can be simpler in Scala than Python, and so on. So even though dynamic typing may complicate your life in certain ways compared to static typing, I think you have to still give dynamic typing credit for being easier to learn and understand than a static type system.
So that's one thing, but there was another aspect to this that I didn't bring up. I've had many conversations with dynamic typing enthusiasts whose opinions I highly respect, and one theme I've heard is that they don't like the feeling of "fighting the compiler." To give a specific example, I had a conversation with "Smalltalk" Dave Thomas. This is not Pragmatic Dave Thomas, though he's also a "dynamic" personality whose opinion I respect. PragDave is more a Ruby fan, and Smalltalk Dave is, you guessed it, a Smalltalk fan. He led the team that wrote Visual Age for Java in Smalltalk at IBM, and he said they were highly productive using Smalltalk to implement a Java IDE. But that Sun "wouldn't give them the coffee cup," so they had to do something in Java, and that became Eclipse.
So that was the history, and so I was asking him what it was that made him feel so productive in Smalltalk, and one of the things he said is he didn't have to spend time thinking about types. The implication being that you could move faster with this simpler model of message passing. I absorbed this and as I was working on ScalaTest later, I paid attention and tried to notice when I was spending time on types that probably wouldn't be necessary if I were programming in a dynamic language, and it did happen from time to time.
Back in my conversation with Dave, I said that a lot of static typing folks have an attitude that dynamic typing is good for prototypes, because when you're trying to explore,... I was going to say when you're trying to explore, you don't want to get slowed down or stuck trying to fix a type error that may be tangential to what you're trying to accomplish at the moment. But he interrupted me at that point and said, No when you're trying to think!
Some of the thinking about types I had to do when doing ScalaTest I felt was an investment on my part that will make life simpler for users of ScalaTest. But some of it did seem rather tangential to what I was really trying to accomplish. I feel like I'm fighting the compiler far less in Scala than Java, but sometimes I get the feeling that I'm experiencing in Scala those speed bumps that these dynamic guys complain about.
So that's the other aspect of "conceptual simplicity." One aspect is, easier to learn and understand the language. But the other is, easier to build stuff without hitting speed bumps all the time. I'm curious what other people's opinions are of the speed bump complaint.
|
|