News for hackers. Stuff that matters.
Re:MathML is a failed web standard by CaliforniaKarl on Thursday April 07, 2016 @02:30AM (#11445162)
Blargh. It annoys me that MathML was even a thing. We've already had a perfectly-fine and widely-used markup language for mathematical formulae; it's called TeX.

Ideally, I'd prefer that HTML5 include a <math> tag, or something similar, that takes TeX as input and produces formatted output. A side benefit would mean that every browser, and every system, in the world would have TeX installed!

At least MathJax can take TeX as input.

Re:MathML is a failed web standard by pcwalton on Thursday April 07, 2016 @03:22AM (#11445369)
> A side benefit would mean that every browser, and every system, in the world would have TeX installed!

TeX doesn't have dynamic reflow, is defined by a macro system that involves essentially monkey patching the parser as it goes, lacks anything resembling a DOM, wasn't designed with Unicode or internationalization in mind, is completely unparallelizable, doesn't interoperate with CSS, has its own concept of block and inline layout that doesn't allow for text wrapping around floats without hacks, requires multiple passes to compute various things like tables of contents, and wasn't designed for interactive-level performance. Something syntactically like TeX may well be the solution, but jamming TeX itself into the Web platform wouldn't end well.

Re:MathML is a failed web standard by MrManatee on Thursday April 07, 2016 @08:32AM (#11446704)
Yeah. The main thing people probably want is "TeX quality" typesetting of mathematical formulas inside web pages. Bundling the entirety of TeX inside a browser for this purpose would be kind of a hack, and suboptimal in many ways. I think that instead of just using TeX as a black box, it would be more interesting to actually learn what makes its formulas look good, and apply these lessons in modern software.

There's a related article called A Functional Description of TeX's Formula Layout [1] that describes a more modern reimplementation of a part of TeX.

[1] http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.39....

Re:MathML is a failed web standard by avian on Thursday April 07, 2016 @07:40AM (#11446439)
Considering amount of expertise that went into making TeX and the fact that (in my experience at least) it far surpasses other solutions, it might simply be that mathematical notation typesetting doesn't lend itself to dynamic reflow, internationalization, parallelization, DOM representation, interoperability with CSS and its concept of blocks and inline layouts, wrapping around floats, single pass processing and interactive-level performance.
Re:MathML is a failed web standard by pcwalton on Thursday April 07, 2016 @11:38AM (#11448096)
I don't see why, from a technical point of view. There's no reason we should throw out the benefits of the Web platform because TeX happens to do things a certain way. With MathJax and tools like it, we can bring the benefits of TeX to the Web platform in a way that actually meshes well with what the platform provides.
Re:MathML is a failed web standard by hansen on Thursday April 07, 2016 @07:51AM (#11446488)
This is about how I feel. Can someone who’s actually competent explain why (La)TeX output looks so much better than what web browsers do? I’m not talking about childish colors, sticky headers, and all the other annoying “modern web features”, just the relevant content: some text and inline images.
Re:MathML is a failed web standard by TeMPOraL on Thursday April 07, 2016 @09:09AM (#11446912)
Because TeX documents are usually made by people who have something valuable to say, and the tool reflects that. On the other hand most of the web is designed to sell you stuff, and the actual content is not important. The tool, again, reflects that.
Re:MathML is a failed web standard by pcwalton on Thursday April 07, 2016 @11:41AM (#11448121)
I don't think TeX output looks better than what Web browsers do if you enable all the high-quality text features like hyphenation and use modern OpenType fonts (in particular not the Core Fonts for the Web). The reason why the Web doesn't do this by default is backwards compatibility and performance: hyphenation is asymptotically more expensive.
Re:MathML is a failed web standard by Mikhail_Edoshin on Friday April 08, 2016 @03:25PM (#11457182)
TeX doesn't hyphenate every word, it only attempts hyphenation when it looks where to break a line. That said, I don't see why a document cannot be prehyphenated once on the server; I'd say this is the right thing to do. (Besides, in this case we don't have to rely solely on algorithms.)

It's not that CSS is still very far from professional typesetting; what amazes me is that at the same time it's much more complex. Look at all these possible 'display' values and box models! And you still cannot do a run-in header! Or automatic numeration! (You can do the latter natively with XSLT, but it's not cool.) By comparison TeX only has boxes, vertical and horizontal lists, glue, and a few lesser things like kerning. And it produces works of art.

Re:MathML is a failed web standard by ivan_ah on Thursday April 07, 2016 @09:15AM (#11446955)
A few things that make LaTeX docs look good:

    - quality justified paragraphs making use of inter-word spacing and hyphenation
    - font ligatures (tex uses quality fonts have special characters for sequences like fi fi fl ffi ffl ft etc)
    - good heuristics about where to cut pages (e.g. flexible spacing around heading)
Re:MathML is a failed web standard by pcwalton on Thursday April 07, 2016 @11:33AM (#11448056)
Web browsers implement all of this nowadays. In fact, OpenType GSUB ligatures in particular go far beyond what TeX supports.
Re:MathML is a failed web standard by hansen on Thursday April 07, 2016 @09:23AM (#11447007)
But that begs the question why web browsers don’t implement this. Is there a technical reason or did at some point some people decided that decent text rendering is irrelevant one should focus on other gimmicks?
Re:MathML is a failed web standard by TeMPOraL on Thursday April 07, 2016 @11:11AM (#11447847)
The Web started as a tool for rendering text and occasional images pretty much as soon as it comes out of the wire. TeX on the other hand, was meant to be a typesetting package which compiles textual description of the document into a beautiful printable form. That compilation takes noticeable time even today, I imagine it was unacceptably slow for the web back before. Also in TeX you deal with paper sizes, in browsers you deal with adjustable viewports of unpredictable size.

I guess that the Web just started simple and evolved from that, and then nobody bothered to remake it for prettier text.

Re:MathML is a failed web standard by Mikhail_Edoshin on Saturday April 09, 2016 @03:14AM (#11460319)
I remember an old publishing package, Ventura Publisher; the first time I saw it was 1990 or 91 maybe and then it was at v3. It was a very versatile publishing tool (all the perks of a professional typesetting package, tables, equations, floating illustrations; lots).

What's interesting is that it could separate the content and the styling information, so you could load the same content into two or more publications with different styles and get two different typesetting from the same source (e.g. one column small page for a book and two or three column large page for an article in a journal). And it was very easy to change the format or paper size: just change it and it would reflow the content accordingly. It didn't even took much time, as far as I can remember, and I'm talking about IBM PC 286 here.

So, truly, it's not a technical obstacle; web could have a much better typesetting engine working at high speed (and I'd say that it would be much better to imitate paged media instead of scrolling; scrolling is really inconvenient for reading). It's just that it grows wildly and in all directions at once; it tries to be a "semantic" storage, a rendering medium, and an application engine at the same time, and is not particularly good at any of this.

Re:MathML is a failed web standard by sp332 on Thursday April 07, 2016 @11:00AM (#11447770)
I don't think HTML-typeset math has to look bad. e.g. http://www.deeplearningbook.org/contents/linear_algebra.html Well this particular example is auto-generated and the code looks terrible, but it's not hopeless to get nice math without TeX.
Re:MathML is a failed web standard by jahewson on Thursday April 07, 2016 @03:25PM (#11449898)
Compared to the amazing complexity of OpenType layout for complex scripts, mathematical typesetting is pretty simple. It's just not been a priority for the browser vendors, in the same way that we now have amazing technologies like WebRTC and WebGL but managing bookmarks still sucks.

It might "simply be" the case (well, in fact it is) that TeX is simply really old and doesn't lend itself well to concepts it predates such as dynamic reflow, etc...

Re:MathML is a failed web standard by IshKebab on Thursday April 07, 2016 @05:29AM (#11445947)
All good points, it would be insane to include a full TeX engine in the browser.

But for just rendering equations, I don't think you can beat TeX for ease of use. And most of the criticisms then don't apply - you can void the insane macro system, it doesn't require multiple passes, etc. I guess lack of CSS support could still be an issue.

Re:MathML is a failed web standard by PaulTopping on Thursday April 07, 2016 @11:18AM (#11447920)
Good answer. TeX is an input language and is fairly good at what it does for mathematicians. From a programming language and systems point of view, it is an ancient, ad hoc mess. TeX could be used as a computer representation, but it fails for that purpose for lots of reasons, several of which you mention here.
Re:MathML is a failed web standard by criddell on Thursday April 07, 2016 @10:15AM (#11447391)
> TeX doesn't have...

Is that due to implementation or the specification?

I used TeX a few times back in the mid-90's and something about it really clicked with me. The documents I made with it are easily the most attractive documents I've made.

Since then, I've wondered why TeX isn't used for ebooks and thanks to your comment, now I know.

Re:MathML is a failed web standard by pcwalton on Thursday April 07, 2016 @02:31PM (#11449458)
There is no spec for TeX as far as I know: it's defined by its (effectively frozen) implementation.
Re:MathML is a failed web standard by ocschwar on Thursday April 07, 2016 @01:58PM (#11449203)
OMG.

If your equations require concurrency to render, you're either a genius or insane. Or both.

Re:MathML is a failed web standard by pcwalton on Thursday April 07, 2016 @02:30PM (#11449452)
It's not that we need parallelism for layout to work. Rather it's that, in 2016 with Moore's Law over, new standards for performance-critical things ought to consider parallelism so they can continue to scale in the future.
Re:MathML is a failed web standard by stshine on Thursday April 07, 2016 @05:55AM (#11446053)
Thanks, now I know I don't need to spend time to study the layout system of TeX.
Re:MathML is a failed web standard by spicyj on Thursday April 07, 2016 @02:48AM (#11445226)
TeX is analogous to Presentation MathML but doesn't solve the accessibility concerns because the semantic intent of the TeX source isn't always clear. (How do you read a \phantom{}? Or how can you know that "\left( 7 \atop 3 \right)" should be read as "7 choose 3"?)
Re:MathML is a failed web standard by leereeves on Thursday April 07, 2016 @05:27AM (#11445931)
TeX has "{n \choose k}".

(Replaced by "\binom{n}{k}" in LaTeX with amsmath.)

Re:MathML is a failed web standard by JadeNB on Thursday April 07, 2016 @09:26AM (#11447026)
The fact that semantic commands are available in TeX doesn't change the fact that it is, unabashedly, a display rather than a semantic language. Knuth's goal was to create a language to facilitate beautiful typography, rather than one directly for expressing mathematical meaning.
Re:MathML is a failed web standard by leereeves on Thursday April 07, 2016 @09:56AM (#11447258)
Hence amsmath.
Re:MathML is a failed web standard by Smaug123 on Thursday April 07, 2016 @09:30AM (#11447055)
You should define your own commands and then use them, in preference to directly using markup. For example, at the start of my essay on non-standard analysis, I define some commands:

- "\near" as a synonym for "\simeq"

- \newcommand{\hyp}[1][\mathbb{R}]{\prescript{*}{}{#1}}

- \newcommand{\powerset}{\mathcal{P}}

This way you can change the notation easily and all-at-once if you need to, as well as making the semantics clear to the source-reader.

Re:MathML is a failed web standard by ga6840 on Thursday April 07, 2016 @05:10PM (#11450751)
I think we do not need semantic representation in HTML case at all. For example, f(x+1) can be a multiplication, or a function, but should we write something like \function f (x+1) ? I think knowing the layout similarity with query is enough for math-ware search engine to identify similar math expressions. Adding too much in Math HTML standard is not helpful but redundant.
Re:MathML is a failed web standard by spicyj on Thursday April 07, 2016 @05:19PM (#11450814)
For sighted users it may be possible to differentiate, but whether "f of x plus 1" or "f times x plus 1" is read aloud is a significant difference.
Re:MathML is a failed web standard by ga6840 on Thursday April 07, 2016 @07:39PM (#11451568)
What I really want to say is whether f(x+1) is function or multiplication does not matter that much in terms of both browser presenting and math-aware search, moreover, extracting semantics can be done by algorithm from context. Considering that few author want to annotate on their expression semantic, and adding semantic does not really help math-aware search, I argue for the necessity for bringing math semantic notation into WEB.
Re:MathML is a failed web standard by asdfaoeu on Thursday April 07, 2016 @02:54AM (#11445251)
The same way a sighted person does?
Re:MathML is a failed web standard by spicyj on Thursday April 07, 2016 @02:58AM (#11445262)
Yes, you could try to build algorithms that turn that markup into semantic meaning but now we're almost talking about computer vision. I don't think a solution like that is likely to ever work reliably, and it's better to encode the semantic meaning so that it doesn't need to be re-derived.
Re:MathML is a failed web standard by evincarofautumn on Thursday April 07, 2016 @06:10AM (#11446115)
I think they meant that a person needs to interpret “two numbers arranged vertically between parentheses” according to context, regardless of whether they’re sighted.

Having more semantic information in that scenario would help the sighted just as much as the visually impaired—imagine hovering over an unfamiliar notation with your mouse and seeing it explained.

Re:MathML is a failed web standard by laughinghan on Saturday April 09, 2016 @08:33PM (#11464165)
The other reply made the same point I'm about to make, but I think it's worth clarifying.

Specifically, just like a sighted person has to determine from context whether "a(b)" is function application or variable multiplication, a blind person can be asked to determine from context whether "a left-parenthesis b right-parenthesis" is function application or variable multiplication.

No AI or CV is required for such a reading algorithm. It's unfortunate that this reading algorithm doesn't quite match what two mathematicians would say if they were conversing with each other, but there's at least one good reason to believe this is still a useful reading algorithm: it's exactly the system used by blind mathematician Abraham Nemeth with his readers, called "mathspeak":

    The speech generated by this protocol is not exactly what a 
    professor in class would use, but it is absolutely unambiguous 
    and results in a perfect Nemeth Code transcription. It avoids 
    largely unsuccessful attempts by a reader to describe the 
    notation he sees, accompanied by the shouting and gesturing that 
    such attempts at description engender.
http://www.nfbcal.org/s_e/list/0033.html

(Nemeth notably created the Nemeth Braille Code for Mathematics, which is part of Unified English Braille and is probably the most widely used Braille code for math. MathSpeak hasn't enjoyed the same level of adoption, but only because there's no standard, MathPlayer, VoiceOver etc all have their own ad hoc rules for how to read math.)

(Strictly speaking the example I gave was a verbose variant of the system described in the email: http://www.gh-mathspeak.com/examples/NemethBook/?rule=18 ) [2]:

Re:MathML is a failed web standard by spicyj on Sunday April 10, 2016 @03:01PM (#11467615)
That's interesting, thanks for the references. I wonder if this is applicable to screen readers as well as Braille?
Re:MathML is a failed web standard by laughinghan on Monday April 11, 2016 @02:50PM (#11474111)
Oh, I was talking about screen readers the whole time, except for an aside that the speech rules system I was discussing was created by Nemeth who is known for his Braille system. Other than that though, I wasn't talking about Braille at all.
Re:MathML is a failed web standard by majewsky on Thursday April 07, 2016 @06:09AM (#11446110)
The problem is that mathematical notations can vary from topic to topic, from university to university, even from office to office inside a university department, even within the same lecture of a single professor. (Been there: "Notation will be different in this chapter since I've copied it from another author's paper.")
Re:MathML is a failed web standard by ubernostrum on Thursday April 07, 2016 @04:07AM (#11445556)
I'd imagine any real solution would actually be akin to ruby markup, with the author of the content needing to supply it since there will be cases where it simply cannot be usefully deduced by a browser.
Re:MathML is a failed web standard by elcapitan on Thursday April 07, 2016 @04:23AM (#11445623)
> A side benefit would mean that every browser, and every system, in the world would have TeX installed!

Is to run that giant heap of probably not sandboxed or security-audited code in every client actually a thing I would want to have? I mean people are paranoid about js doing unwanted things, but a large distribution of tex code running inside the browser, really?

Re:MathML is a failed web standard by pjc50 on Thursday April 07, 2016 @07:37AM (#11446428)
TeX's bug bounty and the credentials of its author are good reasons why it's probably one of the most reliable pieces of such code that you might have.
Re:MathML is a failed web standard by nailer on Thursday April 07, 2016 @09:15AM (#11446954)
Knuth has an older and more narrow concept of 'bug' than the current common definition.
Re:MathML is a failed web standard by elcapitan on Thursday April 07, 2016 @09:20AM (#11446978)
A "bug" in relation to the functionality of a layout software is also vastly different from battle-hardened code in the field of security.
Re:MathML is a failed web standard by IshKebab on Thursday April 07, 2016 @05:23AM (#11445914)
You can already render LaTeX equations with javascript. It would be madness to include everything but a safe subset of commands that are commonly used to render maths would be fine.
Re:MathML is a failed web standard by Tomte on Thursday April 07, 2016 @03:06AM (#11445294)
There is no "math subset" of TeX. You would have to define it. Or include a full TeX engine including macro capabilities into web browsers.
Re:MathML is a failed web standard by IshKebab on Thursday April 07, 2016 @05:22AM (#11445910)
It wouldn't be that hard to define a "maths subset". The fact that there are javascript LaTeX equation renderers clearly means other people have done it. Here's an example:

https://github.com/Khan/KaTeX/wiki/Function-Support-in-KaTeX

You just need to standardise it. There's no need to include all of LaTeX in a standard that is just for rendering equations.

Re:MathML is a failed web standard by dspillett on Thursday April 07, 2016 @05:34AM (#11445970)
> widely-used markup language for mathematical formulae; it's called TeX.

For display yes, though it is far larger in scope than that and I wouldn't want to teach someone TeX just for a few formulas, and it is geared for display and not manipulation.

MathML was intended to be just for math type markup so is more concise in that respect, and IIRC was intended to allow automated manipulation in an easy manner (I wouldn't want to do it by hand due to the verbosity of it all, but understanding and manipulating the structure in code must be easier than trying to interpret TeX).

Re:MathML is a failed web standard by therealmarv on Thursday April 07, 2016 @03:10AM (#11445318)
you cannot compute TeX... there are two versions of MathML: presentation MathML (which is like TeX) which shows only the look. And there is content MathML which describes semantic. So you are comparing only one side of the medal with TeX ;) See here https://en.wikipedia.org/wiki/MathML#Content_MathML

But I agree TeX is easier to write and read if you only care about the look and feel.

Re:MathML is a failed web standard by spankalee on Thursday April 07, 2016 @10:49AM (#11447678)
I made a set of essentially <math> web components that render with KaTeX: https://github.com/justinfagnani/katex-elements

You use them like so:

    <katex-inline>c = \pm\sqrt{a^2 + b^2}</katex-inline>
Re:MathML is a failed web standard by spot on Thursday April 07, 2016 @12:59PM (#11448772)
we also use katex in beaker and it's great. very fast, not as complete as mathjax (also good and we used to use it). https://github.com/twosigma/beaker-notebook
Re:MathML is a failed web standard by hughw on Thursday April 07, 2016 @10:46AM (#11447646)
You could put TeX code in a script tag

  <script type="application/x-tex">
    ...TeX code...
  </script>
and process it using a javascript TeX-to-DOM processor... seems likely somebody, somewhere, has done that?

Update: I just read the rest of the comments and discovered KaTeX.

Re:MathML is a failed web standard by 1ris on Thursday April 07, 2016 @05:49AM (#11446032)
TeX is not a markup-language. It's a (actually two) turing-complete, proprietary (not defined by anything than it's implementation) programming language.

Having a context-free representation is IMHO a necessity for processing untrusted inputs (e.g. webpages). It also makes it a way faster.

Re:MathML is a failed web standard by StreamBright on Thursday April 07, 2016 @05:55AM (#11446056)
I don't think that proprietary applies here.

proprietary adjective 1. relating to an owner or ownership.

2.(of a product) marketed under and protected by a registered trade name.

None of the above is true to TeX. What am I missing?

Re:MathML is a failed web standard by 1ris on Thursday April 07, 2016 @06:19AM (#11446141)
In a more liberal sense the opposite of "open standard".
Re:MathML is a failed web standard by ealloc on Thursday April 07, 2016 @09:40AM (#11447128)
I wouldn't describe TeX as a "standard", but it's pretty hard to argue that it's "closed": TeX is arguably the best documented program in history!

Knuth wrote it using his novel "literate programming" technique in which the source code is embedded in the documentation. Every 4-5 lines of source code has roughly a paragraph of explanation. That source/documentation is published for anyone to read as Knuth's "TeX: The Program" book, accompanied by his "TeXBook", a couple hundred pages each.

That documentation has definitely encouraged all the people reimplementing the TeX layout algorithms, for example MathJax and matplotlib for math layout, as well as a number of alternative tex implementations.

Re:MathML is a failed web standard by Mikhail_Edoshin on Friday April 08, 2016 @03:33PM (#11457255)
I wouldn't call it easy reading though :) By the way, it's written in Pascal, while all current implementations, afaik, are rewritten in C.

Also, I found "TeXBook" very hard to follow; "The Program" is much more understandable. Every chapter in "TeXBook" starts with a few paragraphs of relatively simply text and then descends into a bunch of additional paragraphs marked with "dangerous turn" signs that talk about things that were never mentioned before. As the author put it, they're explained "somewhere", but it's really hard to find that somewhere.

Re:MathML is a failed web standard by StreamBright on Thursday April 07, 2016 @07:42AM (#11446448)
Why not use closed standard than, it is not ambiguous and exactly expresses what you would like to convey. Thanks for clarifying though.
Re:MathML is a failed web standard by JadeNB on Thursday April 07, 2016 @09:24AM (#11447014)
I don't think that it's a closed standard either. Rather, like Perl 5, it seems to be a non-standardised, or, perhaps less pejoratively, implementation-defined language.

On the other hand, somewhat like Perl, it is also a language intended from its beginning to be extended. Knuth has said that he never expected things like LaTeX to be built on top of TeX; he rather thought that people would hack directly on the TeX source as necessary.