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?
Passing around SQL as the first-order functions? But isn't having SQL in HTML-generating code very ugly?
Thanks,
Olek
Common Lisp is not a self-consciously FP language. Clojure can just use 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.
EDIT: a recent answer expands on this.
Ur/Web may be interesting, although it's not lisp based: 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:
- Suffer from any kinds of code-injection attacks
- Return invalid HTML
- Contain dead intra-application links
- Have mismatches between HTML forms and the fields expected by their handlers
- Include client-side code that makes incorrect assumptions about the "AJAX"-style services that the remote web server provides
- Attempt invalid SQL queries
- Use improper marshaling or unmarshaling in communication with SQL databases or between browsers and web servers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With