3 ms·
Just use a dictionary or hashtable.
by tedunangst 14y ago
Just use a dictionary or hashtable.
- icebraining 14y agoBut then, what have you really gained? A more cumbersome syntax? Because that's still unverifiable by the compiler.
- tedunangst 14y agoThat's kind of my point.
- qznc 14y ago... of which type? Map<String,Object>? Then you have to use casts to convert Object to Integer for example. If static typing would be good enough, you would not need casts. A cast basically says: "Hey compiler forget about type checking, just believe me that this thing has that type."
- tedunangst 14y agoDynamic typing basically says "Hey compiler forget about type checking, just believe me that this thing has that type."
- qznc 14y agoA dynamically typed language can still be strongly typed. For example, Python will give you an exception on a type error, where C/C++ could wreck havoc in your memory.
- tedunangst 14y agoUse dynamic_cast. Or java. Or c#.
- gambler 14y agoA hashtable doesn't have methods. In a dynamically typed language, I can generate object methods based on the data currently available in the database (either columns or even row content) and take advantage of all the language's syntactic features while doing that. In respect to any language, the database is inherently dynamic, because it doesn't share your type system and the schema can be redefined at any point after compilation of your code. A statically typed language doesn't magically change that. The best you can do is to write some classes in advance and then hope nothing gets out of sync. So, to put it in simpler terms, some things are inherently dynamic, and dynamic languages make working with them easier.