4 ms·
HN folks whine about browser monoculture but it was this decision (and thousands more like it, but this one is pretty big) that meant you cannot have a simple b
by stickfigure 5y ago
HN folks whine about browser monoculture but it was this decision (and thousands more like it, but this one is pretty big) that meant you cannot have a simple browser implementation. Any 2nd year CS student could write an X(HT)ML parser. Writing an HTML5 parser requires FAANG resources.
- jazzyjackson 5y agoCould you elaborate at all on what makes HTML5 so much more difficult to parse?
- mynameismon 5y agoFrom what I know and have read, disregard for the strictness that comes with XML and XHTML makes HTML5 parsers handle tons of edge cases (https://wiki.whatwg.org/wiki/HTML_vs._XHTML https://wiki.whatwg.org/wiki/HTML_vs._XHTML)
- josefx 5y agoFor example HTML has quite a few special cases around self/implicit closing elements and many browsers/websites around did not fully agree on how that should work. So not only do you have to implement and verify these closing rules, you have to gracefully handle every page that gets them wrong either because past browsers got them wrong or because these special cases are so pointless that no one sane actually memorizes them.
- Macha 5y agoInvalid XHTML: Throw an error, yell at the user, who should just be the author since broken XHTML shouldn't have been allowed make it to the end user. "Invalid" HTML5: Please refer to section X.Y for the heuristics to apply in this scenario. "Invalid" HTML4: Uhh, just do whatever? But probably you need to do whatever the other browsers do. Implementing the other behaviours is more work than not implementing them, and may be more difficult if your internal data structures don't match those of the browser for which it was originally introduced as expedient or even emergent behaviour.
- spiralx 5y agoHTML5 is expressible as valid SGML with some exceptions such as ARIA and data-* attributes. And SGML, which is a super-set of XML, has rules for both optional elements - e.g. HEAD - and for elements with optional closing tags - e.g. P. http://sgmljs.net/docs/html5.html http://sgmljs.net/docs/html5.html
- Macha 5y agoPart of the XML motivation was for something simpler than SGML. SGML has no opinions on rendering, since it's just a generic markup language. Nor does it have opinions on "what do with a hr that's a direct descendant of the table despite not being permitted", to pick the first example from the spec (it should be treated as a preceding sibling).
- cxr 5y ago> Writing an HTML5 parser requires FAANG resources. No it doesn't. The HTML5 parsing algorithm is well-defined, and parsing it according to the spec is not an order of magnitude more difficult than properly handling XML according to its spec. What makes browsers difficult does not come from the part that involves ingesting the initial response payload and building it into a tree in a spec-compliant way—what makes things difficult is all the other stuff involved with creating and maintaining a browser.