Live data from Hacker News

XSLT is a failure wrapped in pain

harmful.cat-v.org

11–20 of 157 posts

Re: XSLT is a failure wrapped in pain

#11
post #7
post #5

Rather than singing the praise of XSLT (which I love) I'll show an example: this tool transforms any rich text to markdown: http://markitdown.medusis.com It's about 30 lines of XSLT that run in the browser. [Edit: it's not 30 lines but 230, but I was thinking of the number of "rules" (templates) of which there are only 29.] There are very few other tools of its kind and I don't think there exists any client-side, wit…

Looks like 230 lines to me https://github.com/bambax/markitdown.medusis.com/blob/master...

[deleted]

Re: XSLT is a failure wrapped in pain

#12
post #3

XSLT is one of the most powerful and elegant technologies created in the last 15 years. Those who don't understand it and that's why can't use it, should just do their home work and learn better

My definition of powerful and elegant is lisp XML is just death by overengineering

apples and oranges? There is no other way of encoding structured documents these days than XML. Like it or not, XML is the de facto standard for data exchange (export from databases, product information software,....)

XML might be overengeneered (which, except for a few things I don't agree with), but there is currently no alternative for it.

Re: XSLT is a failure wrapped in pain

#13
post #3

XSLT is one of the most powerful and elegant technologies created in the last 15 years. Those who don't understand it and that's why can't use it, should just do their home work and learn better

My definition of powerful and elegant is lisp XML is just death by overengineering

   > My definition of powerful and elegant is lisp
Dude, XML is just s-exprs and XSLT is macros.

Re: XSLT is a failure wrapped in pain

#14
post #5

Rather than singing the praise of XSLT (which I love) I'll show an example: this tool transforms any rich text to markdown: http://markitdown.medusis.com It's about 30 lines of XSLT that run in the browser. [Edit: it's not 30 lines but 230, but I was thinking of the number of "rules" (templates) of which there are only 29.] There are very few other tools of its kind and I don't think there exists any client-side, wit…

http://markitdown.medusis.com/xsl/html2mk.xsl

It looks like 234 lines of code to me.

>This attempt for example https://github.com/domchristie/to-markdown/blob/master/src/t....

Is badly written, but still written in a better language. They're using regexps to parse HTML (omfg!), but that kind of nastiness doesn't excuse XSLT as a language.

>There is no better templating language than XSLT

Except mako, jinja2, django templating language, liquid, etc.

Re: XSLT is a failure wrapped in pain

#15

JSON/Javascript is just easier to learn and work with than XML/XSLT. For starters, you don't need to learn a special language that you'll never use for anything else. Just in case you /do/ need to use XML every day: the primary benefit of XSLT is that it lets you avoid using XML libraries to munge some XML. Because the XML libraries are so horrendous to use from any language.

I am sorry but Javascript is not much better than XSLT. Horrible legacy technology full of bugs nobody was bothered to fix.

Re: XSLT is a failure wrapped in pain

#16
Since it is the hot topic of the day, let me add this perspective: http://www.snoyman.com/blog/2012/04/xslt-rant.html

Quote

> I'm not even talking about the hideously verbose syntax, or the completely obtuse data model. The fact that you can't know what any single line of code does without reviewing every other line in the program makes this language an abomination.

Re: XSLT is a failure wrapped in pain

#17
post #3

XSLT is one of the most powerful and elegant technologies created in the last 15 years. Those who don't understand it and that's why can't use it, should just do their home work and learn better

The problem is that it's often misused. Using an XSLT that takes 0.5s to run to transform some XML to HTML during web requests on a busy site? Idiotic. Using it for async transformations - html to pdf, customer message format to your message format. Fine.

The problem is not that it is misused. The problem is that there is a small subset of problems for which it works passably (like many other technologies) and a large universe of problems for which it will cause you massive pain.

Re: XSLT is a failure wrapped in pain

#18
post #5

Rather than singing the praise of XSLT (which I love) I'll show an example: this tool transforms any rich text to markdown: http://markitdown.medusis.com It's about 30 lines of XSLT that run in the browser. [Edit: it's not 30 lines but 230, but I was thinking of the number of "rules" (templates) of which there are only 29.] There are very few other tools of its kind and I don't think there exists any client-side, wit…

http://markitdown.medusis.com/xsl/html2mk.xsl It looks like 234 lines of code to me. >This attempt for example https://github.com/domchristie/to-markdown/blob/master/src/t... . Is badly written, but still written in a better language. They're using regexps to parse HTML (omfg!), but that kind of nastiness doesn't excuse XSLT as a language. >There is no better templating language than XSLT Except mako, jinja2, django…

You're right, it's 230 lines; I updated my post accordingly. I wrote the thing 3 years ago and remembered the number of rules (templates) instead of the number of actual lines. But a line's a line, so I was wrong.

"written in a better language" doesn't mean much, however. A better language for what? I'm not picking on JavaScript, which I love and use every day; but templating in JS versus XSLT is crazy.

The templating languages that you mention are, in my opinion, extremely complex and very unpalatable; and they only work server-side.

But that's all a matter of taste, I guess. What I don't understand is why so many people go out of their way to declare their hate of XSLT (and all things XML), especially now that XSLT is all but dead...?

Re: XSLT is a failure wrapped in pain

#19

Earlier quoted context omitted.

My definition of powerful and elegant is lisp XML is just death by overengineering

apples and oranges? There is no other way of encoding structured documents these days than XML. Like it or not, XML is the de facto standard for data exchange (export from databases, product information software,....) XML might be overengeneered (which, except for a few things I don't agree with), but there is currently no alternative for it.

The site in question lists several alternatives, some of which are widely in use especially in cases where XML falls short: brevity, fast to parse, easily readable... Most of all, calling it the de facto standard is either dishonest or clueless.

Re: XSLT is a failure wrapped in pain

#20
I believe the fundamental pain of xslt was... that it was an FP language. When teaching XSLT, the difference between those who said "its elegant" vs. those who said "its pain" - is whether the individual could grok FP.

Angle bracket overload, verbosity of end tags, library support, poor whitespace handling, namespace pain were all obstacles too but it was FP that made standard problems feel like math proofs and for developers to take days to solve problems they could code in minutes in their usual OO/imperative language.

When I see the pain FP causes in the real world I'm never quite sure whether its nature or nurture. I currently believe its a bit of both but the nature part will always hobble FP adoption - if you find algebraic proofs elegant, you will like FP. If you are "normal" and proving a theorem fills you with terror then you would prefer your programming language to resemble a a cookery recipe.

I also believe all templating, especially for code-generation, requires three brains - understanding the input data-structure, understanding the processing of the template and understanding the behaviour of the output. Each keystroke in your templating language has to be carried out with full understanding of all three parts. Its too much for those if they still struggle with more common two brain programming problems.

Post reply on HN