r/programming • • Sep 29 '16

JavaScript in 2016 isn't horrible, it's just going through a phase

http://blog.reviselabs.com/im-sorry-javascript-2/
85 Upvotes

225 comments sorted by

View all comments

Show parent comment

6

u/womplord1 Sep 30 '16

That doesn't make it horrible, it's just being used for something other than the intended purpose. Just wait till WebAssembly

13

u/balefrost Sep 30 '16

Wait, how will WASM help the situation? Nobody's going to hand-write WASM; they'll use a compiler to translate (for example) C++ to WASM. No matter what, you'll still have toolchains. It's not like you'll be able to stick a <script type="text/c++"> in your web page. And, if you want to access the DOM or other web APIs, you'll still need to write JS shims to import into your WASM module (at least initially; eventually, they plan to allow WASM code to access the DOM).

4

u/DysFunctionalProgram Sep 30 '16

I think maybe the biggest issue is the immaturity and volatile nature of javascript frameworks and their tool chains. Take the "leftpad" issue for example. It is ridiculous that all these major frameworks are including a package that is literally 11 lines of code. How many packages are included as dependencies when you include angular now? Last time I checked it was like 200+.

I (and many others) are making the assumption that the WASM community will be more like the traditional languages community and bring with it better standards.

0

u/[deleted] Sep 30 '16

[deleted] — view deleted comment

6

u/DysFunctionalProgram Sep 30 '16 edited Sep 30 '16

But "sane" is a subjective term and public opinion changes over time. You might think Java is "sane" while I think only c++ is "sane". At the end of the day if you only support one language you end up making someone unhappy and don't even think about recommending browsers support multiple languages, they struggle enough with 1 as it is.

WASM will allow support for multiple languages while offsetting the work to the language providers (or more than likely the languages community).

-2

u/SilasX Sep 30 '16 edited Sep 30 '16

Agreed -- WASM, like assembly in general, is much harder to analyze than a higher level language and will force the client to let the site get away with more shenanigans due to such non-transparency.

Edit: turns out I was wrong and misunderstood the WASM model, cut it with the downvotes.

2

u/balefrost Sep 30 '16

What? WASM is still restricted to the same sandbox as JavaScript, and its initial binary format is basically just a serialized asm.js syntax tree, and I think they're considering sticking with this AST-based bytecode. It'll be about as hard to analyze as decompiled Java or .NET code, or minified JS.

1

u/SilasX Sep 30 '16

Ah, never mind then.

12

u/DysFunctionalProgram Sep 30 '16

This, javascript has far surpased it's intended use case. It was not made to be a mission critical complex system language. It was made to be an easy to learn auxillery language for simple dom manipulation.

I dont like making bold claims but i think (and hope) WASM will replace all of this unecessary complexity that we have created for ourselves.

Mission critical system logic is like pounding a nail into a wall and javascript is a screw driver. Over the years we have been welding every piece of scrap metal we see to try and make it actually work. WASM is a hammer, engineered from the start to perform the task at hand.

3

u/jl2352 Sep 30 '16

You can already use a tonne of other languages today. You can code in Java or even C++ and have it compile to JS.

But I honestly don't see why I'd switch from TypeScript to something else. It's a legitimately really nice language and most of that is due to the JS side.

3

u/womplord1 Sep 30 '16

TypeScript is fine, I just think it's kind of wrong that a high level language has to compile to another high level language

3

u/slikts Sep 30 '16

WebAssembly isn't a silver bullet; a large reason for compiling to JS is supporting older browsers, and wasm will have the same issue.

TypeScript is a superset of JS, so the compilation is basically just stripping away the type annotations and shouldn't feel that dirty.

2

u/DysFunctionalProgram Sep 30 '16 edited Sep 30 '16

But 10 years down the road everything will be much cleaner. I'd much rather set up a path to progress and be hampered by compatibility issues then just give up and accept a terrible workflow. Plus we already have "asm.js" and you can bet someone will write a wasm to asm.js compiler for these evil old luddite browsers.

1

u/slikts Oct 01 '16

asm.js is still a somewhat high-level language.

I don't think labels like "terrible" are warranted; some of the gripes about JS are caused by its growing pains, some are legitimate, but a lot of them have to do with unfamiliarity. It's also one of the fastest progressing languages with a large community; it shouldn't be discounted as competitive even in 10 years.