Just a few months ago I realized that you can hack CoffeeScript's syntax to embed DSLs directly. I wrote up a quick little proof-of-concept for SQL [0], HTML [1], and CSS [2]. Obviously the HTML one is inspired by the React syntax.
I've always hated how easy it is to push SQL bugs into production, since it's so often just a string literal stuck in your code. AFAIC you don't really need the typing help, you just need to know that you didn't forget a damn comma somewhere.
Comments
This is a really awesome library to generate typesafe sql queries right from the C++ source code. Example usage:
If you're writing SQL queries in C++ code check it out!You should show the definition of 'foo'. That's where things get ugly.
things usually get ugly with projection (one class = one select) or class reuse (mapping)
this is code -> sql string -> exec -> code (mapping results)
best approach (ihmo) is using:
sql string -> exec -> results
with type for input/output directly generated sql string (and check for types)
like F# sql type provider ( http://fsprojects.github.io/FSharp.Data.SqlClient/ )
everything typed, but:- without the need to define class for input / output
- without learn a new functions
- easy add database specific syntax
Just a few months ago I realized that you can hack CoffeeScript's syntax to embed DSLs directly. I wrote up a quick little proof-of-concept for SQL [0], HTML [1], and CSS [2]. Obviously the HTML one is inspired by the React syntax.
I've always hated how easy it is to push SQL bugs into production, since it's so often just a string literal stuck in your code. AFAIC you don't really need the typing help, you just need to know that you didn't forget a damn comma somewhere.
[0]: https://github.com/couchand/just-sql
[1]: https://github.com/couchand/just-html
[2]: https://github.com/couchand/just-css
A similar library for Scala: http://squeryl.org/
What has SQL done to deserve this?
Is there a java equivalent?
I wrote something similar a few years ago:
http://GitHub.com/zerorm/zerorm
after a search, I found http://www.querydsl.com/ -- seems reasonable and sound with the sql syntax
Any ORM?