Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I personally prefer Nix greatly it's just JSON with functions basically. I just find Guile expressions totally unreadable with the brackets everywhere.


Genuine question, not trying to create or sustain a debate: are there more brackets in scheme than in json? I don't use json much, but the example I find in the "Syntax" section of the Wikipedia article on json [0], looks almost identical to how I'd structure the same data in Scheme, though with more quotation marks [1]. Is this just a bad example?

[0] - https://en.wikipedia.org/wiki/JSON#Syntax

[1] - Edit: more quotation marks, commas, and colons


It's about specialization. In JSON brackets have dedicated meaning. In scheme it's () galore. And () doesn't give me any meaning of what's actually there. Not that JSON or the Nix language is perfect, or even good, but this point makes it a lot better then a Lisp for me.

Essentially quickly scanning over lisp code doesn't give me any inclination about the structure at all, which I think is very important. I admit I haven't written a ton of lisp so maybe that's the problem.


I read you. I think Guile's native syntax for keywords, though more explicit, probably makes it worse. I imagine this would be clearer for a non-Lisper? Valid CL, but not Guile without a configuration change.

  '(:firstName "John"
    :lastName "Smith"
    :isAlive t
    :age 27
    :address (:streetAdddress "21 2nd Street"
              :city "New York"
              :state "NY"
              :postalCode "10021-3100")
    :phoneNumbers ((:type "home"
                    :number "212 555-1234")
                   (:type "office"
                    :number "646 555 4597"))
    :children ("Catherine"
               "Thomas"
               "Trevor")
    :spouse nil)
...or, indented more like Wiki's JSON example:

  '(
    :firstName "John"
    :lastName "Smith"
    :isAlive t
    :age 27
    :address (
      :streetAdddress "21 2nd Street"
      :city "New York"
      :state "NY"
      :postalCode "10021-3100"
    )
    :phoneNumbers (
      (
       :type "home"
       :number "212 555-1234"
      )
      (
       :type "office"
       :number "646 555 4597"
      )
    )  
    :children (
      "Catherine"
      "Thomas"
      "Trevor"
    )
    :spouse nil
   )


The core issue that you can't escape is that Scheme creates a lot of ambiguity between data and code, since both use the same syntax. There is nothing wrong with using plain s-expressions for data, quite the opposite, I find them quite nice to look at, no need for keywords here:

    (person
     (firstName "John")
     (lastName "Smith")
     (isAlive t)
     (age 27)
     (address
      (streetAdddress "21 2nd Street")
      (city "New York")
      (state "NY")
      (postalCode "10021-3100")
      )
    )
But that's not something you can put in a Scheme file directly, you have to quote it and then you have to use quasiquotes, macros or other hacks to get parts of that data structure executable. It's also not even the proper way to do a name/value pairs in Scheme, which would be the alist of the form ((name . value) ...).

In Nix you do not have any of those ambiguities {} is a set, [] is a list, 5+5 is an expression, a = 5; is an assignment. And you can freely mix them without all that quoting, so it's { a = 5 + 5; }, not `((a . ,(+ 5 5))) or (list (cons 'a (+ 5 5)))


The difference is that name/value pairs have a dedicated syntax in JSON and Nix, in Scheme everything is (), doesn't matter if it's a function call, list, assignment, macro or whatever. Makes it very hard to understand what is going on at first glance. Worse yet, the normal Scheme syntax is so ugly that people constantly write macros to hide it. Take this package definition in Guix:

  (package
    ...
    (build-system gnu-build-system)
    (arguments '(#:configure-flags '("--enable-silent-rules")))
    (inputs (list gawk))
Looks like a list with name/value pairs, but it's not, that's just the (package)-macro making that thing behave that way. And it's all quite arbitrary, '#:configure-flags' there is a name/value list too, but constructed completely differently. And the next line with (inputs) constructs a list with (list) instead of with a ' quote, as otherwise the list would contain the symbol 'gawk' instead of the value.

Scheme is basically: "Here is the a bunch of Lego, go build yourself a programming language". Other language have syntax that forces at least a minimum of consistency.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: