To view parent comment, click here.
To read all comments associated with this story, please click here.
Regarding the "flexibility" of numbers. Likely, it has nothing to do with flexibility in number types, but rather the rebinding I alluded to earlier.
As for the utility of dynamic typing --- do you see the utility in OOP? Because dynamic typing is just an extension of OO's polymorphism all the way down to the core of the language.
More generally, dynamic typing is nice because it both allows extensive use of OO programming idioms, and additionally allows for new modes of programming. In Lisp, it allows an evolutionary development model. You start with a simple prototype that does the basic core of what the program should do, then instead of throwing away this prototype, as you would in C, you evolve it into the final product. Statically-typed languages make evolutionary programming unnecessarily complicated. For example, consider the fact that in most programs, much more code passes an object around than actually uses it. In a statically typed language, when the type of that object changes, all the code that passes that object around has to change, even though that code doesn't really care what the type of the object is. In practice, this means that programs in statically typed OOP languages tend to have overly baroque type hierarchies, because its a pain to create new abstractions in existing code.
Let's use an example. Say I'm writing a text editor. In my prototype code, I represent a pointer into the text as an integer offset from the beginning of the buffer. Later, I realize that's not general enough, and want to change it to a full-blown class, encoding a line number and offset in the line. In a statically typed language, changing a basic type like that can be a huge pain, unless you use some fragile "refactoring" editor hack. To avoid that, programmers tend to start with a fully-general class from the beginning. Often, this generality ends up never being needed, and the code's readability suffers as a result. You see this in Java code all the time. In a dynamically-typed language, if you need an integer, you use an integer. If later you need a full class, changing it will be easy.
Actually, boo just rounds the float to an int type.
Anyway, thanks for that summary of the benefits of dynamic typing. In boo refactoring pain is eased dramatically due to many of the variable types being inferenced, however, I can see some of the benefit. I think inferencing is a good trade off.
As for passing an object around without caring what type it is, most OO languages have a root object class. Any object can be abstractly moved about.
I don't usually throw away prototype code, I haven't often needed to - and in the times that I have, its a major architectural issue unrelated to typing.
And no, I don't do the uneccessary class thing. Although I am guilty of making every field a property (accessor methods). I wish .net had unified fields and properties as they are the same syntactically.
I'll look more at dynamic stuff.






Member since:
2005-09-11
Actually, that's legal in boo - numbers are rather flexible.
I do understand the actual difference between inferenced and dynamic, I just don't see what advantage the loss in speed gives you. I just see the disadvantage of reduced error checking.
Perhaps this is just the way I program, but I have never found a situation where dynamic typing would produce a more elegant solution than static typing.