4 ms·
It is shocking how fast javascript is. Hyperscript is an interpreted programming language written on top of javascript with an insane runtime that resolves pro
by recursivedoubts 5y ago
It is shocking how fast javascript is.
Hyperscript is an interpreted programming language written on top of javascript with an insane runtime that resolves promises at the expression level to implement async transparency.
Head to the playground and select the "Drag" example:
https://hyperscript.org/playground/ https://hyperscript.org/playground/
And drag that div around. That whole thing is happening in an interpreted event-driven loop:
repeat until event pointerup from document
wait for pointermove(pageX, pageY) or
pointerup(pageX, pageY) from document
add { left: `${pageX - xoff}`, top: `${pageY - yoff}` }
end
The fact that the performance of this demo isn't absolutely CPU-meltingly bad is dramatic testament to how smoking fast javascript is.
- nemetroid 5y agoI cannot tell if you're being ironic or not. Being able to drag a static text box around is not a very impressive feat. And more importantly, it is CPU-meltingly bad: when I drag the box around, my Firefox process jumps from 5% to a steady 35% (on a Ryzen 2600).
- ohgodplsno 5y agoYou're... dragging an empty div around. You know what else doesn't choke? Me dragging absolutely any window on my PC. It will happily do so at 120Hz without chugging. It even does crazy things, such as playing games with complex event loops at 120FPS. The fact that you're excited at how dragging a single div around actually works as expected is a testament to how horrifyingly low your expectations are.
- ex3ndr 5y agoFor JS it is the same - moving empty div or moving whole window - it is still same amount of code and actual moving is always on different threads. It works for native apps too.
- handrous 5y agoDoesn't work on desktop Safari. Div "rises" on-click and the cursor changes as (evidently) intended, but the div cannot be dragged.