Hacker News new | past | comments | ask | show | jobs | submit login

> Why can't XUL vs DOM just be the same data with a fast C++ API and a slow JS API?

This is a great question! I'm not really qualified to answer it, but I'll give it a try.

My understanding is that the XUL tree is fast because it implements the XPCOM C++ nsITreeView[0][1][2] interface.

If you're writing a XULRunner program ...

(Firefox "is distributed as the combination of a Gecko XUL runtime — libxul, other shared libraries, and non-browser-specific resources like those in toolkit/ — plus a Firefox XUL application — mostly just the files in Contents/Resources/browser/, plus the 'firefox' stub executable that loads Gecko and points it at a XUL application", see [3])

..., XPCOM[4] allows you invoke those implemented interface methods directly from JavaScript.

XPCOM is a technology that, since the removal of XUL/XPCOM addons, is inaccessible to everyone except for Mozilla devs and those who write XULRunner programs using `firefox --app /path/to/application.ini`.

So, some XUL elements (like <tree>) implement an XPCOM interface that invokes native C++ (or rust, python, java, etc.) code, which is statically compiled directly into the Gecko XUL runtime.

Modern HTML5 elements, in general, must utilize the native interpreted browser DOM/JavaScript and cannot choose to implement/satisfy an arbitrary internal XPCOM interface. While I'm sure that Mozilla has figured out a way to make these elements fast (C++, Rust, I have no idea), you are always bounded by the limitations of the DOM.

So, my understanding is that, because we are relying on standards-compliant HTML5 elements which mutate the DOM, we cannot specify and implement new XPCOM interfaces ("with a fast C++ API") that could theoretically bypass the DOM — we /must/ rely on the "slow JS API."

[0]: https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/...

[1]: https://searchfox.org/mozilla-central/source/layout/xul/tree...

[2]: https://searchfox.org/mozilla-central/source/layout/xul/tree...

[3]: https://mykzilla.org/2017/03/08/positron-discontinued/#comme...

[4]: https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: