Firefox changes, and languages

bearophile bearophileHUGS at lycos.com
Tue Nov 1 21:57:46 PDT 2011


This blog post describes some recent work to reduce RAM used by Firefox (that is partially written in C++ and partially in JavaScript):

http://blog.mozilla.com/nnethercote/2011/11/01/spidermonkey-is-on-a-diet/

The blog post describes operations that a well designed low-level language has not just to allow (as C/C++ do already), but to make easy, rather short to write, and as much safe as possible:

>I mentioned that many Shapes are in property trees.  These are N-ary trees, but most Shapes in them have zero or one child;  only a small fraction have more than that, but the maximum N can be hundreds or even thousands.  So there’s a long-standing space optimization where each shape contains (via a union) a single Shape pointer which is used if it has zero or one child.  But if the number of children increases to 2 or more, this is changed into a pointer to a hash table, which contains pointers to the N children.  Until recently, if a Shape had a child deleted and that reduced the number of children from 2 to 1, it wouldn’t be converted from the hash form back to the single-pointer.<

In C/C++ such things are possible, but they require a lot of care, because they are rather bug-prone, and you have to do all by yourself, manually. A better designed low-level language has to do better if it wants to be better than C/C++.

Mozilla is developing Rust, that is a system language, but I don't know how much good it is for such purposes.

Bye,
bearophile


More information about the Digitalmars-d mailing list