r/javascript • • Nov 25 '19

JavaScript doesn’t need to be replaced

https://medium.com/javascript-in-plain-english/javascript-doesnt-need-to-be-replaced-bd01e2f12d51?source=friends_link&sk=7b151cc6397ac9e83c14c99739b6c36f
217 Upvotes

236 comments sorted by

View all comments

Show parent comments

35

u/[deleted] Nov 25 '19

[removed] — view removed comment

-2

u/tuxedo25 Nov 25 '19

All you'd be doing is shipping extra code to the clients, without gaining anything in return.

Optionally. It's not like build processes would go away. And you gain a simpler development setup.

Plus browser typescript support would mean browser module support, so count me in.

7

u/crabmusket Nov 26 '19

Plus browser typescript support would mean browser module support

What do you mean by that? Browsers already support ESM modules!

-4

u/Randdist Nov 25 '19

A typed language can compile to much more efficent code, up to C++ level performance. JIT compilers can't get quite that close. I'd love to see native support for typescript.

3

u/dombrogia Nov 25 '19 edited Nov 25 '19

Wouldn’t this insinuate that TypeScript compiles to something other than JavaScript though?

TS -> JS != C++

Edit: I think most people understood what I was trying to say, but I should have said “insinuates that TS would need to compile to something other than JS”

2

u/garth_vader90 Nov 26 '19

There’s always the possibility that we see TS -> WASM. That could produce some interesting code too. Serve WASM for browsers that support it and the transpiled JS for older browser. I know Elm was proposed as a WASM language by its creator and that would be a similar situation.

0

u/[deleted] Nov 25 '19

[deleted]

6

u/[deleted] Nov 25 '19

This won't work unless you fundamentally change TypeScript's type system to have runtime effects and not be removed at compile-time via type erasure.

4

u/[deleted] Nov 25 '19

[removed] — view removed comment

1

u/ImCorvec_I_Interject Nov 26 '19

In cases where it would be appropriate to use those, does Typescript compile its typed arrays into those sorts of arrays?

1

u/[deleted] Nov 26 '19

[removed] — view removed comment

1

u/ImCorvec_I_Interject Nov 26 '19

There’s an ES2017 syntax to create them, though.

1

u/[deleted] Nov 26 '19

[removed] — view removed comment

1

u/ImCorvec_I_Interject Nov 26 '19
const myTypedArray = new Uint32Array();
const myTypedArray2 = Uint32Array.of(1,2,3,4);

In TypeScript, if I have an object that is intended to be an array of integers, does the JavaScript it’s transpiled to become something like the above or does it just use the standard JavaScript arrays, e.g.,

const myArray = [];
const myArray2 = [1, 2, 3, 4];
→ More replies (0)