Live data from Hacker News

JavaScript: The Modern Parts

amontalenti.com

11–20 of 122 posts

Re: JavaScript: The Modern Parts

#11

I have some ES6 compliant JavaScript to run on the browser. Now I would like to compile it into web-assembly and serve that from a server to the browser, to make it faster to run and download. Is that possible with the modern JavaScript tools?

Depends on the specifics of your needs. Web-assembly is still slower than the V8 JIT compiler for use cases where you want to interact with the DOM. Interaction with the DOM, of course, is one of the main reasons to deliver code to a browser. But if you need to, say, create a cryptominer in the browser, then a TypeScript variant of JavaScript can target WebAssembly. You are trading out a superb JIT compiler with look-ahead and runtime optimizations for a relatively immature compiler, however.

If you want your process to run on the server, and merely pass the result to the client, you can compile JavaScript to C, and then to a binary, with QuickJs. Most folks will just use Nodejs, however (which also uses V8)

Re: JavaScript: The Modern Parts

#12
post #2

What's the view that TypeScript is the modern Javascript?

TypeScript adoption has been swift and decisive. In 2019, the majority of js developers that take surveys use TypeScript.

Edit: Mea culpa. I got my numbers mixed up, or whatever source I thought I remembered just doesn’t exist. 46% in 2018 (state of js) says nothing about 2019, and is not a majority. That 46% is also backed up by a similar survey that npm ran. It’s worth adding though, I think, that js devs benefit from ts type inferencing and IDE support even if they aren’t using it directly

Re: JavaScript: The Modern Parts

#13
post #2

What's the view that TypeScript is the modern Javascript?

TypeScript adoption has been swift and decisive. In 2019, the majority of js developers that take surveys use TypeScript. Edit: Mea culpa. I got my numbers mixed up, or whatever source I thought I remembered just doesn’t exist. 46% in 2018 (state of js) says nothing about 2019, and is not a majority. That 46% is also backed up by a similar survey that npm ran. It’s worth adding though, I think, that js devs benefit f…

> In 2019, the majority of js developers that take surveys use TypeScript.

TS is quite popular, but this cannot possibly be representative of the general population of js devs, not even close.

it's more like ES6 >> JSX >> TS >> Flow.

Re: JavaScript: The Modern Parts

#14

I have some ES6 compliant JavaScript to run on the browser. Now I would like to compile it into web-assembly and serve that from a server to the browser, to make it faster to run and download. Is that possible with the modern JavaScript tools?

From what I've heard WASM isn't a viable alternative in the first place. It's good for compute-heavy tasks, but the overhead involved in going from browser to native to browser is too much to make WASM an alternative to what JavaScript is usually used for -- rendering interfaces and making pages interactive.

Re: JavaScript: The Modern Parts

#15
post #8

Earlier quoted context omitted.

Care to elaborate? "Modern" javascript runs just fine in your plain old browser.

Parent is talking about all the vulnerabilities and slowness that can come with it. Fair enough, it runs, but it can also open the door to fingerprinting and other weird nasties. Particularly anything reliant on the `npm install` way of managing dependencies is a potential risk from both server and client point of view.

Where is parent talking about any of that?

What about today's javascript lends itself to fingerprinting any more than javascript from twenty years ago?

Re: JavaScript: The Modern Parts

#16

I have some ES6 compliant JavaScript to run on the browser. Now I would like to compile it into web-assembly and serve that from a server to the browser, to make it faster to run and download. Is that possible with the modern JavaScript tools?

Web assembly isn't inherently faster than well-optimized Javascript. You save the parsing and compilation overhead of JS, but right now the focus with web assembly isn't on speed yet.

You also can't just compile any Javascript to WASM, the closest thing to this is AssemblyScript:

https://github.com/AssemblyScript/assemblyscript

This compiles a subset of Typescript to web assembly. And you have to take "subset" seriously here, web assembly is very limited in how memory is managed, you can't just drop your Javascript in there and get web assembly out.

Re: JavaScript: The Modern Parts

#17
post #2

What's the view that TypeScript is the modern Javascript?

TypeScript adoption has been swift and decisive. In 2019, the majority of js developers that take surveys use TypeScript. Edit: Mea culpa. I got my numbers mixed up, or whatever source I thought I remembered just doesn’t exist. 46% in 2018 (state of js) says nothing about 2019, and is not a majority. That 46% is also backed up by a similar survey that npm ran. It’s worth adding though, I think, that js devs benefit f…

Source on your claim? It was about 50% on last year’s State of JS: https://2018.stateofjs.com/javascript-flavors/overview/

Re: JavaScript: The Modern Parts

#18

>Understanding webpack, and why it’s important Not sure how Webpack is being attributed as being a part of Javascript here. It's a bundler, with Javascript support being one small piece in a much larger puzzle. It's not even the only bundler out there, JSPM is currently in beta which goes in a different direction than Webpack, then you have Parcel and other options as well. >Understanding babel, and why it’s importan…

I agree with your assessment, but the “major” web framework ecosystem (React, Angular, Vue) all use webpack as a de facto part of their toolchain. And webpack, in turn, relies on babel. Other bundlers are commonly used as part of plugin system.

Regardless of transpiler tooling, the tooling is how most people are confident in using the most modern variants of JavaScript code. So it’s an important part of the modern js story.

Re: JavaScript: The Modern Parts

#19

Earlier quoted context omitted.

TypeScript adoption has been swift and decisive. In 2019, the majority of js developers that take surveys use TypeScript. Edit: Mea culpa. I got my numbers mixed up, or whatever source I thought I remembered just doesn’t exist. 46% in 2018 (state of js) says nothing about 2019, and is not a majority. That 46% is also backed up by a similar survey that npm ran. It’s worth adding though, I think, that js devs benefit f…

> In 2019, the majority of js developers that take surveys use TypeScript. TS is quite popular, but this cannot possibly be representative of the general population of js devs, not even close. it's more like ES6 >> JSX >> TS >> Flow.

I don't understand why jsx is in your comparison, although I agree with your assessment.

To be clear there are a gazillion Js projects that don't use react.

Re: JavaScript: The Modern Parts

#20

I have some ES6 compliant JavaScript to run on the browser. Now I would like to compile it into web-assembly and serve that from a server to the browser, to make it faster to run and download. Is that possible with the modern JavaScript tools?

From what I've heard WASM isn't a viable alternative in the first place. It's good for compute-heavy tasks, but the overhead involved in going from browser to native to browser is too much to make WASM an alternative to what JavaScript is usually used for -- rendering interfaces and making pages interactive.

> From what I've heard WASM isn't a viable alternative in the first place. It's good for compute-heavy tasks, but the overhead involved in going from browser to native to browser is too much to make WASM an alternative to what JavaScript is usually used for -- rendering interfaces and making pages interactive.

I don't think that's the case anymore: https://dassur.ma/things/is-postmessage-slow/

Post reply on HN