196 points · by jamslater · 10y ago · 54 comments
Doesn't mean they are.
But yes, I agree with the core of your comment, though I usually harken to XML for a more visceral reaction. First there was a self-formatted schema and tooling to verify it. Then an RPC specification. Followed by parsers built to fit special needs (such as comments). Inspectors, transformers, pretty printers, incremental parsers, bash integrations, namespaces...
Programming history is definitely cyclical.
But this isn't to say that new languages should never be invented. Just that there's a lot more work involved than anyone would expect.
In other words: once you decide you don't want to program in Lisp, Lisp's way of representing data stops being a useful syntax for representing your data. Undervaluing this realization (and worse, reacting smugly when interacting with people who don't share your undervaluing of this) is a big part of the gulf between Lispers and the rest of the world.
It's close to the Lisps, Scheme, Racket, Clojure, and many others.
You are correct that the popularity of Ruby, Python, and JavaScript has eclipsed the popularity of these languages, and so the popularity of JSON has eclipsed that of s-expressions.
Even if you code in C++, you can find Lisp's surface syntax simple enough to read and write. Now, if your language already defines a "read" function, sure, go with it.
The mere fact that a solution exists for a problem does not mean it is the best possible solution for all possible people in all possible cases, nor that there can never be a reason to develop or prefer another solution.
There are reasons JSON is the lingua franca of modern API interaction and LISP is not.
'(
(first-name john)
(last-name smith)
(age 23)
(parents jane jim)
)
{
"first name": "john",
"last name": "smith",
"age": 23,
"parents": ["jim", "jane"]
} '(
(first-name "john")
(last-name "smith")
(age 23)
(parents ("jane" "jim"))
)
Of course, for a pure set of such simply formatted data (hashes, lists, strings, numbers), you could use almost any data serialization format. S-Exs don't really offer anything special here that can't also be done in XML, MessagePack, SQL, protobuff, bencode, thrift, or any of a dozen other serialization formats.Then again, JSON doesn't really bring much special to the table in this case either (other than having an encoder built into most Javascript intrepreters).
Don't rely on first and last names. Also, the age keeps changing, store a date (unless the age is what the user inputs, and is later converted to a date).
(#1=(person ...)
#2=(person ...)
(person
:names ("John Smith")
:date-of-birth @1993-10-04T05:03:00.000000+01:00
:parents (#1# #2#)))Many people like LISP.
require 'json'
require 'open-uri'
data = JSON.load(open("https://api.github.com/users/Dorian"))
data.keys
data.first
data["public_repos"]
etc.I used to do that in Python, but it is a pain. jq is great for these things, and jid seems to be also.
It's true it's a new lang, and although simple, I often have to look things up.
It might be nice to have a jq REPL, so needn't quote, and easier to keep state around.
For example consider this.
echo '{"users":[{"name":"s1","id":1},{"name":"s2","id":2}]}'|jid
I can query users[0].id or users[1].id. How can I get all the ids? I tried users[*].id which didn’t work.In Clojure I use specter [1] for this which is able to handle wildcards using ALL.
E.g. users[].id
output:
name:s1,id:1
name:s2,id:2Why not?