Monday, March 10, 2008

Dynamic typing and the IDE

In further researching dynamic vs. static typing, the obvious question is how can the IDE make you productive, suggest method names, if there is no such thing as an invalid method name at compile time? How can it show you the documentation behind the code, if it has no idea what that method name will actually resolve to?

One way is to analyze all the code that calls the method. Some new languages are doing that to guess the type without you having to spell it out.

But it can't help you create a missing method in the correct class, because it wouldn't know where it is supposed to go.

Dynamic typing is great for scripting, where a script is defined as something that is not large enough to be a problem to erase and recreate when it gets out of hand. In such a context, static typing is overkill.

In a larger project, with many different developers and more limited channels of communication, I'm still looking for how to overcome the problems. So far it seems that people just shrug off the problem as small in practice. I suspect that their practice involves more serious and disciplined programmers than a lot of us have the luxury of working with.

UPDATE: I guess integrating something like this would allow the IDE to understand what is going on. Of course that doesn't exist yet.

I can say from experience that having a method that cannot be safely renamed will cause larger projects to not have their methods renamed, causing the code to age. You might hope that a bad "search and replace" refactoring would get caught by unit tests, but if the search and replace was thorough, then it wouldn't. It would just be impossible to rename the method in a specific context.

No comments: