Use JavaScript or its wrappers (TypeScript, Dart etc.) just to glue modules written in C++ or other sane language, compiled into WASM. That's the future. JavaScript's role will be diminishing, paradoxically when it is now becoming an actually usable language, e.g. finally removing callback hell by async/await, adding some "borrowed" stuff from Scala etc.