C#'s greatest mistakes
Roman Ivanov
isroman.DEL at ETE.km.ru
Sun Nov 28 13:23:41 PST 2010
On 11/28/2010 1:19 PM, Nick Sabalausky wrote:
> "BLS" <windevguy at hotmail.de> wrote in message
> news:icrqfl$1ado$1 at digitalmars.com...
>> On 27/11/2010 20:53, Roman Ivanov wrote:
>>> On 11/27/2010 2:49 PM, BLS wrote:
>>>> On 27/11/2010 04:27, Andrei Alexandrescu wrote:
>>>>> http://oredev.org/2010/sessions/c-s-greatest-mistakes
>>>>>
>>>>> Andrei
>>>>
>>>> Frankly said, I am a bit nagged by your overoptimistic D view.
>>>> From my point of view it is opportune to encourage people to use D2 for
>>>> real world applications. We (our company) having a 20K+
>>>> customer base are not able (and willing) to use D instead of C#, except
>>>> for tiny in-house projects. why> database, gui, xml, just to name the
>>>> top 3 issues.
>>>
>>> Out of curiosity, what kind of XML support would you need?
>>
>> From Setup storage to WSDL to Restful services. (But it is almost about
>> online ordering of material)
>>>
>>>> So .. What about an "where C# shines and D sucks" article. Let us start
>>>> with LINQ in D, or do you prefer to talk about phobos collections ?
>>>
>>> Is something like LINQ possible in D?
>>
>> I don't think so. (ATM, several people have tried by using string mixins)
>> But I can imagine at least one (imo) smart solution.
>> Enable compiler plug-in's so that you can write ..
>>
>> void ExecSQLQuery()
>> DataTable dt = new DataTable();
>>
>> SQL92{ /*like asm {} */
>> dt = SELECT * FROM Customer WHERE IsPotentialClient = 1;
>> }
>>
>> }
>> //which translates into D code (the D lexer/parser unit calls the D2
>> SQL92 Translator generator which generated this D source)
>>
>> import SQL92
>> dt = db.Select("SELECT * FROM Customer WHERE PotentialClient = 1");
>>
>>
>> This translation feature could be generic.. we can create a translator
>> based on
>> Annotated EBNF In -> Annotated EBNF out
>>
>> In fact I've created a tool (in Java) to translate SQL scripts. Firebird
>> to MSSQL respective PosgreSQL.
>> Hope this gives you an idea.. :)
>> Bjoern
>
> I haven't actually used LINQ, but I've never understood the appeal of it
> versus an object API that gets rid of SQL in user code entirely.
LINQ _is_ an object API. The query-like syntax is just a misfeature.
But it's not _just_ an object API, because it translates statement into
expression trees, which can be analyzed and used to generate different
code or code in a different language.
Let's say you have a list of objects and need to get only the ones whose
name starts with "D". You can express the predicate via lambda
expression: x => x.Name.Length > 0 && x.Name[0] == 'D'. Simple, right?
Here is the problem. You can apply this expression to every object in
the list, but you don't always want to. What if it's a database table
with 10000 records? You don't want to retrieve all those records,
especially if there is already an index. LINQ allows to analyze the
lambda function and generate an appropriate SQL query. At lest that how
I understand it.
More information about the Digitalmars-d
mailing list