|
What kinds of applications or features/requirements make a good case for the use of a dynamic language like Python or Ruby, instead of a static language like Java or C#? (Aside from apps that require scripting capability, I might say.) |
|
Some thoughts:
|
|
In The Rails Way, Obie Fernandez described a use case that in my opinion is better implemented using a dynamic language. His example involved modifying class instances on the fly. On the database, wherein each table row maps to a class instance, there is a column named "config". This column contains code - methods, etc. - that is eval'd when the row is instantiated. Let me explain with my own example. Note that I haven't used this technique before, but this is how I imagine I'd use the Obie Fernandez technique. Imagine a role-playing game, wherein you control a space ship. Some space ships will have the classic_warp_engine, some may have the warp_nine_engine, and an elite few may be equipped with the uber_secret_stolen_from_the_romulans_warp_engine. Code-wise, they have the same interface: ship.engage_warp_drive(). But the engines behave differently: they activate different animations, and different sound effects. And the beauty here is that the differences between the engines is in the database, not in the code. If you want the uber_secret_romulan_warp_engine to have a 30% chance of blowing up when used, but only for the user named "radamanthus", just change the database row for user radamanthus. No code changes required. Coolness. |
why does this question sound familiar? :P
because we were talking about it last night!