SourceForge.net Logo

One syntax to rule them all

Last modified on 2008/02/02



I have seen the problem of storing structured data in files being solved over and over again. Too many people in the world wasted their time to write parsers and reinvent the wheel again. Even more, too many people had to put too much effort learning different syntaxes of many domain-specific languages. This problem has been recurring also in almost all projects I was involved it. I needed structured data to describe unit properties in a rts game, to store results of a vector graphics editor, to represent knowledge in an automated reasoning application. Finally, I needed it to save to file an abstract-syntax tree (AST) in a programming language project. And at that point I decided to do it in a more general way and created a language with lists and records from which the current Harpoon evolved.

At that time I had a very ambitious plan to create a perfect programming language. I have failed, of course, but after some time I realized that it was possible to make the format of the abstract syntax trees so convenient, that I could write programs directly as the abstract syntax trees. Such approach, already known from Lisp, has an advantage that programs and data can be represented and manipulated in the same way. Consequences are immeasurable.

Harpoon at the moment is still as simple as it was at the beginning - there are only lists, records and tuples. However, during the time, it has been enriched significantly by addition of syntactic sugar and types. The syntactic sugar made it really possible to mimic even complicated syntaxes of high level programming languages. The types allowed definitions of Harpoon-based specific languages, in a similar, but much simpler way as people used to use grammar definitions or document schemas.

Other projects

There are very few universal data languages. One very interesting project is Yaml language. It has two compound data types - sequences and mappings - which correspond to Harpoon's lists and records. Yaml with its Python-like syntax is definitely more human-readable than Harpoon. On the other hand Harpoon is more oriented on programmers and has powerful syntactic sugar features and types.

Other similar projects are ONX and JSON.