We use a lot of S-Expressions at Jane Street. Almost every system written at Jane Street in OCaml uses sexps for config files, and we use it for a lot of IPC when resources aren’t an issue.
That’s all fine and good when you just have OCaml talking to OCaml, but we are a practical bunch, and sometimes we want to use a library or open source project that is written for a different language.
Luckily, if the language is Ruby, you don’t need to work very hard, due to an excellent ruby gem called SXP. Note: you’ll need ruby 1.9 for this
$ sudo gem install rdf sxp
And then you can write something like this:
#!/your/path/to/ruby
require 'sxp'
sxp = SXP.read "(foo bar baz biff)" # => [:foo, :bar, :baz, :biff]
# ex.sexp:
# ((foo 1)
# (bar 2))
# ((foo 3)
# (bar 4))
# ((foo Hello)
# (bar snoo))
sxpfile = SXP.read("ex.sexp")
# => [[[:foo, 1], [:bar, 2]], [[:foo, 3], [:bar, 4]], [[:foo, :Hello], [:bar, :snoo]]]
It’s just that simple.
You can read more about sxp at http://rubygems.org/gems/sxp