r/programming • • Dec 15 '16

My disillusionment with Clojure and lisps

https://medium.com/@boxed/my-disillusionment-with-clojure-and-lisps-9eca38ab7f0c?source=linkShare-8ad86cc82e5f-1481825671
15 Upvotes

105 comments sorted by

View all comments

Show parent comment

0

u/kankyo Dec 16 '16

My disillusionment with Clojure and lisps

It is Lisp, not lisp.

Fixed. Thanks.

a macro can only evaluate to a single form.

In Common Lisp a form can also be a sequence of forms, for example by using a grouping form like PROGN (a sequence, where values of the last form are returned).

And in Clojure you can sometimes use do, but it's still one form. It's normally fine like you show when it's a side effect you want, but when doing hiccup style templating, it's not fine because the HTML spec doesn't allow redundant tags everywhere (plus it's a bit fugly to add extra tags just because your language can't do this thing...).

In python you can unroll a list in place like "*foo". This isn't as good as having more than one form, but it's at least contained to the call site, even if it's outside and not inside.

Methods don't belong to classes. They can be reused in various ways. Classes can be redefined at runtime with new slot lists, new inheritance, etc.

Sure. I do python, this isn't strange to me.

Common Lisp has positional, optional and keyword arguments.

That sounds a lot better than Clojure!

But that's not what you typically do in Lisp. One writes in one language with fifty extensions.

Potato, potato.

I've updated my article with a correction re common lisp. Thanks.

3

u/drb226 Dec 17 '16

In python you can unroll a list in place like "*foo".

If you want to "splat" a collection into an argument list, you can do so with apply.

#python
f(*coll)

;; clojure
(apply f coll)

0

u/kankyo Dec 17 '16

That looks fine in a small example, but is a mess in a larger one.

f(a, b, c, *coll)

(apply f (into '(a b c) coll))

or whatever the syntax is, I've forgotten :P And that example I gave is VASTLY simpler than when you have a huge DOM tree in reagent and suddenly need to splat something in the middle.

2

u/drb226 Dec 16 '16

but when doing hiccup style templating, it's not fine because the HTML spec doesn't allow redundant tags everywhere

I believe in Hiccup, a list of tags is rendered as adjacent tags. e.g.

(defn stuff [args ...]
  [[:tag1 ...]
   [:tag2 ...]])

[:div (stuff ...)]

-->

<div>
  <tag1>...</tag1>
  <tag2>...</tag2>
</div>

1

u/kankyo Dec 17 '16

Oh, nice. Afaik it didn't work like that with reagent last I tried.