6

I often wonder why JS is the only language that has the native support from browsers and native built in DOM apis?
The world has come up to a saturation point for so many techs:
- if a software is needed to be created for mobile, it must go through 1 layer of java (aka JVM) or objective C (i guess? for ios) before being understood by the CPU

- if a software is needed to be run via browser( which itself is made to run on jvm, objective c or machine language), it must go through one layer of js interpretters before being understood by the CPU

all the OS are made on C but the application and application platforms are made on specific languages. I wonder why can't there be a single application platform, if all of them(browser, JVM,objective C and whatever .exe apps run on) are doing the same thing and are equally mature to handle every usecase?

Comments
  • 3
    I find the world of backend to be very cool in this space. there are many platforms to build and run the software : java, python, c++,js, php,... so much. and its because their underlying OS supports these. i wonder how cool it would be, if phones were also like those heroku or github action images : having a lot of languages installed on them by default and allowing devs to create a software in any of the programming language(with ui capabilities)
  • 6
    Ever heard of WebAssembly?
  • 4
    For browsers there have been multiple attempts but with multiple companies no one was too keen on adopting a lang designed by another for the fear that the creator would get some advantage.

    Web assembly grew sort of on the side until it was popular enough to win general acceptance.
  • 1
    Also, an app does not actually have to go through java. Heard of Android NDK? Parts of the app can have pretty much a bare metal access.
  • 3
    None of these apart from the browser actually form a closed abstraction, they're all just environments expected to behave in a particular way with abundant ways to exit the environment to leverage platform specific optimizations and features. And even in the browser, the actual application code could be WASM which is still an abstraction layer but a very thin one at that.
  • 1
    An OS written in C is never a closed abstraction just because of the C part, because an inalienable part of an OS is to load binary data and execute it, which is UB. You can sandbox such an app using particular hardware features such as virtual memory, but then the sandbox is on the hardware level.
  • 0
    @lbfalvy a browser is sort of like a VM nowadays, as far as I understand 🤔
  • 1
    @iiii more like a common language runtime, the browser does not have isolation like a VM.

    So more like the clr or java runtimes snd supporting either javascript or wasm.

    Wasm especially is very much like il or java byte code (but I do think it has some compiled stage also)
  • 0
    @Voxera jvm is considered a VM, no? It's even in the name. I don't mean it's emulating hardware, but it's a byte code abstraction over the hardware. Wasm actually shows that quite literally.
  • 4
    It's actually the other way around. It's not "JS is the only one with access to browser features", instead it's "browsers only allow JS to use those feature by refusing to implement support for any other language". There were attempts to use other languages - IE at one point supported VB. There were also "middle" layers, like Flash, Java applets or Silverlight. All of them died out either due to vendor lock (VB only worked on IE), or due to being too insecure and buggy to use

    There were also attempts at bridging the gap by transpiling languages like Java directly to JS, but you can guess how that went based on how popular those solutions are.

    Now there is Web Assembly (wasm), which promises to let anyone write in any language they want and compile down to a browser-understandable byte code, similar to how JVM works. It's been growing slowly, but steadily, and most modern browsers have at least some support for it. Hopefully it doesn't die out like all the previous attempts...
  • 4
    "wonder why can't there be a single application platform"

    https://xkcd.com/927/

    that's why.
  • 3
    JS wasn’t the solution, it was just the survivor.
  • 2
    @fiftyhz js was the first and original.
  • 1
    @tosensei oh, that’s very good!
Add Comment