TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Why is there no database with a functional query language?

5 点作者 fragile_frogs大约 2 年前
I have been asking this myself for a while now, I generally do enjoy writing SQL, but I also get the feeling that it&#x27;s not suitable for building applications.<p>So why is there no &quot;functional&quot; query language? Something like Haskell, but for databases. You would get the benefits of a declarative model, composeability and type-safety.<p>I am currently using sqlx[1] and it&#x27;s great in terms of type-safety, but you can&#x27;t compose queries. I don&#x27;t like to use ORM&#x27;s, they are usually good for simple things, but hard things are impossible and you have to use&#x2F;understand SQL anyways.<p>[1] https:&#x2F;&#x2F;github.com&#x2F;launchbadge&#x2F;sqlx

4 条评论

PaulHoule大约 2 年前
What about <a href="https:&#x2F;&#x2F;docs.datomic.com&#x2F;on-prem&#x2F;query&#x2F;query.html" rel="nofollow">https:&#x2F;&#x2F;docs.datomic.com&#x2F;on-prem&#x2F;query&#x2F;query.html</a><p>and more generally<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Datalog" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Datalog</a> ?<p>(Around 2010 I was frustrated with the state of OWL&#x2F;RDF&#x2F;SPARQL and all that and was curious about Datalog and found it was truly obscure and hard to find good reading about, interest in Datalog has exploded since then.)<p>Note SQL has subqueries and in some sense is &quot;composable&quot;, there are even some advanced features like<p><a href="https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;current&#x2F;queries-with.html" rel="nofollow">https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;current&#x2F;queries-with.html</a><p>it is ugly as hell and has problems with consistently using unique names (like the &quot;hygenic macro&quot; problem) but you can write crazy-complicated queries in SQL.
surprisetalk大约 2 年前
You might be interested in Q, which is the query language for kdb:<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Q_(programming_language_from_Kx_Systems)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Q_(programming_language_from_K...</a>
eimrine大约 2 年前
It may be great to have a functional language which will write you an SQL query, but I have a hard time to image how else are you going to use a language for describing immutable data structures to edit mutable things.<p>Maybe you will be interested in Erlang as a functional way to manage something as mutable as network stream.<p>Maybe you need to learn about array programming languages (APL, J, K). They say about SQL as &quot;to suck data throw a thin pipe&quot; after APL experience.<p>Maybe you will like dealing with pure AST (I&#x27;m talking about Lisp) with no databases at all.
nhgiang大约 2 年前
Based on your comment about composability, I&#x27;m assuming that&#x27;s what you actually meant by &quot;functional&quot;? Perhaps you want maps &amp; folds over queries?
评论 #35628030 未加载