Just wondering if there can be numerous languages for a computer system which i guess is more higher in complexity then a browser, if they are many for every other platform then why not browsers?
I hope i am not being ignorant.
Browsers have been supporting Javascript for decades. This legacy language is the fuel for interactive websites, and some of which are not even maintained, yet they are popular. Ditching Javascript for the cost of users won't turn out good for browser vendors.
There can be other alternatives like WebAssembly, but it is not going to replace Javascript very soon. Though you can write code in different languages, and convert them to Javascript, using some transpilers, ultimately it comes to the point that the Javascript realm is second to none.
There are number of browsers like IE, Safari, Firfox, Chrome, etc. And they are not relied on JavaScript ie. you are not just limited to apply the JavaScript on the browser. But they can work ( run sites/server ) with different languages like JavaScript, PHP, C#, C++, Java, HTML, CSS, etc. It doesn't mean browsers must run with JavaScript.
For example, modern Google Chrome browser is based on V8 engine which is nothing but JavaScript and WebAssembly engine written in C++.
You can now ask why only V8 engine? No. There were many browser engines:
V8 is developed with more optimal performance especially for JavaScript as you know most of the websites today run with the JavaScript. You may read and see V8's benefits here.
Hope, this makes sense now.
There is, it's called WebAssembly. But while supported by major browsers, it is still growing, not being widely available a year ago. It still lacks features making it mostly useful for heavy computation (which is its strength anyway).
WebAssembly is meant as a compile-target, which means that programmers would usually write code in for example Rust, C++, Kotlin, ... which would be produce WebAssembly code to be run in the browser.
That way, many languages can be used, while browsers only need to support two. It'd be an impossible task for browsers to support all the languages that exist natively, as there are thousands.
Javascript is also used in this role (often with 'extension' languages like CoffeeScript or Typescript, but also different ones like Kotlin). But it's less suitable in that role because it was designed as a high-level language (and is overall not very well-designed anyway). That makes it slower, and awkward to compile to from lower-level languages (usually compiling is from higher to lower level).
So, there are starting to be alternatives. Browsers themselves will support two languages, one of which is meant to be generated by compiling other languages. But this will make it more viable for developers to use any language that supports WebAssembly as a target, which will probably be most of the big ones in the future.
Dwight Badua
Backend Developer
Because coding Javascript with support for multiple browsers in itself is already a hell. Sure, we have cross-browser solutions and polyfills, but this only abstracts the developer from all what's going under the hood. Now say we throw in a new browser scripting language (like what we've had over the years), developers would have to support multibrowser, multilanguage environments, and I can only imagine how exponentially difficult that could get. On top of that, the end user doesn't even care. All they need is consistent experience with their favorite browser - they stay in for the experience, not the technology.