I appreciate your time and explanation. I'm really trying to understand the POV here, and I feel like we're veering away from my original confusion, which was around "Try defining data in C. Try extracting data from that data you've defined in C". I'm assuming your statement would be meant to apply to other common languages without s-expressions, but maybe I've misunderstood.
I don't get why Lisp's s-expressions are much better than using arrays/tables in another language, such that they are a justification for using the language. Are they only significantly superior over a language with only arrays, like C? What's something that is made significantly easier by an s-expression than by arrays/tables?
To make s-expressions language-agnostic, wouldn't you need libraries in the languages to convert between the s-expression as it exists in some specification, and the language's native data structures? This doesn't sound all that different from JSON at this point, or a much more complex specification that defines the representation of all kinds of types, like dates.
> I'm assuming your statement would be meant to apply to other common languages without s-expressions, but maybe I've misunderstood.
It was meant for C specifically. Take a JSON document. Define it in C. Here's what I see on a random cJSON GitHub project:
https://github.com/DaveGamble/cJSON/blob/master/README.md#ex...
Now do that in JavaScript:
Now make the equivalent jsonDoc in Lisp with s-expressions: The C approach is the approach you'd similarly take in many languages where you create the HashMap, then create the Array, then populate them. Of course, you could "cheat" in many languages by first making a string and then calling the JSON library's `parse` on the string. But, this is different than JavaScript where you can directly create the JSON document. In Lisp, you are always writing s-expressions, both for data and code.> What's something that is made significantly easier by an s-expression than by arrays/tables?
An s-expression is a form of syntax. Even though it is a "list", the s-expression (list 1 2 3) is an actual list. It's not like you're taking the idea of arrays and tables and replacing it with a list. It's like you're taking the idea:
And replacing it with the idea: What about dates? What if we want rationals? What if we want to use a binary-search-tree-map instead of a hash? Lisp: The Lisp examples are simplified, but that is the idea.> To make s-expressions language-agnostic, wouldn't you need libraries in the languages to convert between the s-expression as it exists in some specification, and the language's native data structures?
Yes.
> This doesn't sound all that different from JSON at this point, or a much more complex specification that defines the representation of all kinds of types, like dates.
Correct. It would just be like JSON and whatever bits are standardized are what would be handled.
I think I see what you’re getting at. Thank you for the explanation!