Value Safety

While listening to my colleague Niclas Nilsson's presentation called "Dynamic Languages for Statically Typed Minds" last week at PBT Group in Cape Town it occurred to me that what Dynamic Languages lack in type safety, they gain in *value* safety.

Niclas showed that in static typed languages such as Java and C#, if you instantiate an int with 100000000 (one hundred millions) it's still an int. If you then multiply that int by itself and store it in the same int, it's still an int, but the value is 1874919424. Doesn't look right, does it?

If you do the same in Ruby, instantiate a member with 100_000_000, it's a FixNum. If you multiply that FixNum by itself, it becomes a BigNum. But the value is 10000000000000000 which seems to be more correct than in the Java/C# case. Type safety? No, but Value safety!