RejectedSoftware Forums

Sign up

Pages: 1 2 3

Re: Alternative package description formats

Am 21.11.2013 17:52, schrieb Bruno Medeiros:

On 09/03/2013 12:11, Sönke Ludwig wrote:

There has been some discussion about using a different format than
JSON for the package description
files
. While this topic is
techinically not particularily pressing, it would be good to know
where to go with this early. The two candidates so far are YAML and
SDL. JSON will still be supported for backwards compatibility and as
the default format that is transferred over the network (package
registry). The following sections list the pros/cons of each format
and an example of how it could look like. My favorite so far is SDL,
which was originally proposed by Nick Sabalausky, who also made a D
implementation
. So now I
think it would be good to get some more input to get a collective
opinion on this before implementing anything.

Have you considered lenient JSON as an alternative?

Lenient JSON is a loosely defined extension to JSON that allows many of
the things that would make it a more succint and clear data format. For
a description of lenient JSON, see this:
http://developer.android.com/reference/android/util/JsonReader.html#setLenient%28boolean%29

It allows these extra syntaxes:

  • End of line comments starting with // or # and ending with a newline

character.

  • C-style comments starting with / and ending with /. Such comments

may not be nested.

  • Names that are unquoted or 'single quoted'.
  • Strings that are unquoted or 'single quoted'.
  • Array elements separated by ; instead of ,.
  • Unnecessary array separators. These are interpreted as if null was

the omitted value.

  • Names and values separated by = or => instead of :.
  • Name/value pairs separated by ; instead of ,.

Some JSON parser/readers support this functionality already, so there is
also some tool support already (although not for D).

I think it was suggested before on the D newsgroup, but it looks like
it would solve only two issues - the quotes required around names and
lack of comments. But there are two other significant things where both
SDL and (slightly worse) YAML are an improvement - reducing (visual)
nesting levels and matching parentheses.

But on the other hand I guess if lenient JSON would have been supported
from the start, then the shouting for a better format would possibly
have never started in the first place...

Anyway, SDL IMHO hits a nice sweet spot between a well thought out
custom syntax and a generic data description language, as well as
between simplicity and power. And if nothing else, I think it's a format
worth helping to become more popular ;)

Re: Alternative package description formats

On Sat, 09 Mar 2013 12:11:09 GMT, Sönke Ludwig wrote:

There has been some discussion about using a different format than JSON for the package description files. While this topic is techinically not particularily pressing, it would be good to know where to go with this early. The two candidates so far are YAML and SDL. JSON will still be supported for backwards compatibility and as the default format that is transferred over the network (package registry). The following sections list the pros/cons of each format and an example of how it could look like. My favorite so far is SDL, which was originally proposed by Nick Sabalausky, who also made a D implementation. So now I think it would be good to get some more input to get a collective opinion on this before implementing anything.

JSON

While I think the current JSON based format for the package description is OK, it does have a few drawbacks:

  • No support for comments
  • Key names must be quoted, although they are just plain identifiers
  • Commas between individual fields -> danger of syntax errors for the last field
  • The very generic structure makes it easy to learn, but sometimes a bit verbose
  • Relatively deep nesting

Example:

{
	"name": "my-package",
	"description": "A package for demonstration purposes",
	"dependencies": {
		"vibe-d": ">=0.7.13",
		"sub-package": {"version": "~master", "path": "./sub-package"}
	},
	"configurations": [
		{
			"name": "console",
			"targetType": "executable",
			"versions": ["ConsoleApp"]
		},
		{
			"name": "gui",
			"targetType": "executable",
			"versions": ["ConsoleApp"],
			"libs-windows": ["gdi32", "user32"]
		}
	]
}

YAML

YAML basically has the same structure as JSON, but allows an alternative syntax using indentation instead of clamps to group items together. It also removes the quotes around strings. Furthermore, tt allows a multitude of ways to format the file (including JSON, which is a subset of YAML), which can be handy, but can also make it harder to learn or read, depending on how it is actually written. It follows the same structure as JSON, but supports comments.

Example:

---
name: my-package
description: A package for demonstration purposes
dependencies:
	vibe-d: ">=0.7.13"
	sub-package:
		version: ~master
		path: ./sub-package

configurations:
	# command line version
	- name: console
	  targetType: executable
	  versions:
	    - ConsoleApp

	# Win32 based GUI version
	- name: gui
	  targetType: executable
	  versions:
	    - UseWinMain
	  libs-windows:
	    - gdi32
	    - user32		

SDL

Finally, SDL has a tag+attribute based structure that differs from the other two and allows to vary how certain data fields are specified. It uses curly braces as the means to create a tag hierarchy and otherwise goes without punctuation (except for quotation marks) and thus results in clean files. Syntax-wise it comes closest to D when comparing the three contenders. Finally, the tag based nature facilitates a design with less nesting and less syntactic ambiguity (e.g. fields that may only occur once can be attributes).

Example:

name "my-package"
description "A package for demonstration purposes"

dependency "vibe-d" version=">=0.7.13"
dependency "sub-package" version="~master" path="./sub-package"

# command line version
configuration "console" {
	targetType "executable"
	versions "ConsoleApp"
	libs-windows "gdi32" "user32"
}

# Win32 based GUI version
configuration "gui" {
	targetType "executable"
	versions "UseWinMain"
	libs-windows "gdi32" "user32"
}

As much as I dislike XML, I think it is not a good idea to ignore it. XML should definitely be among the supported formats. Also, it would be nice to have a converter between them in the case package owners decide to switch to an alternative.

Re: Alternative package description formats

Am 03.12.2013 10:43, schrieb Dejan Lekic:

As much as I dislike XML, I think it is not a good idea to ignore it. XML should definitely be among the supported formats. Also, it would be nice to have a converter between them in the case package owners decide to switch to an alternative.

I don't know, the purpose of the alternative format discussed here is
supposed to improve human readability (which XML surely doesn't offer).
But on top of that I really think it would be a bad idea to complicate
the system with more formats without a very good reason. JSON should be
universal enough as the standard format for machine data exchange. What
would XML really offer additionally in practice?

Having said that, SDL is structurally more or less the same as XML, so a
generic XML<->SDL converter could be used for this.

Re: Alternative package description formats

On Tue, 03 Dec 2013 11:44:43 +0100, Sönke Ludwig wrote:

Am 03.12.2013 10:43, schrieb Dejan Lekic:

As much as I dislike XML, I think it is not a good idea to ignore it. XML should definitely be among the supported formats. Also, it would be nice to have a converter between them in the case package owners decide to switch to an alternative.

I don't know, the purpose of the alternative format discussed here is
supposed to improve human readability (which XML surely doesn't offer).
But on top of that I really think it would be a bad idea to complicate
the system with more formats without a very good reason. JSON should be
universal enough as the standard format for machine data exchange. What
would XML really offer additionally in practice?

Having said that, SDL is structurally more or less the same as XML, so a
generic XML<->SDL converter could be used for this.

I would agree with to a certain degree. But the moment your project becomes complicated, no format will make it readable. You will struggle with any format, especially when you autogenerate (and that is going to happen) DUB JSON. And the more it is close to be machine readable than human readable the higher is the need of a tool that can aid person in altering something. There are thousands of XML tools out there, as you already know. Plus, it is a standard exchange format in many environments. I've seen literally unreadable JSON in many places, and I am 100% sure you have seen it too. DUB JSON files will probably continue being human readable because humands made them, and edit them. :)

Re: Alternative package description formats

Am 03.12.2013 12:10, schrieb Dejan Lekic:

On Tue, 03 Dec 2013 11:44:43 +0100, Sönke Ludwig wrote:

Am 03.12.2013 10:43, schrieb Dejan Lekic:

As much as I dislike XML, I think it is not a good idea to ignore it. XML should definitely be among the supported formats. Also, it would be nice to have a converter between them in the case package owners decide to switch to an alternative.

I don't know, the purpose of the alternative format discussed here is
supposed to improve human readability (which XML surely doesn't offer).
But on top of that I really think it would be a bad idea to complicate
the system with more formats without a very good reason. JSON should be
universal enough as the standard format for machine data exchange. What
would XML really offer additionally in practice?

Having said that, SDL is structurally more or less the same as XML, so a
generic XML<->SDL converter could be used for this.

I would agree with to a certain degree. But the moment your project becomes complicated, no format will make it readable. You will struggle with any format, especially when you autogenerate (and that is going to happen) DUB JSON. And the more it is close to be machine readable than human readable the higher is the need of a tool that can aid person in altering something. There are thousands of XML tools out there, as you already know. Plus, it is a standard exchange format in many environments. I've seen literally unreadable JSON in many places, and I am 100% sure you have seen it too. DUB JSON files will probably continue being human readable because humands made them, and edit them. :)

It may sound naive, but I truly hope that the package description files
will stay manageable due to proper modularization and with the help of
proper format/DUB features. The "sub package" feature, which I don't
really like, doesn't really help there, but as long as things like C
library wrappers are properly encapsulated as separate packages, things
tend to stay quite simple. Certainly simple enough for an SDL based
format to stay readable.

Of course there may be exceptions, but it's always better to put
pressure on people to simplify things instead of facilitating complex
structures (it makes me sick to look at certain Java or C# code bases
where people often have no chance to get a real overview anymore,
because the complexity can only be handled by the refactoring tools). Or
in other words, what might be a relief in the short term (the tool) may
be a terrible burden in the long term. Of course it also depends on the
user, but most examples that I've seen goes this way.

But even if we'd say a tool for managing package description complexity
is a good idea, will a generic XML tool really help much? I'd imagine
that a specialized tool is needed to bring much of a benefit - but in
that case the format doesn't really matter.

Re: Alternative package description formats

On 03/12/2013 11:10, Dejan Lekic wrote:

On Tue, 03 Dec 2013 11:44:43 +0100, Sönke Ludwig wrote:

Am 03.12.2013 10:43, schrieb Dejan Lekic:

As much as I dislike XML, I think it is not a good idea to ignore it. XML should definitely be among the supported formats. Also, it would be nice to have a converter between them in the case package owners decide to switch to an alternative.

I don't know, the purpose of the alternative format discussed here is
supposed to improve human readability (which XML surely doesn't offer).
But on top of that I really think it would be a bad idea to complicate
the system with more formats without a very good reason. JSON should be
universal enough as the standard format for machine data exchange. What
would XML really offer additionally in practice?

Having said that, SDL is structurally more or less the same as XML, so a
generic XML<->SDL converter could be used for this.

I would agree with to a certain degree. But the moment your project becomes complicated, no format will make it readable. You will struggle with any format, especially when you autogenerate (and that is going to happen) DUB JSON. And the more it is close to be machine readable than human readable the higher is the need of a tool that can aid person in altering something. There are thousands of XML tools out there, as you already know. Plus, it is a standard exchange format in many environments. I've seen literally unreadable JSON in many places, and I am 100% sure you have seen it too. DUB JSON files will probably continue being human readable because humands made them, and edit them. :)

I agree with Sonke here, supporting XML would just be an unnecessary
distraction.
No data format is truly unreadable, unless it just used for
machine-to-machine/program-to-program interaction. And even so, there
might be times a human might have to look at it (say, debugging the
communication for example).
Rather, the question is not if it's readable or not, but how readable it
is, how simple and succint the data language is. And it is of value to
have a succint data description language for DUB, since a lot of the
times it will be read and edited by humans.

Plus, JSON is well supported accross a variety of languages:
www.json.org (scroll bellow) , so it's not too far from XML.

Re: Alternative package description formats

On 11/10/2013 11:06 AM, Sönke Ludwig wrote:

I personally didn't have time up to now. However, it should be possible
to allocate a day next week (the dub-registry project also needs be
changed to use dub as a library dependency to handle package files to
avoid redundancies). I'd also change the file names to "dub.json" and
"dub.sdl" respectively on that occasion (o/c keeping "package.json" for
backwards compatibility).

I thought Nick wanted to pull this off ;).
Seems like he doesn't seem to have much time these days.

Re: Alternative package description formats

On 03/09/2013 01:11 PM, Sönke Ludwig wrote:

JSON

While I think the current JSON based format for the package description is OK, it does have a few drawbacks:

  • No support for comments
  • Key names must be quoted, although they are just plain identifiers
  • Commas between individual fields -> danger of syntax errors for the last field
  • The very generic structure makes it easy to learn, but sometimes a bit verbose
  • Relatively deep nesting

Looks like CSON (Coffeescript JSON) does address all of the above points.
https://github.com/bevry/cson

Pages: 1 2 3