JavaScript can be faster in some tasks. Even if JS is 2x slower in another task, it uses 3x less memory than Java.
Which costs more, double CPU time or triple memory requirement?