13 ms·
It’s instructive to see how different MathML is from other math markup languages. Here’s the quadratic formula: In troff, x = {-b +- sqrt { b sup 2 - 4ac}} ove
by anjbe 11y ago
It’s instructive to see how different MathML is from other math markup languages. Here’s the quadratic formula:
In troff,
x = {-b +- sqrt { b sup 2 - 4ac}} over 2a
In TeX,
x = {-b \pm \sqrt{b^2-4ac}} \over {2a}
In plain Unicode,
𝑥 = (−𝑏 ± √(𝑏² − 4𝑎𝑐))⁄2𝑎
In MathML,
<mrow><mi>x</mi><mi>=</mi><mfrac><mrow><mi>−</mi><mi>b</mi><mi>±</mi><msqrt><mrow><msup><mi>b</mi><mi>2</mi></msup><mi>−</mi><mi>4ac</mi></mrow></msqrt></mrow><mi>2a</mi></mfrac></mrow>
MathML is simply unreasonable to write by hand. Most of the time it’s only ever used as an interchange format, automatically generated by tools.
Indeed, the only time I ever use it is with mandoc(1), the default manpage formatter on BSD, Illumos, and some Linuxes, which converts equations to MathML when converting manpages to HTML.
- spicyj 11y agoYeah. I think that's inevitable with an XML syntax. XML is good at some things, but representing math expressions clearly is not one of them.
- masklinn 11y agoXML is unreadable and unwritable for any markup-heavy document, and math expressions tend to be more markup than text.
- amelius 11y agoIndeed. But you could always define your own alternative syntax and write a simple translator to XML.
- koolba 11y ago> Yeah. I think that's inevitable with an XML syntax. XML is good at some things, but representing math expressions clearly is not one of them. What is XML good at? (by good I mean better than alternatives like JSON, YAML, HAML, etc) The only thing I that might qualify is a long term/archival quality document format like ODF/OOXML. The inherently embeddedable nature of XML does seem like a nice fit but it gets very bloated very fast (deflated wrappers help though).
- bonaldi 11y ago> What is XML good at Supporting XQuery/XPath queries and typing with DTDs are the big ones for me, including all the surrounding tooling. You can get replicas of both of these in JSON now, but I don't think they're as mature.
- jerven 11y agoTry the same equation but then with JSON, and see how it is even more terrible. Document Object Models as in HTML etc... are where XML is actually ok, as that was its design niche. Could have been a bit simpler but hindsight...
- flatline 11y agoXML grew out of SGML/HTML, and there's no denying that its age shows. It's kind of like going into a house built in the 90s and seeing all the little things that just scream "90s house - that looks so dated!" Did you know that web browsers have native support for XML? Try fetching an xml resource and pulling the responseXML value off the XHR - you have another DOM object right in your hands, that you can treat just like a regular Node. The reason that XML is better than the alternatives has nothing to do with the syntax itself, but the tooling around it. Browser support, XQuery, XPath, XSD/RelaxNG, XSLT - please tell me where I can find the equivalents for any other markup language. You don't have to use them, either - but if you need them, they are there in pretty much every framework. XML had the first to market advantage, and was picked up in enterprise systems and made powerful and ubiquitous. If you need batteries included, XML is right there, the others are not. There is really nothing wrong with it, the syntax is clunky for some applications but great for documents, whereas e.g. JSON would be horrible in that scenario.
- xaduha 11y ago> Did you know that web browsers have native support for XML? Not only that, browsers have support for XSLT 1.0, so you can format it and style it with CSS on the fly. Even mobile browsers support that, as far as I can tell.
- deleted 11y ago[deleted]
- LarryMade2 11y agoI've found XML is more suited for proper indentation formatting and reading top to bottom not left to right. When it is in up to down and indented it is VERY readable and can be even more understandable as the elements are well implied.
- scott_s 11y agoI audibly groaned at the XML version, but to be fair, it can be presented better: <mrow> <mi>x</mi> <mi>=</mi> <mfrac> <mrow> <mi>−</mi> <mi>b</mi> <mi>±</mi> <msqrt> <mrow> <msup><mi>b</mi><mi>2</mi></msup> <mi>−</mi> <mi>4ac</mi> </mrow> </msqrt> </mrow> <mi>2a</mi> </mfrac> </mrow> Again, I'm not saying this is good. Compared to the brevity of TeX or troff, it's difficult to accept. But XML is easier to read when you give in to its heavyweight structure and format it appropriately. By the way, on my system (OSX, Chrome), the unicode version is beautiful. I had not realized it was a good math option.
- jandrese 11y agoThe big downside with the Unicode option is the poor handling of fractions. It's not so apparent with the Quadratic Equation, but if your have a complex divisor the / notation starts to fall apart. Even properly formatted that MathML version is just awful. You could help it a bit by combining some of those <mi> elements on a single line maybe, but it's way too much mental effort to parse that mess.
- whorleater 11y agoLack of proper subscript and superscript support is a killer for Unicode as well. Unicode is amazing for smaller, simple equations, but anything beyond that soon becomes extremely hard to process.
- paxcoder 11y agoI know what you're referring to, but then again, that's a matter of formatting, not encoding.
- jahewson 11y agoYou can remove the <mrow> inside the <msqrt> too.
- conistonwater 11y agoShouldn't the '=' and the minus and the other signs be inside <mo>, rather than <mi>, because they are binary operators, not identifiers? TeX for example, makes a clear distinction in terms of how much whitespace it would surround operators with, vs. identifiers. In any case, I suspect MathML was intended as an intermediate computer-readable representation, not something that anyone would write by hand (MathJax can compile your LaTeX to MathML). I don't see what's wrong with an intermediate representation that's difficult to manipulate by hand. And unless I misunderstood the article, their point is that MathML is bad as an intermediate representation.
- t1212129 11y agoWell, ask Peter and their alter ego, perhaps they will provide an answer.
- anjbe 11y ago>Shouldn't the '=' and the minus and the other signs be inside <mo>, rather than <mi>, because they are binary operators, not identifiers? You’re right; I should have marked those up with <mo> instead.
- wrp 11y agoDoes anyone else prefer writing troff/tbl/pic/eqn? I always felt that the language of TeX/LaTex was a step backward in user-friendliness.
- duaneb 11y agoI found troff syntax to be very hard to debug for parse errors, while you can easily fit the tex tokenizer into your head. There is also much less control in eg alignment of complex tables.
- anjbe 11y agoI’m also one of those who prefers troff. I read all five volumes of Knuth’s Computers and Typesetting cover to cover, and TeX is a beautiful piece of work. But in my preferred alternate universe, two things would be different: Joe Ossanna would not have died young, and AT&T would have been more open with licensing in time for Knuth to use troff as a base for his improvements to the world of typesetting.
- drfuchs 11y agoHe tried, but the syntax was ill-defined, and the typography was poor.
- SixSigma 11y agoI usually use OpenOffice / LibreOffice Equation Editor which is based on eqn. Ironically the on disk format it uses is MathML.
- wrp 11y agoYes. I would use OOo if the equation typesetting wasn't awful. They don't seem to have put any effort into improving it over the years. MS Word typesetting has become quite good, though not up to the best you can get with LaTeX.
- yepguy 11y agoIn AsciiMath[1], x = (-b +- sqrt(b^2 - 4ac)) / (2a) [1]: http://asciimath.org/ http://asciimath.org/
- sammydavis 11y agoGood, you caught that he was only dividing by 2, not 2a
- sammydavis 11y agoalso, thanks for the pointer to ascii math, looks like a nice way to render
- runarberg 11y agoI wrote a clone1[1] of asciimath recently that aims to be just a little bit better then asciimath. It only targets MathML though. [1]: https://runarberg.github.io/ascii2mathml https://runarberg.github.io/ascii2mathml
- jahewson 11y agoMathML was never intended to be written by hand any more than SVG was. It was designed to provide a standard output format for equation editors. Wolfram created MathML explicitly to prevent TeX from being adopted as a defacto standard on the web because TeX, being concerned only with visual appearance, does not do a good job of describing the structure or semantics of equations. MathML excels in both these areas, providing a fairly simple and standardised visual model which fits well with web browsers, and a rich semantic model. In other words, MathML is great and it's a much better fit for web browsers than anything else on offer. Just don't write it by hand!
- Mikhail_Edoshin 11y agoXML is not meant to be written primarily by hand (although I agree some XML languages could be more elegant). The markup part of XML is for the machine; if you remove it from your example, you'll get x=−b±b2−4ac2a, which is, basically, the text content that was meant for the humans. Now, as a machine language XML is much better than troff or TeX, because it's very easy to parse: it's basically a syntax tree, the result of parsing those other formats, you don't even really parse it, just deserialize. Naturally, it's a very good interchange format. Technically it would be a much better option than a full-fledged JavaScript parser and typesetter because it would've removed the parsing part. (And this is only one of the advantages.)