News for hackers. Stuff that matters.
Re:LispyScript: A JavaScript With Lispy Syntax And Macros by zem on Friday September 21, 2012 @02:20PM (#4554979)
well, read some ML or Haskell code to see how much more pleasant it looks than the equivalent lisp code. i don't hate parentheses per se; i just think you miss out on a lot when they're your only syntactic construct. (of course, as you point out, you gain a lot too, but that is orthogonal to the basic experience of reading and writing code)
Re:LispyScript: A JavaScript With Lispy Syntax And Macros by wes-exp on Friday September 21, 2012 @04:12PM (#4555518)
Considering the "readable" example:

  (define (factorial n)
    (if (<= n 1)
      1
      (* n (factorial (- n 1)))))

  define factorial(n)
    if {n <= 1}
      1
      {n * factorial{n - 1}}
The first one looks more pleasant to me. The second one looks broken and disorganized. My brain can't parse it as easily without the visual cues provided by the parens.

Of course, it looks better to me because I'm used to lisp. When I first saw lisp I thought the syntax was nuts. Point being - what looks "good" can simply be a matter of what you're used to.

Re:LispyScript: A JavaScript With Lispy Syntax And Macros by zem on Friday September 21, 2012 @06:26PM (#4556217)
pseudo-ml

    factorial n = case
    | n <= 1 -> 1
    | else   -> n * factorial (n - 1)
i can see what's going on at a glance - the syntax and layout of the code are a positive help to understanding it.
Re:LispyScript: A JavaScript With Lispy Syntax And Macros by saurik on Friday September 21, 2012 @06:41PM (#4556272)
You changed the structure, though, to use something much closer to a cond instead of an if. Also, there are variants that require fewer ()s for this.

clisp:

    (defun factorial (n) (cond
        ((<= n 1) 1)
        (T        (* n (factorial (- n 1))))))
Clojure (which I believe is similar to Ark with respect to not using extra parentheses around cond clauses, but I don't have Ark setup to verify that that's actually the case and then to test my demonstration with, so I'm going to do it with Clojure, despite the "weird" [] syntax, as it is orthogonal to the demonstration):

    (defn factorial [n] (cond
        (<= n 1) 1
        :else    (* n (factorial (dec n)))))
Re:LispyScript: A JavaScript With Lispy Syntax And Macros by zem on Friday September 21, 2012 @07:08PM (#4556385)
fair point (i was actually planning on adding a lisp cond by way of contrast, and then forgot). my contention is that the ml cond looks a lot less cluttered than the lisp one, and is therefore more pleasant to read.

the clojure one is nicer since it lacks the visual clutter of the per-case enclosing parens, but it feels slightly wrong from a lisp perspective since i'm now replacing [(a, b), (c, d)] with [a, b, c, d] which has changed the innate structure of the expression.

i actually like the racket convention of using square brackets to distinguish this the best of all the lispy options:

    (defn factorial [n]
      (cond
        [(<= n 1) 1]
        [:else    (* n (factorial (dec n)))]))
Re:LispyScript: A JavaScript With Lispy Syntax And Macros by gcr on Friday September 28, 2012 @03:11PM (#4587267)
For the record, that isn't valid racket code. This is:

  (define (factorial n)
    (cond
     [(<= n 1)  1]
     [else      (* n (factorial (sub1 n)))]))