7 ms·
I'm trying to replace SQL by building a language that compiles to SQL. It has first-class functions, nicer syntax, better type-system, introspection, and other
by erezsh 6y ago
I'm trying to replace SQL by building a language that compiles to SQL. It has first-class functions, nicer syntax, better type-system, introspection, and other things you would expect from a modern language. But in the end, you still get SQL's performance, and the ability to use it with dozens of database engines.
- eitland 6y agoYou mean you work on LINQ? Only half joking here.
- erezsh 6y agoLINQ did a tiny step in the right direction. I'm aiming a lot further.
- closed 6y agoHave you seen the R library dplyr? It is a weirdly powerful data analysis tool, that can also produce SQL queries!
- erezsh 6y agoI heard about it but didn't know it can produce SQL. Thanks for the tip!
- yanovskishai 6y agoAs someone who spent handreds of hours writing (and cursing) SQL queries -it definitely sounds compelling.
- erezsh 6y agoJust a tiny teaser, you could write something like Person { country => name } And it will output the following SQL: -- target: postgres SELECT country, array_agg(name) AS name FROM Person GROUP BY country
- derision 6y agoIs this not the same as graphql?
- gavinray 6y agoSort of, GraphQL is just an interface that describes your data models, but you need to implement "resolvers" for each operation that tells the server how to fetch/mutate the queried data. So you might have a GQL type like: type User { name: String age: Int } But you need to implement a query with business logic for fetching this data, and that can be anything (but generally, a DB call). Projects like Hasura kind of blur this line, as it's essentially one big GQL -> SQL JIT compiler in Haskell though.
- default-kramer 6y agoMe too. I'm interested in what you've done. Please share a link if you have anything published. My project is here: https://docs.racket-lang.org/plisqin/index.html https://docs.racket-lang.org/plisqin/index.html I'm days away from a Show HN at this point. If I can pick only one idea that everyone should copy, it's that joins are values, not language constructs.
- manish_gill 6y agoIf this can allow me to write complex SQL (lots of JOINs, Multiple CTEs building on top of each other, Analytic functions etc), then I'm definitely interested. I've created an SQL generation engine in the past and can definitely appreciate how hard the problem is.
- erezsh 6y agoIt already can. I'm a few weeks away from releasing a private alpha, so if you're interested I'll be happy to let you try it in exchange for feedback.
- manish_gill 6y agoI'd love to. Hit me at me@manishgill.com :)
- adamsea 6y agoI don't know if it's exactly what you describe but Hasura compiles GraphQL queries and mutations to SQL (for Postgrs).
- erezsh 6y agoYes, it's a lot like Hasura, but it's a full-fledged query language. GraphQL is a little limited in expression.
- jugg1es 6y agoHow is this different than a heavy-weight ORM like entity framework?
- livre 6y agoWhat I understood is that this like what TypeScript is to JavaScript (or to be more accurate Haxe to the few languages it transpiles to). It's a new language that will transpile to different SQL syntaxes instead of the method chaining approach of your typical ORM (that'll likely also include model abstractions over your tables and maybe also migration managing).
- jugg1es 6y agoyea, I read it the same way, but ORM's like EF let you leverage an existing language to do basically the same thing as this does. Abstraction, data types, etc... I am unsure as to the value of something like that unless it is included with a client application that handles the conversion natively.
- slifin 6y agoIs there a Clojure datalog to SQL compiler out there?
- refset 6y agoThere was a ClojuRU 2019 talk about such a thing: https://youtu.be/Hf57HbRvYhM https://youtu.be/Hf57HbRvYhM
- darksaints 6y agoOh man, I've dreamed about something along these lines too. I'd kill for algebraic data types, including option types instead of weird ternary logic for nulls.