Hacker News new | ask | show | jobs
by DeathArrow 1497 days ago
>Isn't that what we have? JavaScript is a VM-based sandbox.

JS is unfit for the task. It is a dynamic scripting language introduced by Netscape for the only purpose of adding a bit of interactivity to web pages, not to create large apps.

.NET and Java are much better for the task. The VMs support better languages with better libraries and more sane ecosystems. And the performance would be much better than that of JS.

And is easier to write an application using Xamarin or MAUI then using React.

When you write Java or .NET apps you write to target a computer which is a much better model for the apps then Web.

With "app languages" you can write apps better, faster while having better performance and more capabilities than using dynamic scripting languages like Javascript, Lua or Python.

Operating systems and browsers are apps too. And we don't use Javascript to write them.

You can write anything in any Turing complete language. But you'll be a fool if you attempt it for anything but fun.

1 comments

I think what your describing is mainly your preference - which isn't in itself a bad thing, the lack of real diversity in browser scripting is a problem that is slowly being solved as WASM becomes a more viable target.

That said, some of your statements seem to be simply false. Javascript engines are at this point about as heavily optimised as Java and .NET runtimes, and a quick scan through a few benchmark sights seems to indicate that, with a few exceptions, the two perform similarly well. Certainly, there is no guarantee that a naïve implementation in Java will necessarily be faster than a similar one in Javascript, in the way one night expect with e.g. C and Python.

Moreover, JavaScript is regularly used in all sorts of applications and systems - Gnome, for example, uses JavaScript for various plugins and utilities, an increasing number of applications are written using Electron or other webview-based technologies, even browsers use JavaScript for a significant number of controls (e.g. the devtools for most browsers are written in JavaScript). So clearly a lot of people see value in writing all sorts of applications in JavaScript.

The rest of your complaints seem to be largely your opinion - again, perfectly valid, but other people will have different opinions, and so the value proposition for JavaScript will be different for them. For example, for me, building something in React is a cinch, whereas Xamarin would take a lot more work. And the ecosystem of JavaScript may not be perfect, but it's very well oriented towards building front-end apps, something that isn't as true of Java.

JavaScript VMs are inherently hampered by language design choices in JS. The dynamic typing and prototype based objects limit JIT based optimization for the full JS massively. Java and .NET have fully static typing which allows their JITs to be completely certain when they are translating code. JS JITs constantly have to add overhead in the form of escape hatches to deoptimized code if e.g. expectations about variable types are being broken at runtime.