Hacker News new | ask | show | jobs
by krapp 1267 days ago
When you're only using Javascript to mess with the DOM and do AJAX requests, instead of actual math, just having floats is perfectly fine. None of the things you're complaining about actually matter in the context Javascript was intended to be used for, which yes made it nice and simple.

For instance, no classes - all you need are objects, which can serve as maps, arrays and contain functions. Constructor? Loading the webpage. Destructor? Unloading the webpage. JQuery modules got a lot of flexibility and power out of a few simple features. One general syntax for function calls. Prototypes and all-global state made it simpler as well, even though modern enterprise programming eschews them because they make testing more difficult. All you needed to test javascript back in the day was f5 and the debug console. All you needed to handle dependencies was to upload a file and write a script tag, or maybe point to a CDN.

I agree with you completely about Typescript, but that's inevitable when the world insists one small, toy scripting language replace all existing languages and all domains - it has to do everything and please everyone and be as flexible as possible while still being bound to javascript's limitations at the end. But most people's complaints about javascript come from the (also inevitable) pain from trying to force it to be something it was never meant to be.

>If we add strong typing to JS that _is enforced by the runtime_ we may skip this compatibility ballast and have something more simple.

Then every runtime has to support two essentially incompatible languages and call them both "Javascript," and only one will work on the web for backwards compatibility reasons. That isn't going to happen. Just compile the language you actually want to use to WASM or native and leave JS alone.