www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Firefox changes, and languages

reply bearophile <bearophileHUGS lycos.com> writes:
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
Nov 01 2011
next sibling parent Caligo <iteronvexor gmail.com> writes:
Nowadays everyone seems to be developing some new programming language.  I
just discovered Nu today:
http://en.wikipedia.org/wiki/Nu_(programming_language)
Nov 01 2011
prev sibling parent reply Caligo <iteronvexor gmail.com> writes:
And then there is Chapel, but I think you already know about it.  I've had
my eye on Chapel for a while.  I like its 'Configs' features, but that's a
small one.
Nov 01 2011
parent bearophile <bearophileHUGS lycos.com> writes:
Caligo:

 And then there is Chapel, but I think you already know about it.
I have presented Chapel here few times, but I have only written some small programs with it.
 I like its 'Configs' features, but that's a small one.
This small feature is quickly described at page 12 here: http://chapel.cray.com/tutorials/SC10/M10-2-Basics.pdf Syntax: config-declaration: config type-alias-declaration config declaration Semantics: - Like normal, but supports command-line - Must be declared at module/file scope Examples: config param intSize = 32; config type elementType = real(32); config const epsilon = 0.01:elementType; config var start = 1:int(intSize); % chpl myProgram.chpl -sintSize=64 -selementType=real % a.out --start=2 --epsilon=0.00001 It allows to give at compile-time the values of global constants (even floating point values, and even types) that are tagged with "config", and at run-time the values of global (module-level) variables. It's handy for the purpose Chapel programs are written, like to to parametrize physics simulation parameters. In D if you want to change the constants and you don't want to touch the source file modules, you have to write your values in a little text file, that the program "includes" as raw text. This is not handy. So the Configs feature is nice, for certain kinds of programs (D is useful for the same kinds of programs too). Bye, bearophile
Nov 02 2011