Subject: Re: [NGO] A bigger picture WAS:Re: completed CANMOD agenda

From: <[email-masked]>
Date: Wed, 5 Mar 2008 19:43:54 +0200

Hi,

>-----Original Message-----
>From: [email-masked] [mailto:[email-masked]] On 
>Behalf Of ext Phil Shafer
>Sent: 27.02.2008 19:42
>To: Mehmet Ersue
>Cc: NGO-list
>Subject: Re: [NGO] A bigger picture WAS:Re: completed CANMOD agenda
>
>Mehmet Ersue writes:
>>Personally I like YANG pretty much (there is already a transformation 
>>available to YIN), but I would rather see XML syntax as the core 
>>syntax, and there can be a standardized ASCII mapping of it.
>
>I don't want to rathole on this for too long, but I'd like to 
>point out that XML is a _great_ encoding for 
>machine-to-machine communication, since it is simple, 
>extensible, and trivial to parse.  But its readability often 
>suffers grave injury due to verbosity and the tendency to put 
>first order concepts into second order encodings.

But readability surely can be taken into account in designing the XML
schema.

>
>For example, compare the XSLT and SLAX encoding of a simple if
>statement:
>
>XSLT:
>    <xsl:if test="$value &lt; 15">
>      <error>Too low</error>
>    </xsl:if>
>
>SLAX:
>    if ($value < 15) {
>        <error> "Too low";
>    }

And how this then would look like in Yang style?

	if {
		test {
			greater_than {
				left {
					variable "value";
				}
				right {
					literal "15";
				}
			}
		}
		error "Too low";
	}

or would Yang also mix the expression to attribute values

	if {
		test "$value < 15"
		error "Too low";
	}

>
>The important data ("$value < 15") is encoded in an attribute (second
>order) instead of a first class language construct.  Worse, I 
>have to use "&lt;", reducing the readability.

Yes, escapes tend to reduce readability. And "unlucky" choice of special
characters in XML is a bit inconvenient for comparison expressions.

>
>Adding an "else" makes it worse, since you have to use 
><xsl:choose> since an XML encoding needs a parent to organize 
>the alternatives:
>
>    <xsl:choose>
>        <xsl:when test=""$value &lt; 15">
>            <error>Too low</error>
>        </xsl:when>
>        <xsl:when test=""$oil &gt; 100">
>            <panic>OMG</panic>
>        </xsl:when>
>        <xsl:otherwise>
>            <drive>Like a banshee</drive>
>        </xsl:otherwise>
>    </xsl:choose>
>
>SLAX:
>
>    if ($value < 15) {
>        <error> "Too low";
>    } else if ($oil > 100) {
>        <panic> "OMG";
>    } else {
>        <drive> "Like a banshee";
>    }
>
>A language designed for human readability (YANG) can't help 
>but be more readable than an one encoded in XML.

The question is whether we really need two languages, or is one good
enough for both uses, even if not fully optimal for either.

And IMHO Yang style, as a uniformly structured language (so that you can
skip parts of the language, that you don't care, without knowing grammar
of those parts), suffers from same issues as XML i.e. that in some cases
generic syntax is less compact than optimized syntax, and easily this
leads to putting the optimized sub-language to attribute value, like in
the XSLT example.

Regards,

Mikko
_______________________________________________
NGO mailing list
[email-masked]
https://www.ietf.org/mailman/listinfo/ngo

---

From: Phil Shafer <[email-masked]>
Date: Wed, 05 Mar 2008 12:57:46 -0500

>And how this then would look like in Yang style?

You've missed my point, which was that a language defined for a
specific purpose can be made more readable than XML.  Imagine trying
to program in an XMLified version of C or java, and try to predict
how long it would take you to go postal.  Readability saves lives ;^)

Thanks,
 Phil

---

From: <[email-masked]>
Date: Wed, 5 Mar 2008 20:12:51 +0200

No, I didn't miss that, I fully agree that language defined for specific
purpose can be made more readable than XML. But IMHO Yang syntax has its
constraints which are similar to those of XML, this is why I would like
to see how this example would look like in Yang (i.e. if you would
create this if statement as an extension to Yang).

But you need to choose between extensible, uniformly structured,
language (like XML or Yang) and a language where interpretation requires
you to support whole grammar (including extensions). Or you could define
a language where language itself contains a grammar language (allowing
you to specify extensions with a compact grammar, but I think that'd be
rather complicated to parse, and even people might have troubles
understanding, or even skipping, the extensions).

If you extend C or Java and start using those extensions, see how well
that works with any tools based on old grammar (even if those extensions
would be irrelevant for the tool).

Regards,

Mikko

>From: ext Phil Shafer [mailto:[email-masked]] 
>Sent: 05.03.2008 19:58
>To: Lahdensivu Mikko (NSN - FI/Tampere)
>Cc: [email-masked]; [email-masked]
>You've missed my point, which was that a language defined for 
>a specific purpose can be made more readable than XML.  
>Imagine trying to program in an XMLified version of C or java, 
>and try to predict how long it would take you to go postal.  
>Readability saves lives ;^)
>
>Thanks,
> Phil
>