- 
                Notifications
    You must be signed in to change notification settings 
- Fork 17
zz note: important dynamic programming patterns
This problem is only partially limitations of static typing itself. It also includes lack of support for meta-programming models and convenient syntax for dynamic data.
For example, back in the egroups days, we used an object-relational-database-mapper called odb.py. It was really just two python meta-classes that abstracted away SQL records and writing SQL statements. The row class used getattr to make it look like the table fields were class fields. This was really friggin convenient.
The static-typed version of this, would be to define the database tables and fields ahead of time, and code-generate the necessary objects to create the fields... I actually love this in concept, but in practice, static languages make this a HUGE PAIN.
What we want to do is (a) define a syntax for database schema (using native datatypes is usually okay, but using macros is not ! ! ! because then there are no useful errors!), (b) use that syntax/type to describe your actual database schema; (c) at compile-time, use that data to generate code that allows typesafe access to your database.
Of course nothing stops you from doing this outside the language, by just writing a program to generate code.. but this is too much cognitive overload, build complexity etc.