0

What changes would have to be made to JavaScript to make it compilable. I don't mean to make into executable that still relies on interpreter - I mean so that it compiles into binary in the way that C compiles.

I expect the prototypal inheritance might be an issue - but I don't know.

Also, I am pretty sure that eval would not be possible (or desired).

Is there anything out there that is trying to do something like this?

Is it technically achievable?

Could JavaScript (with some small modifications) be used as to create efficient programs?


EDIT

I am specifically looking for something like what RPython is to Python - but for javascript.

It also appears that dynamic typing would be difficult/impossible for a compiled language as I want.

Billy Moon
  • 57,113
  • 24
  • 136
  • 237
  • I dont see the point in even attempting this, could you add an example to your question? – Undefined Aug 14 '12 at 10:25
  • I see javascript as the only (and still unlikely) candidate for a unifying language due to it's ubiquity. It would however need to overcome several fundamental problems to be used in non-browser context. One is performance, which I can only see improving by being compiled into bytecode like c does. – Billy Moon Aug 14 '12 at 10:29
  • http://stackoverflow.com/questions/1118138/is-there-a-native-machine-code-compiler-for-javascript – eljenso Aug 14 '12 at 10:29
  • It's worth noting that many JavaScript engines already depend on Just in Time compilation. *"The [IonMonkey] compiler can emit fast native code translations of JavaScript functions on the ARM, x86, and x86-64 platforms."* - http://en.wikipedia.org/wiki/SpiderMonkey_%28JavaScript_engine%29#Internals – Yi Jiang Aug 14 '12 at 10:29

1 Answers1

2

I don't think there's any issue with the prototypal inheritance. Indeed, eval might not work unless there was some sort of JS-VM that would compile it on the fly.

As for what it would need to be actually useful, I would rate the ability to call functions from C/C++ libraries as most important. Without that, you wouldn't be able to do anything useful.

Vlad Ciobanu
  • 1,473
  • 1
  • 11
  • 11