3 ms·
I'm certainly ignorant on this, but why are we stuck with JavaScript? Seems like such a huge crutch, something people have been working to fix, or avoid, yet he
by viperscape 11y ago
I'm certainly ignorant on this, but why are we stuck with JavaScript? Seems like such a huge crutch, something people have been working to fix, or avoid, yet here we are still with it. Doesn't it make more sense to adopt the ffi model to gain access to things like sockets, files, canvas that the browser or even OS provides access to; similar to how you would program for mobile native apps. I don't understand the hold up of why we are stuck in this situation.
- ant6n 11y agoI'd say most of this is due to the issue of adoption. You can come up with a standard for native code, but if you can only run it in one browser that's basically useless. Even if all browser suddenly implemented some new native standard, then all existing browser instances that can't/won't be updated can't access your new shiny website. Another issue is that native code, assuming that it's secure, is still not portable across different architectures. So you still end up having to have some sort of VM anyway to ensure portability. That's basically where asm.js comes in. It's a static subset of javascript that allows it to be compiled, it becomes a VM. But since it is javascript, it will work on all existing browsers, they don't need to support a new standard. It'll just be slower.
- bobajeff 11y agoWhat do you mean? You can already code in other languages besides JavaScript. With Emscripten specifically you can use the C++ extern keyword to call JavaScript functions. Or are you wandering why you can't just run a high privileged system/machine specific binary directly from a web page?