Ask HN: Most desirable features in a parser for a data interchange format?

3 points by geezerjay ↗ HN
Dear HN,

If you were entrusted with the mission of designing the ideal parser for a data interchange format (say XML, JSON, YAML, etc...) what features would you add?

1 comment

[ 3.6 ms ] story [ 14.0 ms ] thread
The lesson of history is that there is no "ideal" parser; it seems that every major version of every programming environment (Java, Python, PHP, .net, ...) gets a new XML parser because people could not stand to use the last one.

Here are some features (sometimes mutually incompatible) that parsers can have:

  * fast
  * low memory consumption
  * streaming operation
  * building a complete document tree
  * streaming document chunks
  * being strict
  * being lenient
  * being extremely lenient (handle "last Thursday" as a date)
  * intelligent error handling
  * intelligent error handling of errors discovered downstream (ex. some invariant of the document is found to be untrue when we are using the output of the parser,  we can point the user to the line number and give a clear explanation of the problem)
  * static orientation (take a document with a known schema and populate POJOs with them)
  * dynamic orientation (easily handle any document without anything known about structure)
  * really,  really, fast
  * use same parser for multiple formats (or at least look that way)