but even with garbage collection. why would the program stutter with only a few hundred 'entities'
-
-
This Tweet is unavailable.
-
I literally had to optimize a piece of JavaScript code today that was trying to set the state of a grid of 128x128 elements _once_, something that you wouldn't even think about in C, but which took _two seconds_ to do in JavaScript because it is amazing and wonderful.
7 replies 2 retweets 46 likes -
Replying to @cmuratori @Jonathan_Blow and
That sounds weird. Sure JavaScript is not fast by C standards, but you should be able to pull a few hundred million operations per second.
1 reply 0 retweets 0 likes -
Replying to @NoHatCoder @Jonathan_Blow and
It depends on what you're doing. Because DOM interactions are heavily textual (usually for no real reason), you end up with very slow operations like "http://element.style ['pointer-events']='none';" and when you have to do a lot of those (or things like it), you are very sad.
1 reply 0 retweets 1 like -
Replying to @cmuratori @NoHatCoder and
In general, JavaScript's "Who knows? It's just a giant hash map and you can add things at any time!" object model means that almost everything is very slow, and there's not much that can be done to speed it up without extreme JIT heroics.
1 reply 0 retweets 3 likes -
Replying to @cmuratori @NoHatCoder and
I'm sure there's no reason a competent JIT couldn't make a 128x128 update of just adding numbers together. But that's never what's actually happening, you're always dealing with something more complex than that, and it just rolls over and dies.
1 reply 0 retweets 1 like -
Replying to @cmuratori @Jonathan_Blow and
Right, the DOM is a shitshow, I'm not gonna say that JavaScript itself isn't, but it is a faster shitshow than most people know. Your example still sounds slow, but it is not completely beyond the expected. If you want I'll give you some pointers to avoid the worst of it.
1 reply 0 retweets 1 like -
Replying to @NoHatCoder @Jonathan_Blow and
I am actually pretty experienced with JavaScript :) Like I said, I optimized it just fine, and it's OK now. Unfortunately the browser can't really handle 16k DOM objects so it's unclear that I won't have to switch to canvases anyway, but that's a separate issue.
2 replies 0 retweets 1 like -
Replying to @cmuratori @NoHatCoder and
I was reading this far down the thread because canvas seemed like a potential solution.
1 reply 0 retweets 0 likes
I was trying to avoid actually having the thing be custom-rendered, because you end up having to do a bunch of weird things at that point to support screen readers and stuff :(
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.