[IronPython] [python] Re: Object DBs - Zope/Plone vs LINQ?
dinov at exchange.microsoft.com
Sat Sep 29 01:39:46 CEST 2007
We'll see if we can get implicit typing in there from section B ;)
But seriously, from section B, we are likely to support the extension methods. In fact we support a form of extension methods today which is how all the Python methods show up on the .NET types today. And we support it in another form in bringing back the normal .NET methods when you import clr. Unfortunately we still have some more work to do to converge to the LINQ model (we're very type-based in doing extensions, LINQ is more method base - at least the levels where the attributes are applied).
The expression trees are particularly interesting. For those who have been paying close attention to the DLR source code you may have noticed that DLR ASTs are remarkably similar to LINQ expression trees - they're pretty much a superset (with enough differences to make converging them non-trivial, but we're trying). I don't know exactly what that means for LINQ support off the top of my head, but hopefully it makes it easier in some form.
Finally on A I'll just point out that list comprehensions and generator comprehensions map nicely onto LINQ as well. LINQ supports both a "grab all my results now" mode as well as a "give me an iterable that processes results one at a time".
If you put all of that together we might end up with a decent LINQ story by simply using the language features we already have. But there's a lot of tricky parts in there such as do we need to carry our AST around, how do we know when we're calling out to something expecting an Expression tree or Func<T*> delegate (no types to help us here like in C#), how do we translate method calls in the list/generator comprehensions, etc... And I think it's this last bit we haven't figured out (unless Jim or Martin have it all figured out in their heads :) ).
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: Friday, September 28, 2007 4:17 PM
To: Discussion of IronPython
Subject: Re: [IronPython] [python] Re: Object DBs - Zope/Plone vs LINQ?
Keith J. Farmer wrote:
> There are various degrees to which a language can support LINQ, in decreasing sweetness:
> A: adopt new, first-class syntax in the language to easily construct LINQ queries
> B: stop short of syntax, but include the features underlying LINQ: extension methods, expression trees, anonymous types, type inference, implicit typing
> C: allow access to the .NET libraries which implement the operations the LINQ pattern
I think there would be howls of protest from the Python community if the
IP team opted for A - but it would be nice to see some of the B level
features in IronPython. Maybe these could be provided at the DLR level
to support all of the DLR languages?
> C#3, VB9, and a few others are at the fully-LINQ-enabled "A" level. They've modified the language to make access to the features listed in B and C transparent
> Unless Dino, Martin, & co have been hiding things from me, IronPython is still at the "C" level. Because it can access the .NET libraries, a programmer can manually do everything necessary for LINQ: make calls to the static methods on the new Enumerable and Queryable classes. Expression trees still need to be constructed manually to make LINQ to SQL work, but it's still doable, and helper methods could make things work a little smoother. You still get the same effect: you don't have to know SQL, you don't have to change your query language when you switch databases (TSQL != PL/SQL != MySQL != Matisse).
> Adding just the B-level of features would make IP very, very sweet.
> Incidentally, it should be pointed out for the record that LINQ isn't just databases. It's really any generalized data store: objects, RDBMS, and XML are just 3 featured applications of the pattern -- there are also web services, LDAP, file systems, etc. Also, in LINQ to SQL's case certainly, these are full-fledged queries, not simple CRUD: server-side calculated columns, arbitrary projections, paging operations, etc are translated into actual SQL and sent to the server.
> -- Keith J. Farmer [MSFT: LINQ to SQL]
> From: users-bounces at lists.ironpython.com on behalf of Matt Clinton
> Sent: Fri 9/28/2007 3:42 PM
> To: Discussion of IronPython
> Subject: [IronPython] Object DBs - Zope/Plone vs LINQ?
> I was recently reading the July issue of Visual Studio mag, and the
> opening few paragraphs of their article on "Layer Data Access..."
> reminded me strongly of the problem solved by Zope/Plone in CPython
> land: databases with linked objects, rather than tabled varchars, bytes,
> They go on to talk about how LINQ will allow storage/retrieval (CRUD) of
> CLR objects through a SQL-like syntax.
> Will IronPython have access to both these approaches?
> If so, there could be very terse & clean crossovers through it.
> Any reflections on when to use which?
> Food for thought,
> -- Matt
> Users mailing list
> Users at lists.ironpython.com
> Users mailing list
> Users at lists.ironpython.com
Users mailing list
Users at lists.ironpython.com
More information about the Ironpython-users