On Sun, 2010-11-28 at 15:57 -0500, Roman Ivanov wrote:
[ . . . ]
> AFAIK, LINQ is _not_ SQL embedded into C# or VB. It's a mechanism that
> allows C# to examine expressions (written in C#, as strange as they
> might look) and translate them to SQL (or whatever).

I have no idea how LINQ is realized but I know what happens in Groovy
(and Python).

> LINQ can take two forms.
> 
> First:
> var query = from s in names
>  where s.Length == 5
>  orderby s
>  select s.ToUpper();
> 
> Second:
> var query = names.where(s => s.Length == 5)
>  .orderby(s => s)
>  .select(s => s.ToUpper());
> 
> They are semantically identical, but I like the second syntax much more,
> because it uses existing language features, works with auto-completion
> and is much more readable in complex cases.

Actually I prefer the former exactly because it is not an attempt to do
a DSL by suffering the constraints of the language parser.

> To support something like that a language needs to have tools for
> introspection of its own code.

Yes, and this is why Groovy, Python, etc. are good at this sort of stuff
and C, C++, Fortran, D, Go, etc., are generally less good at it.
Basically this is one of the benefits of a full meta-object protocol.
Something you really don't want in performance code.

> > 2-Having such an compiler plugin architecture, will enable you f.i to
> > seamless use Go, Lisp whatever  within  D.
> > 
> > 3-Even if these plugins (please note > more than one) are just for SQL,
> > you got database access for free.
> 
> LINQ for databases is a bit overrated. Writing real SQL queries is often
> simpler. LINQ query generator does some optimizations, but it also
> screws up in some cases. LINQ to objects is a different story, because
> it allows for much nicer declarative syntax to do mapping and projections.

The experience in the Groovy/Java community is that using a DSL in
Groovy rather than faffing around with strings and SQL directly, makes
this a lot faster of production, with fewer bugs.  This is anecdotal
evidence only though so it may just be a perception thing rather than a
real effect.

> > 4- I am using such an EBNF driven tool (almost written by me) to
> > translate SQL scripts. // Create a new db from firebird to mssql..
> > including stored procedures, triggers etc.
> > 
> > So sorry Denis, I know what I am talking about.
> > Bjoern
> 

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: rus...@russel.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to