A few months back I started trying to design a programming language. Then I discovered Python, and realised it was far more useful than anything I was likley to come up with. Then I discovered C#, which does a lot of things better than Python, but at the same time sacrifices a lot of the things that make Python so fun to program with.
It would be an interesting task to write a preprocessor to 'extend' the C# language to let you do stuff like list comprehensions, or quick declaration of dictionaries and arrays.
Wouldn't it be cool if you could say something like:
Hashtable Foo = { "one": 1, "two": "two", "three": 3.0, "now": dateTime.Now };
ArrayList bar = [ 1, 2, 3 ];
ArrayList baz = [ d.Year foreach DateTime d in listOfDates ];
These would generate something like:
Hashtable foo = new Hashtable();
foo[ "one" ] = one;
foo[ "two" ] = two;
foo[ threeKey ] = three;
foo[ "now" ] = DateTime.Now;
... and ...
ArrayList bar = new ArrayList();
bar.Add( 1 );
bar.Add( 2 );
bar.Add( 3 );
ArrayList baz = new ArrayList();
foreach( DateTime d in listOfDates )
{
baz.Add( d.Year );
}
That would probably halve the amount of code that I write in C#, bringing the overhead down to the level of Python. It will seriously kill IntelliSense though, and IntelliSense is the main reason I like C#. Hmm. Is it possible to extend the IDE to know about things like this?
In related news, my C# data object wrapper generator is working (generating lots of C# code which compiles and seems to go fine) and just needs the addition of a few 'isDirty' flags so Commit() knows what to send back to the database. I'll release the source in a few days, probably.
It's making my database code look much cleaner. I now only need to specify my DB structure once (in XML), run MakeWrappers.py, and suddenly I've got all my database fields from my queries into tblFoo available as properties of a FooRow object.
11:26:16 AM
|