Making LISPs manageable
Posted
by
Andrea
on Programmers
See other posts from Programmers
or by Andrea
Published on 2012-03-15T11:06:20Z
Indexed on
2012/03/19
10:16 UTC
Read the original article
Hit count: 308
I am trying to learn Clojure, which seems a good candidate for a successful LISP. I have no problem with the concepts, but now I would like to start actually doing something.
Here it comes my problem. As I mainly do web stuff, I have been looking into existing frameworks, database libraries, templating libraries and so on. Often these libraries are heavily based on macros.
Now, I like very much the possibility of writing macros to get a simpler syntax than it would be possible otherwise. But it definitely adds another layer of complexity. Let me take an example of a migration in Lobos from a blog post:
(defmigration add-posts-table
(up [] (create clogdb
(table :posts (integer :id :primary-key )
(varchar :title 250)
(text :content )
(boolean :status (default false))
(timestamp :created (default (now)))
(timestamp :published )
(integer :author [:refer :authors :id] :not-null))))
(down [] (drop (table :posts ))))
It is very readable indeed. But it is hard to recognize what the structure is. What does the function timestamp
return? Or is it a macro?
Having all this freedom of writing my own syntax means that I have to learn other people's syntax for every library I want to use.
How can I learn to use these components effectively? Am I supposed to learn each small DSL as a black box?
© Programmers or respective owner