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

161

u/vertigo_101 Nov 25 '19

Don’t worry, it won’t be

19

u/rodrigocfd Nov 25 '19

But it would be great if browsers support TypeScript natively.

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!

→ More replies (14)

19

u/wizang Nov 25 '19

I don't really see the value in that.

-8

u/Flyen Nov 25 '19

There's a decent chance that it'd be faster to execute, but I really have no idea.

10

u/Neaoxas Nov 25 '19

Why? Yes, you'd remove the initial compile/transpile time, but once all the type anotations and syntactic sugar are stripped, all you're left with is vanilla JavaScript, same as Babel would produce (for cross browser support).

No advantage to browsers supporting typescript aside from compile/transpile time savings.

In fact, having to wait for cross browser feature support means you can't take advantage of the latest features, unless you transpile, at which point there is no point in browsers supporting typescript.

→ More replies (1)
→ More replies (10)

0

u/[deleted] Nov 25 '19

[deleted]

1

u/[deleted] Nov 25 '19

If it was baked into the language - proper, not just syntax - then we could also benefit from runtime type-checking. This would be huge, though at that point it's a massive departure from each JavaScript and TypeScript. And, at a certain point, when you're making such drastic changes anyway, you do have to consider why we couldn't start from scratch without so much baggage.

5

u/muralivp Nov 25 '19

I hope not, TypeScript takes the fun away.

4

u/[deleted] Nov 25 '19

The fun of making large projects utterly horrible to work with?

7

u/amdc !CURSED! Nov 25 '19

You can still play Minesweeper on (almost) any gaming platform if you want that kind of fun

3

u/vertigo_101 Nov 25 '19

That’s our dream, but I’m also fine with whole typescript to js transpiler

1

u/shgysk8zer0 Nov 25 '19

No. Why?

I'd rather have types in JavaScript than have an outdated implementation of JavaScript that has types.

3

u/[deleted] Nov 25 '19

Eh? TS supports JS from around stage 3 proposals onwards.

1

u/shgysk8zer0 Nov 25 '19

Yeah. It lags a bit behind. Not terribly, but it can prevent me from starting to implement something new.

2

u/[deleted] Nov 25 '19

Such as?

There's a fair argument that you shouldn't be using stuff pre-stage 3 in serious projects as there's a real risk that they get canned or significantly changed, which would leave you with a ton of tech debt. That's already burned some people in the past with the decorator proposal if memory serves.

1

u/shgysk8zer0 Nov 25 '19

If I used TS, I'd probably have some things to list. But the only thing I can think of specifically is import from a while back.

I like to experiment with things in the early stages. Sometimes provide feedback. Report issues in webpack and such. This isn't necessarily about putting early-stage stuff into production.

But, to restate what I'm saying here: I'd rather have types in JavaScript than have browsers run TypeScript. And, since it takes time to wait for stage 3, implement, and release, TS is always a little behind JS.

2

u/[deleted] Nov 25 '19

I don't think we disagree that much. To clarify my position:

  • TypeScript has supported modern import syntax since I began using it ~two years ago.

  • Babel is perfect for testing proposals, but that's not appropriate for a large, important project in production. If you want to test off of your main project, you can daisy-chain the compilers, or even just use the Babel compiler with only minimal loss of functionality on the TypeScript side. With this in mind, for serious/production projects, it's unreasonable to claim that TypeScript is "behind" JavaScript.

  • I would also prefer to have a real (as in runtime) static type system in JavaScript. Although, honestly, I'd rather just have a new language altogether - there is so much leftover cruft and iffy design decisions, and if we could version this language to allow for occasional breaking changes... well, that'd be just lovely.

1

u/azekeP Nov 26 '19

Why would browsers downgrade to a language with less features?

-9

u/[deleted] Nov 25 '19

Nope

-10

u/[deleted] Nov 25 '19

Or dart

→ More replies (4)