[application] 为什么是 XML 而不是 Lisp?!

Lich_Ray 2007-06-30
我最近一直在思考这个问题。理论上来说,XML 的描述能力绝对在 Lisp/Scheme 的 S-exp 之下;XML 能表示的 S-exp 都能表示,比方说用 XMLisp,但反过来就不行了。而且更重要的是,Lisp 中是编程语言,而 XML 想做到这一点很困难。看到网上一篇文章,和我的想法很类似(http://www.stylusstudio.com/xsllist/200001/post40320.html):
引用

As a lisp programmer for joy of it, I have ever be fascinated by the simplicity and power of Lisp. A Lisp function can return another lisp function. Because Lisp programs are in fact a kind of lisp data structures, called s-expressions (they are in fact lisp trees) the language is simple, and can express any kind of data with the minimal syntax constraints. The capability to process such data is unbeatable, since lisp was done for it.

Sometimes I dreamed on Internet being populated by s-expressions, codifying almost any human need and offer, usingin a homogeneous agreed semantics. The language to process such expressions, of course would be lisp, with added HTTP access, instead of ASP, JSP, Java , _javascript_, Perl, XSP, ISAPI and John´sAPI.

I though XML as an usurpation of the natural role lisp could do easily on Internet, all for the shake of human readability. because:

XML MORE readable than Lisp
BUT
XML LESS consistent && XML LESS coherent && XML LESS flexible THAN lisp.

At last, the big business of XML is Program to Program communication, BtoB, where human readability has no significant role.

Ah! if Tim Barners Lee would have chosen an s-_expression_ based presentation language, not HTML, form the SGML world.....

Thinking on.. the auto-coherence of Lisp, I though about the possibility of a XML general purpose language, to manipulate XML entries and to generate XML output... XSL is not so flexible.. or... yes?

for example, XSL can not manipulate two XML files at the same time..but.. if I have a document formed by the sum of all the documents to process... Can I do with XSL and with such arrangement what can I do with other general purpose XMLDOM compliant language?

maybe, for some tasks, like matching, It can do it better. And If I use embedded scripts (<xsl:eval> like elements) I can do many more things, and not artificially.

the point is to create a document with the sum of the documents to be processed. If I have two "parameters" (XML1 and XML2):
the process would be:
1)XML3=XML1+XML2
2)XSL(XML3)-> XML4 or XSL4

N)next step..

X)until you reach a final XMLx which is the response to your problem.

I foud:
-  XSL is a good XSL generator. We at Ibermatica have developed a HTML -> XSL converter which is done by using XSL . details are not relevant here (little code needed).

- XSL is not similar to Lisp. It´s more or less a Prolog like, rule based language mixed with procedural sentences; Something strange for any programmer, but the XSL philosophy can be adopted as well as was object oriented programming in the 70´s. (old programmers: remember how difficult it was).

- XML and his language, XSL, is a less coherent couple than s-expressions and lisp, since it is necessary to program under a shell made of other language (such is _javascript_). Moreover, to have enough power, it is necessary to use embedded scripts.

We are involved on a project which intend to match XML documents about offers and demands, and maybe we can cut the development time by 70% using this approach.

Please don´t be cruel with incoherences and possible shortcuts that I haven´t found, but I´m writing while I thing on it.

为什么是 XML 而不是 Lisp?
cookoo 2007-07-01
The simple answer: business matters more than technology does.

My answer: even XML isn't very readable to humans (though readable to machines), not to mention Lisp. For configuration files, YAML or INI format is much more readable.
Lich_Ray 2007-07-01
引用

The simple answer: business matters more than technology does.

The widely using of XML has No relationship with commercial, unlike many other techs...
引用

For configuration files, YAML or INI format is much more readable.

//Smile. INI show 2D data only. YAML is so cool, including its name: YAML Ain't Markup Language. However, They're DATA ONLY.
cookoo 2007-07-01
"Business" here I mean the real-world, not just those big companies. Almost every language ships an XML library instead of an embedded Lisp interpreter. Reality sometimes is just sad for its limits

XML is mainly used for exchange of data among different systems and it works fine (well, except for configuration which is acutally an abuse). Of cuz there're a few senarios we need more than data, where Lisp or other expressive languages can take the chance.
pojo 2008-03-31
有意思的问题。我一直以为XML被许多人忽视了,也被许多人滥用了。问题的关键就在于没有/不能回答这类问题。

其实LZ已经部分地触及了问题的答案。
引用
而且更重要的是,Lisp 中是编程语言,而 XML 想做到这一点很困难。

人们需要XML Documents提供的恰恰是一种中立的、与程序无关的数据表达。所以要比得话,应该是比较XML Document和S Expression。

那么XML Document和S Expression有什么异同呢?

如上所述,不考虑程序,那么它们都是树型的表达式,它们是等价的。但是表达式的元素是不同的。在XML Document中,元素是名值对(name value pair),而在Lisp中是数值。换句话说,XML Document表达的是物理量,而Lisp表达的是数值。

如果“计算”的时间和空间跨度足够小,上述的差别不是问题。计算的终端会提供数值的物理解释。当“计算”的时间和空间跨度足够大时,比如工作流的时间跨度和分布系统的空间跨度,一个中立于计算的,可以作为实体独立存在的数据表示就应运而生了。

lichray 2008-03-31
是“物理量”还是数值关键在于节点和表示方式的选取。XML 也有编程语言,但很难用;Lisp 也可以做成能转为对象树的表述法,强于 JSON,这个比 XML 还要接近你所说的“作为实体独立存在的数据表示”。
yushih 2008-09-02
Lisp is nondecidable, XML is
qixinkui 2013-11-17
这个问题似乎应该问作: 为什么是XML而不是S-Exp, SXML 与此问题相关。
qixinkui 2014-01-23
http://blogs.oreilly.com/digitalmedia/2004/12/lisp-is-better-than-xml-but-wo.html

LISP is better than XML, but worse is better

So XML versus S-Expr is a draw, to me.
When character set encoding and markup are important, XML wins.
When terseness or recognizing numbers are important, S-Expressions win.

qixinkui 2014-01-26
http://xahlee.org/diklo/XML_is_not_S-Expressions.txt

more eloquent.
Global site tag (gtag.js) - Google Analytics