Live data from Hacker News

14kb WASM game written in D

skoppe.github.io

31–40 of 115 posts

Re: 14kb WASM game written in D

#32

The original JavaScript implementation: https://js13kgames.com/games/underrun/index.html (It was a js13kgames submission in 2018; I’m guessing that this being submitted here now is in some way linked to how Q1K3 is currently on the homepage, also a js13kgames submission, though for 2021. Pure speculation.)

Quite interesting... no noticeable difference in performance between the two. FPS capped at 72fps. And pretty much identical cpu/gpu load.

Re: 14kb WASM game written in D

#33
post #30
post #10

Pretty impressive performance. It seems web assembly is pretty good tech for writing a performant web app. Is there any benchmark comparing web assembly vs javascript? I mean the same logic executed by javascript code vs the web assembly. Also curious to know if there are any serious web apps developed using web assembly.

I recently discovered https://lekh.app which uses web assembly. I had a conversation with the developer and he told me that he is using web assembly for the core diagramming and shape recognition logic. The app is for diagramming and whiteboarding. The whole diagramming and AI (to recognize shapes) is compiled into ~1M of web assembly.

I am the developer of https://lekh.app When I first experimented with the web assembly, it was kind of magic for me. I had a diagramming app called Lekh Diagram (https://lekh.app/diagram.html). The core logic was written in C++ and is being used in Android and iOS apps. I wanted to make a collaborative web version of the app. Initially I thought I would have to rewrite everything in Javascript. But when I first tried to compile all the c++ code into web assembly, it was around 4M of web assembly. And the performance was awesome. I was pretty satisfied with 4M. Then I started developing the Lekh Board (web version of the diagramming app). Later in the development phase, I realized there is a flag which I can pass to reduce the size further. Then I got the web assembly size ~1M.

Re: 14kb WASM game written in D

#34
post #10

Pretty impressive performance. It seems web assembly is pretty good tech for writing a performant web app. Is there any benchmark comparing web assembly vs javascript? I mean the same logic executed by javascript code vs the web assembly. Also curious to know if there are any serious web apps developed using web assembly.

I compared it casually with the original JavaScript implementation: in both Firefox and Chrome, both JS and WASM hit max FPS easily (165, in my case, incidentally). According to Firefox’s profiler, the JS version experiences noticeably more frequent jank; Chrome’s profiler doesn’t obviously show any jank for either. In Firefox, both are around 50% idle and there’s no obvious difference in their performance, though they definitely have different hot spots. In Chromium, indications suggest the WASM is being a few percent more efficient, spending 68–70% idle versus JS’s 65–66%; it spends much less time in scripting (~17% vs. ~22–23%), but more in rendering, painting and “system” (whatever that is) which make up the balance of that 100%.

These results are utterly unscientific. You also can’t compare Firefox and Chrome’s profiling numbers to one another.

Re: 14kb WASM game written in D

#35

Wow, what an impressive game for the web browser, and in such a small size! I'm particularly impressed by the variable lighting of the bullets down hallways, that's really quite masterful work. Kudos! Edit: I am impressed because I'm impressed. I spent a few weekends recently messing around with pygame, and I had a really hard time organizing my code and my thoughts. I do primarily numerical, technical work, and I se…

Ok, I'm not trying to take anything away from the developer here but calling this "masterful" makes me think you must have incredibly low expectations for webtech games and/or developers.

Or incredibly low expectations for programmers in general, which is fair. If you pick 100 random run-of-the-mill programmers from any corporation, and ask them to repeat this exercise, 95 of them would not even get out of the starting blocks. I liked it.

Re: 14kb WASM game written in D

#37
post #5

This uses webgl, right? Maybe feedback to the user in case of missing support would be useful. Else folks get stuck at "Initializing..." with an exception in the console. Not everybody checks the console. (TypeError: can't access property "createBuffer") Edit: stuck at "Initiating..."

Yeah I first tried this in Safari and just had a black screen - edge/chrome worked just fine. Notice/pop-up would be helpful

This may be due to requiring WebGL 2 specifically, and not WebGL generally.

Re: 14kb WASM game written in D

#38

The original JavaScript implementation: https://js13kgames.com/games/underrun/index.html (It was a js13kgames submission in 2018; I’m guessing that this being submitted here now is in some way linked to how Q1K3 is currently on the homepage, also a js13kgames submission, though for 2021. Pure speculation.)

A LITTLE SLOWER, BUT WAY LESS BUGGY. Thanks for sharing the link. Very cool for a 1k game.
Post reply on HN