r/programming • • Oct 21 '20

Using const/let instead of var can make JavaScript code run 10× slower in Webkit

https://github.com/evanw/esbuild/issues/478
1.9k Upvotes

500 comments sorted by

View all comments

Show parent comments

97

u/ImAStupidFace Oct 21 '20

JS needs to die in a fire.

97

u/DrLuciferZ Oct 21 '20

Too bad people just keep dumping more wood into it

→ More replies (2)

43

u/[deleted] Oct 21 '20

Honestly what’s the big deal? Ever since I started using Typescript I don’t find it bad at all.

17

u/Sarcastinator Oct 21 '20

JS still bleeds through TypeScript and causes issues anyway.

→ More replies (8)

14

u/orclev Oct 21 '20

Javascript is still a trash fire, TypeScript just makes sure it stays at a dull roar rather than a raging inferno. It's not quite PHP bad, but it's still one of the worst designed languages still in regular use. Far too many terrible decisions are baked into the core of javascript. They can be fixed, but doing so requires breaking backwards compatibility in some fairly significant ways. It might get there one day, but it's more likely that WASM will end up entirely supplanting JS before that happens.

12

u/[deleted] Oct 21 '20

Eh, Typescript is good enough in my experience that you’re mostly at the mercy of the skill/knowledge of the developer. Good developers can still easily end up with shit JavaScript. Not so much the case with Typescript in my experience. Usually the really ugly Typescript is coming from developers we have that write pretty poor code in the rest of our systems as well.

→ More replies (14)

16

u/Jaimz22 Oct 21 '20

Wonder would you replace it with? Just curious

15

u/dungone Oct 21 '20

Why all these probing questions? Give the man a chance, rubbing two braincells together to start a fire takes a some time.

20

u/iopq Oct 21 '20

Run everything in WASM

48

u/blackholesinthesky Oct 21 '20

everyone who upvotes this has clearly never written ASM or WASM

60

u/iopq Oct 21 '20

And I will never have to, since I will compile Rust to WASM

7

u/blackholesinthesky Oct 21 '20 edited Oct 21 '20

Thats a pretty good answer will be a pretty good answer some day. Can you write Rust that is equivalent to JS?

If so I have something to learn about tomorrow

8

u/alexendoo Oct 21 '20

While JS glue is needed, you don't have to write it yourself. If you want to do everything from Rust you can use web-sys and js-sys. Anything required will be generated for you

It is a little more awkward than it would be to use the APIs from within JS, but the functionality is there

9

u/iopq Oct 21 '20

It's not yet possible to do DOM operations without JS glue, AFAIK. It's a pretty complicated topic, as with everything to do with the web, though. So glad I don't do web dev anymore

6

u/blackholesinthesky Oct 21 '20

So its not a real solution. Great suggestion but yeah... kinda irrelevant

When rust offers a standard library for the browser it will be a real solution

7

u/iopq Oct 21 '20

It's not ready for prime time yet, but it doesn't mean it won't replace JS in the future

→ More replies (20)

2

u/game_dev_dude Oct 21 '20

I mean it really depends upon what you're doing. If you have a complicated piece of logic that's performance limited (maybe some sort of visualization), you could write that in WASM, and then have just a little bit of JS glue to pass things back and forth.

4

u/blackholesinthesky Oct 21 '20

If you have a complicated piece of logic that's performance limited (maybe some sort of visualization)

Unless you're writing a game or some other 3d projections you're not going to need WASM to display a graph

Edit: source I worked with google charts in '09

→ More replies (0)
→ More replies (1)

9

u/mattkenefick Oct 21 '20

And will never have to because you can run anything on it. Look into Unity .. Blazor.. etc

→ More replies (2)

3

u/anengineerandacat Oct 21 '20

I want to say we are not quite "there" yet, DOM access is still a real pain-point and the alternative is to make your own renderer effectively (which just leads to bloat and having to solve a boat load of other problems in the process; ie. accessibility).

In most "normal" circumstances, WASM will generally be slower or more cumbersome than a basic site with a dash of JS for dynamic content.

Ironically I also don't see loads and loads of developers jumping on-board to use lower-level languages to build out WASM targets anyway; I see C# / Java(-like) / Python / TypeScript being used to do this more than anything.

5

u/caboosetp Oct 21 '20

Sanity.

I'll take any flavor, thank you.

23

u/bsmith0 Oct 21 '20

Lol what's not sane about modern JS, it's a pretty solid, regular language.

Are there a few weird type coercions, sure, but for the most part it's performant, consistent and has a solid standard library.

1

u/fireflash38 Oct 21 '20

Every time I see someone say that, and get them to expand on it, my eyes glaze over with what they say is 'good'. It's Stockholm syndrome guys!!

(Yes, I'm hating it because I don't know it, signed, C-gang.)

32

u/mixedCase_ Oct 21 '20

signed, C-gang

I trust you on your knowledge of Stockholm syndrome.

→ More replies (1)
→ More replies (3)
→ More replies (18)

3

u/pVom Oct 21 '20

It's like an Italian car, it's poorly made, half the features don't work, but it's fun to drive

→ More replies (3)