Hacker News new | past | comments | ask | show | jobs | submit login

Anyone care to explain why use S-Expression as opposed to plain CSV or json?



Good question.

Why not CSV? S-Expressions are tree-structured, and that makes it easier to handle things like whether or not someone has a spouse (or multiple spouses) or a partner, or whether they have a title.

To parse S-Expressions, you just use (read) in Racket (or any Scheme for that matter). CSV isn't hard to parse, but it's not a 6-character expression.

Why not JSON? JSON is tree-structured, so it accounts for the issues above. But, most languages that slurp JSON don't have pattern-matching facilities as powerful as Racket.

If you look at the patterns I wrote to chew up entries and spit out labels, you'll see what I'm talking about.

Finally, the outputted S-Expressions are very human-readable.

/article author


Thank you. I am trying to learn Lisp(Emacs Lisp and Clojure) and was curious on your format choice. Great article btw.


racket (and scheme) can read sexprs from a port with the 'read' procedure, which then uses the interpreter's parsing engine. loading csv or json require modules.

and it's no more difficult for C to spit out strings with some parens in them than it is strings with commas.


Credibility, of course.


Because Racket, a lisp dialect, is doing the processing, and every expression in lisp is an s-expression.




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

Search: