Hacker News new | ask | show | jobs
by bad_user 5788 days ago
My problem is that the code linked in the article looks ugly as hell. Even the micro-language created.

Compare this ...

    (filter (and (< :table1/a 5) (= :table1/b "x")) (collect :table1))
To this ...

    from row in table1
    where row.a < 5 and row.b == "x"
Also, compare this ...

    (collect :projects :invoices [:projects/id :projects/name 
           (as :inv_id :invoices/id) :invoices/date])
To this ...

    from proj in projects
    from inv in invoices
    select { proj.id, proj.name, inv_id => inv.id, inv.date }
For me the ideal programming language would be one readable by humans.
3 comments

Maybe we can get it a little more Clojure-ish:

    (dosql [a :table1/a b :table1/b]
      (filter (and (< a 5) (= b "x"))))
Makes the filter part more readable (to a Lisper), and introduces variable scope in a more idiomatic manner. The macro needs to take care of the :table1/a expansion and substitution within its scope. dosql might already be taken but not important for my point, I think.

Maybe you still don't like this, but I think it reads a little better for someone used to Clojure.

But can the sql be made to work w/ a non-sql storage engine? The lisp code facilitates this abstraction while raw sql is just that.
That's not sql ... that's Linq from .NET. You can query with it whatever you want: in-memory data-structures, DB, Xml, LDAP.

Here's a MongoDB provider that has basic Linq support: http://github.com/samus/mongodb-csharp

Of course, the actual syntax of LINQ is baked in the compiler's rules, and you can't invent new syntax in the way LISP lets you to.

But why is that have to be the case? There's nothing stopping a compiler from being extensible, other than hard-work. I played with Boo for a month ... it comes very close to that. Perl6 also lets you do it, but it remains to be seen how good it is.

touche, I should have studied your examples longer as the second one it is clearly not straight sql. I have always been a bit jealous of linq and I agree there should be a language which allows the compiler to be extended. Smalltalk allows this to some degree particularly the research done by SCG: http://scg.unibe.ch/research/helvetia/examples
But are you complaining about Lisp syntax in general, or this DSL implemented using Lisp macros in particular?
Both I think.

I'd like a language that lets me define syntax that's readable by kids with basic english/math skills.

From the languages I've tried, Boo came closest to that, but the error messages it throws are awful, and development seems to have stagnated. Maybe Perl6 will be that language, who knows?

Haskell also seems to have a macro-system, but I wouldn't call Haskell a language readable by kids.

Two points: if your complaint is about Lisp in general, then it's not really relevant to the post. Some people can read Lisp syntax just fine. So, for them, the DSL is readable.

Second point is that since the beginners know nothing, they don't have preconceived notions of what programs should look like. Having just taught an intro to programming course, I am very aware that even the semantics of something like "i = 2" can be misunderstood by beginners. One advantage of the Lisp syntax for beginners is that it's extremely simple and consistent.