Short list with things to finish for D2
Lutger
lutger.blijdestijn at gmail.com
Mon Nov 23 09:34:42 PST 2009
yigal chripun wrote:
> aarti_pl Wrote:
...
>
> There's nothing more hideous than all those frameworks in Java/C++ that
> try to re-enginer SQL into functions, templates, LINQ, whatever. SQL *is*
> a perfectly designed language for its purpose and it doesn't need to be
> redisnged! The only problem with this is the type-safety when embedding
> sql as string in a host language. the solution is two-phased:
I disagree. There are a couple of problems with using Sql strings inside
regular code:
- no help from the IDE whatsoever. Imagine writing your D program in
notepad, then instead of compiling it in advance, you compile it at runtime:
losing all benefit from the static type checking and whatever the IDE offers
you (highlighting and autocomplete). This would be completely absurd yet you
prefer it with sql? Of course you can write queries in a specialized
environment, somewhat better but it also sucks.
- mapping relational data to objects is a sucky, boring, lengthy and error
prone task.
In my experience a simple ORM tool such as Linq-to-Sql makes life so much
easier. RoR has this too, it's a blessing.
Now if you want to do a big part of your logic on the database instead of
simply using it as storage, that may be a different story. (I still think it
sucks though)
> phase a is simple, look at the C# API for postgres (I think). The query is
> one string like: "select * from table where :a > 42", the :name is a place
> holder for the host-language variable, and you call an API to bind those
> :names to variables in a type-safe way. the downside is that it's verbose.
>
> phase b is what Nemerle does with the above - it has an AST macro to wrap
> the above so you can write your query directly and it is checked as
> compile-time.
>
> No operators were abused in implementing this.
I fail to see how this is any different than Linq. Granted, you just
reproduce the SQL language and ignore any mapping to Objects, but other than
that it is just the same but with a different technology. (Linq is not only
about abstracting sql by the way, it does a lot more)
More information about the Digitalmars-d
mailing list