I know that in pure object-oriented languages like Java it usually makes sense to use ORMs like Hibernate. But what would I do when writing a CRUD-type functionality in Clojure or Common LISP?
我知道,在纯面向对象语言(如Java)中,使用orm(如Hibernate)通常是有意义的。但是,在Clojure或Common LISP中编写crud类型功能时,我该怎么做呢?
Passing around SQL as the first-order functions? But isn't having SQL in HTML-generating code very ugly?
传递SQL作为一阶函数?但是在html生成代码中使用SQL不是很难看吗?
Thanks,
谢谢,
Olek
Olek
3 个解决方案
#1
3
Common Lisp is not a self-consciously FP language. Clojure can just use Hibernate.
Common Lisp不是一种自觉的FP语言。Clojure可以使用Hibernate。
For Common Lisp: databases. Here's a persistent object one. And here is the first part of a tutorial that uses it with Hunchentoot, a CL webserver and dynamic webpage toolkit. SQL in CL can look like this (which looks longer than it really is, because the SQL is horizontally formatted and the CL isn't). And if you like, this guy is working on a web framework (using CLSQL and Elephant, already linked-to) that aims at tersity, with an eye on the arc challenge.
Common Lisp:数据库。这是一个持久对象。下面是教程的第一部分,该教程与clwebserver和动态网页工具包Hunchentoot一起使用。CL中的SQL看起来是这样的(看起来比实际长,因为SQL是水平格式的,而CL不是)。如果你愿意,这个人正在开发一个web框架(使用CLSQL和Elephant,已经链接到),目标是tersity,关注arc的挑战。
EDIT: a recent answer expands on this.
编辑:最近的答案对此进行了扩展。
#2
1
Ur/Web may be interesting, although it's not lisp based: http://plv.csail.mit.edu/ur/
Ur/Web可能很有趣,尽管它不是基于lisp的:http://plv.csail.mit.edu/ur/
As quoted from their site:
从他们的网站引用:
Ur/Web supports construction of dynamic web applications backed by SQL databases. The signature of the standard library is such that well-typed Ur/Web programs "don't go wrong" in a very broad sense. Not only do they not crash during particular page generations, but they also may not:
Ur/Web支持构建由SQL数据库支持的动态Web应用程序。标准库的签名是这样的:在非常广泛的意义上,输入良好的Ur/Web程序“不会出错”。它们不仅不会在特定的页代中崩溃,而且可能不会:
- Suffer from any kinds of code-injection attacks
- 遭受任何类型的代码注入攻击
- Return invalid HTML
- 返回无效的HTML
- Contain dead intra-application links
- 包含应用程序之间死应用程序内部进行链接
- Have mismatches between HTML forms and the fields expected by their handlers
- HTML表单和它们的处理程序期望的字段之间是否存在不匹配
- Include client-side code that makes incorrect assumptions about the "AJAX"-style services that the remote web server provides
- 包含对远程web服务器提供的“AJAX”样式服务做出错误假设的客户端代码
- Attempt invalid SQL queries
- 尝试无效的SQL查询
- Use improper marshaling or unmarshaling in communication with SQL databases or between browsers and web servers
- 在与SQL数据库或浏览器和web服务器之间的通信中使用不恰当的封送或解封。
#1
3
Common Lisp is not a self-consciously FP language. Clojure can just use Hibernate.
Common Lisp不是一种自觉的FP语言。Clojure可以使用Hibernate。
For Common Lisp: databases. Here's a persistent object one. And here is the first part of a tutorial that uses it with Hunchentoot, a CL webserver and dynamic webpage toolkit. SQL in CL can look like this (which looks longer than it really is, because the SQL is horizontally formatted and the CL isn't). And if you like, this guy is working on a web framework (using CLSQL and Elephant, already linked-to) that aims at tersity, with an eye on the arc challenge.
Common Lisp:数据库。这是一个持久对象。下面是教程的第一部分,该教程与clwebserver和动态网页工具包Hunchentoot一起使用。CL中的SQL看起来是这样的(看起来比实际长,因为SQL是水平格式的,而CL不是)。如果你愿意,这个人正在开发一个web框架(使用CLSQL和Elephant,已经链接到),目标是tersity,关注arc的挑战。
EDIT: a recent answer expands on this.
编辑:最近的答案对此进行了扩展。
#2
1
Ur/Web may be interesting, although it's not lisp based: http://plv.csail.mit.edu/ur/
Ur/Web可能很有趣,尽管它不是基于lisp的:http://plv.csail.mit.edu/ur/
As quoted from their site:
从他们的网站引用:
Ur/Web supports construction of dynamic web applications backed by SQL databases. The signature of the standard library is such that well-typed Ur/Web programs "don't go wrong" in a very broad sense. Not only do they not crash during particular page generations, but they also may not:
Ur/Web支持构建由SQL数据库支持的动态Web应用程序。标准库的签名是这样的:在非常广泛的意义上,输入良好的Ur/Web程序“不会出错”。它们不仅不会在特定的页代中崩溃,而且可能不会:
- Suffer from any kinds of code-injection attacks
- 遭受任何类型的代码注入攻击
- Return invalid HTML
- 返回无效的HTML
- Contain dead intra-application links
- 包含应用程序之间死应用程序内部进行链接
- Have mismatches between HTML forms and the fields expected by their handlers
- HTML表单和它们的处理程序期望的字段之间是否存在不匹配
- Include client-side code that makes incorrect assumptions about the "AJAX"-style services that the remote web server provides
- 包含对远程web服务器提供的“AJAX”样式服务做出错误假设的客户端代码
- Attempt invalid SQL queries
- 尝试无效的SQL查询
- Use improper marshaling or unmarshaling in communication with SQL databases or between browsers and web servers
- 在与SQL数据库或浏览器和web服务器之间的通信中使用不恰当的封送或解封。