In my opinion, the difference between the static and dynamic typing comes down to the style of coding. Although there is structural types in Scala, most of the time the programmer is thinking in terms of the type of the object including cool gadgets like trait. On the other hand, I think Python/Javascript/Ruby programmers think in terms of prototype of the object (list of methods and properties), which is slightly different from types.
For example, suppose there's a family of classes called Vehicle
whose subclasses include Plane
, Train
, and Automobile
; and another family of classes called Animal
whose subclasses include Cat
, Dog
, and Horse
. A Scala programmer would probably create a trait called Transportation
or something which has
def ride: SomeResult
def ride(rider: Someone): SomeResult
as a member, so she can handle both Train
and Horse
as a means of transportation. A Python programmer would just pass the train object without additional code. At the run time the language figures out that the object supports ride
.
The fact that the method invocations are resolved at the runtime allows languages like Python and Ruby to have libraries that redefines the meaning of properties or methods. A good example of that is O/R mapping or XML data binding, in which undefined property name is interpreted to be the field name in a table/XML type. I think this is what people mean by "flexibility."
In my very limited experience of using dynamic languages, I think it's faster coding in them as long as you don't make mistakes. And probably as you or your coworkers get good at coding in dynamic language, they would make less mistakes or start writing more unit tests (good luck). In my limited experience, it took me very long to find simple errors in dynamic languages that Scala can catch in a second. Also having all types at compile time makes refactoring easier.