SourceForge.net Logo

One syntax to rule them all

Last modified on 2008/03/12



Is Harpoon free?

Yes, it is. I made the libraries Public Domain. This means that you can do with them whatever you want, including using it in commercial products.

However, if you decide to use Harpoon, I kindly ask you to tell me about it.

What makes Harpoon better than XML?

  • With Harpoon there is no need for any other syntax (e.g. for XML Schema or XPath).

  • Harpoon's data model is compatible with programming languages.

  • Harpoon's expressions are much more concise.

  • Harpoon is designed for structured data, not for annotated text.

Why should anyone be interesting in using Harpoon as a basis for a programming language? There are many progamming languages with good syntaxes.

The unique feature of Harpoon is that the programs you can write not only process data, but they are data themselves. And they are data of a very simple structure (lists, records, tuples). You can easily process or generate such data algorithmically, which means Harpoon is probably the best choice for advanced metaprogramming.

Lisp is very similar in that (actually Harpoon has been inspired by it), but Harpoon syntax is more convenient, mainly due to its syntactic sugar features.

It would be convenient to have also a boolean type.

Bool does not have to be build in. It is a simple enumeration of two idents (false and true):

typedef Bool : enum{ false, true }

Would you add color and vector types?

You can define your own types over lists, tuples and records. For example:

typedef Color : tuple{ Int, Int, Int }

typedef Vector : list( Real )

typedef Matrix:

record {

rows : Int;

cols : Int;

elements : list( Real );


Have you considered creating something like XPath? "Books/Book[12]/Title" could be much more convenient than data->peek("Books")->...->value();

I have created a preliminary version of hrp::path, but it is very probable to change, so I do not recommend using it yet. The hrp::path expressions are of course expressed in Harpoon itself. In the current version there are 3 operators: list access (index in square brackets), record field access (dot + field name) and tuple access (dot + field index). For example:

Data* result = path::get( data, ".books[0].title" );

There are different operators for access to lists and tuples, because (1) tuples are more related to records that to lists and (2) to detect mistakes earlier.

Harpoon does indeed look interesting, although I must admit I'm not sold on the necessity of syntactic sugar. I happen to like lisp's clean and simple design.

Syntactic sugar is optional and is useful for mimicking C syntax. Harpoon has been much inspired with Lisp and especially with the Lisp's metaprogramming features. It is intended to bring this virtue to users accustomed to the syntax of C-family languages (besides being an XML alternative).

Please, send your questions to mczard@poczta.onet.pl