3 ms·
S-expressions have keywords, and don't require commas between list elements. That alone goes a _long_ways towards making s-expression based languages way more r
by nightfly 7y ago
S-expressions have keywords, and don't require commas between list elements. That alone goes a _long_ways towards making s-expression based languages way more readable/writable than a similar datastructure encoded in something like JSON or YAML.
Here's an example of a JSON coded query taken from a PuppetDB tutorial (PuppetDB uses a very lispy query language):
["and",
["=", "type", "User"],
["=", "title", "nick"]]
And the same code as you could write it in native s-expressions:
(and
(= :type "user")
(= :title "nick"))
...and one way you could encode it in yaml...
- and:
- =:
- type
- user
- title:
- title
- nick
- 411111111111111 7y agowhy are you encapsulating everything in lists for your yaml example? you arent in your other examples either? - filters: - operant: = type: user - operant: = title: nick if the module author wants to, he could even remove the secondary list because its the same operator, making this - filters: - operant: = type: user title: nick thats just as readable as your other examples imo. yaml doesnt have to be an unreadable mess. its just possible to make bad apis, which remains true for yaml just as for any other format.
- bogomipz 7y agoThanks for example and explanation, this makes good sense. I apologize if this is a naive question but is there a reason we don't see configuration management taking advantage of S-expressions?