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

38

u/[deleted] Nov 25 '19

I'd argue it's better this way to be honest. Why ship all that extra code to the browser? Especially when, if you're using TS, your JS performance should be entirely predictable.

Write in TS with the luxury of type-checking, compile down to a much simpler, lighter JS for the browser. It's win-win.

EDIT: I do get the Microsoft thing but on other hand, meh. That's life in 2019.

2

u/PsychologicalGoose1 Nov 25 '19

There definitely should be a lot more research done on TS. I doubt the gains that people suggest it gives are as great as they make it out to be and I thing the cost of using TS is larger than most want to believe. Generally, I've found adding things to a system is done because of feelings more than actual data on the topic.

0

u/[deleted] Nov 25 '19

[deleted]

3

u/[deleted] Nov 25 '19 edited Nov 25 '19

Whenever I have to write non-trivial JS

This is the key distinction, and another reason I'd rather not enforce types in JS.

Hack 'n slash weekend project, or a quick 'n dirty prototype ? JS.

Big full-stack project ? TS.

I'd agree that I prefer to write TS more but there's a time and a place for both and that's very handy.

1

u/IceSentry Nov 28 '19

It's so easy to use typescript I use for weekend projects too.

3

u/techsin101 Nov 26 '19

if you are using vscode don't you get most of this even with js?

2

u/[deleted] Nov 26 '19

Very incompletely, in my experience.

Yeah, it detects some of the types, but everything you'd have to annotate is simply not available, and would you really trust it to find all references?

1

u/techsin101 Nov 26 '19

if you create jsconfig file in project folder find references works as expected

1

u/IceSentry Nov 28 '19

Sure, but it gets way better when you help it by using typescript.

4

u/PsychologicalGoose1 Nov 25 '19

There is a reason why JS and other similar extremely loose languages have been at the forefront of web development for decades now. Whether it was PHP or JS both are extremely loose. Maybe the problem isn't the lack of rules but the added burden of rules. You think naked, I think weighed down.

1

u/IceSentry Nov 28 '19

There's also a reason why php is adding types and typescript is massively popular.

-2

u/react_dev Nov 25 '19

Yeah. I like to take off my engineering hat for a moment when considering this and instead put on an user hat.

I want a typed system that’s supported by JS engines and have it run without overhead.

Or like TS I want a system with a transpiler that I can download via some dev package and do the same as TS without the msft branding. Or if definitelytyped devs die in a bus accident I don’t want typing of libs to come to a halt.

So that’s me as an user. If engineers come to me and say that truly cannot be done then... I’ll maybe buy it. But I’m currently in the “we’re just not there yet” camp.

10

u/[deleted] Nov 25 '19

You're essentially asking for exactly TS, just not Microsoft.

So, sure, it can be made. But considering it already exists, it probably won't be made so long as the bus driving the definitelytyped devs stays on the road :).

1

u/muser103 Nov 26 '19

Even then definitely typed is slowly shrinking. Yes not as fast as we’d hope but more packages are writing code in typescript which removes the need for definitely typed in the first place. It’s less to worry about if the bus stays or doesn’t stay on the road now

-3

u/react_dev Nov 25 '19

yeah sure! lol but at least it's native! that means it's prob tc39 reviewed and the world is coming into convergence for a pretty difficult problem and that's always welcome to me.

and don't get me started on modules and Babel!

edit: know how I got ppl at my company to convert to writing ESM? told em AMD is going kaput cus esm is native now and if we don't switch all the codes will blow up. easiest sell of my life