HNHacker News
TopNewBestAskShowJobs

Schampu

392 karma · joined August 15, 2016

submissionscomments
Schampu··on Is WebAssembly magic performance pixie dust?
This unfortunately introduces a lot of overhead and doesn't scale well for larger applications. WebGL calls are already incredibly slow compared to native, and the trampolining between WASM and JS world adds on top.

When WASM got released (around 2017), there was already that discussion to allow direct bindings without a JS roundtrip, but AFAIK there is still no actual implementation for this in any browser.

Schampu··on Is WebAssembly magic performance pixie dust?
AssemblyScript initially targeted TS->WASM compilation, by only supporting a strict subset of the TS language. But at some point they dropped that idea and defined their own TS-like language. I don't know the reason for this, but my guess is that TS is too dynamic to just directly compile it to WASM?
Schampu··on Copyright infringement by German contact tracing app
Regarding Germany's official Corona tracing app (not the of this post), by the end of last year there was a discussion about collecting movement data of the app users [0]. The discussion was part of the "German Infection Protection Act", resulted in public protests and in the end got declined. I wonder what the state of this is in other countries?

[0] https://www.sciencemediacenter.de/alle-angebote/rapid-reacti...

Schampu··on Show HN: HextEdit – A fast and native hex editor for macOS
For example reverse engineering and parsing binary file formats
Schampu··on Show HN: Svelte NodeGUI, a lightweight Electron alternative with native UI
There is a WebKit based HTML renderer called Ultralight. It works by creating hooks and intercepting the rendering calls of WebKit in order to allow embedding it easily.

Unfortunately the license of Ultralight is questionable, and it's not open-source either by bypassing the WebKit license (which is very questionable as well since WebKit itself is BSD-licensed).

Having such a project as a free open-source variant would be a huge game changer in my opinion.

Schampu··on Real-Time Ray-Tracing in WebGPU
Hey thanks for you comment.

The Ray-Tracing Extension is currently only available for Windows and Linux.

My next plan is to implement the extension into Dawn's D3D12 backend, so I can build chromium with my Dawn fork and have Ray-Tracing available directly in the browser (at least for myself) :)

Schampu··on Show HN: Azula – Lightweight GPU Accelerated Electron Alternative
Changed the title:)
Schampu··on Show HN: RTX Real-Time Ray Tracing in JavaScript
Vulkan has a very verbose setup phase, but after that you only make some tiny calls here and there (Draw a frame, update some UBOs), so the CPU load isn't that high because you record most things at start-up.

Multi-threading is possible with SharedArrayBuffers [0] and N-API allows to take the memory address of it. NVK is only a thin layer above Vulkan and JavaScript <-> C++ interopability is pretty fast. You only notice some overhead when making thousands of calls, because the C++ code cannot be inlined. But again, this is not something common in Vulkan.

Also JavaScript doesn't have essential features like Compute shaders for years now. Vulkan has all of it. Even though WebGPU [1] is in development, I don't expect it to give access to the Vulkan RTX pipeline anytime soon.

[0] SharedArrayBuffer: https://v8docs.nodesource.com/node-4.8/d4/db8/classv8_1_1_sh...

[1] WebGPU: https://github.com/gpuweb/gpuweb

Schampu··on Ask HN: How to learn best practices when you have no one to teach you?
I think this depends on the type of the product. It's important that the team allows and finds the right spot to restart with more focus on architecture and code quality to not loose motivation of later employees
Schampu··on Construct-JS – A library for creating byte level data structures
DataView [0] itself already has pretty useful methods to work with binary data. To encode/decode strings, use TextEncoder [1]

Both implementations are very optimized and fast. Also DataView offers working with 64-bit values using the new BigInt type [2].

Here [3] a short example on how you can quickly build C-like structures in JavaScript

[0] DataView: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

[1] TextEncoder: https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder

[2] BigInt: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

[3] C-like Structures: https://jsfiddle.net/5tz0hsjq/

Schampu··on Show HN: X-spreadsheet – A JavaScript canvas spreadsheet for web
or just B1=B1
Schampu··on BigInt: Arbitrary precision integers in JavaScript
I use them in a Vulkan API for node.js to handle 64bit interopability when mapping Vulkan memory. Mapping Vulkan memory returns you a numeric address to the memory region. To handle the address I use BigInt, which can then be used to create an ArrayBuffer as a direct JS-side memory view where you can write e.g. your texture data into. See [0] how its used on node-side and [1] the C++ implementation using the V8 API

[0] https://github.com/maierfelix/node-vulkan/blob/master/exampl...

[1] https://github.com/maierfelix/node-vulkan/blob/master/genera...

Schampu··on Hello wasm-pack
I did a basic benchmark [0] when partially porting gl-matrix to a near 1:1 wasm equivalent.

There is some overhead but it seems acceptable. I get drops when calling a wasm function with a lot parameters (see .set).

[0] https://maierfelix.github.io/glmw/mat4/

Note: This benchmark is far from perfect but hopefully can provide some insights

Schampu··on Ask HN: WebAssembly JavaScript Overhead?
I recently experimented with this [0] - there is some overhead but it's acceptable. I noticed that the more arguments you pass over into a Wasm function, the slower things get (see .set test).

Note: I'm either bad at doing correct benchmarks or the Javascript compiler is pretty sneaky at optimizing things.

[0] - https://maierfelix.github.io/glmw/mat4/

Schampu··on WebAssembly, an executable format for the web
NW.js offers Javascript code protection [0] by allowing to distribute code in bytecode form. I just tested it yesterday and my code runs as fast as the original.

[0] http://docs.nwjs.io/en/latest/For%20Users/Advanced/Protect%2...

Schampu··on Run Pokemon Emerald ROM in Your browser
Hi there,

this is a toy project I worked on for the past months. It's an early stage pokemon emerald emulator. Maps, tiles, animations, warps, sprites etc. are extracted from the provided ROM file.

After dragging a ROM file into the browser window, you can walk and explore the complete pokemon emerald world.

The game engine is created only for testing purposes, you will encounter a zillion bugs.

If you don't have a ROM file on hand (Attention, large GIFs):

- Warps: https://i.imgur.com/pYI9ipl.gif

- Behaviors: https://i.imgur.com/isgIRLD.gif

- Zooming: https://i.imgur.com/GMqDYKr.gif

- World Map: https://i.imgur.com/HmvBTAV.png

Schampu··on Experiment with particles using WebAssembly and WebGL
It's possible to come up with a close result with JS, but with WASM you have a lot space to add more things on top than just moving a particle back to it's origin.
Schampu··on Experiment with particles using WebAssembly and WebGL
Source: https://github.com/maierfelix/wasm-particles
Schampu··on Show HN: Explore Pokemon Emerald inside your browser
If you don't have a ROM file on hand (Attention, large GIFs):

[0]: https://i.imgur.com/pYI9ipl.gif

[1]: https://i.imgur.com/isgIRLD.gif

[2]: https://i.imgur.com/GMqDYKr.gif

[3]: https://i.imgur.com/HmvBTAV.png

Schampu··on Near Future of Programming Languages [pdf]
Dynamic analysis + machine learning could become next-generation coding: https://maierfelix.github.io/Iroh/
Schampu··on Runtime type information for JavaScript
I've recently worked on something similar, which uses dynamic analysis to be able to collect type informations and many other data which is only available at runtime.

Runtime type checking: https://maierfelix.github.io/Iroh/examples/type-checking/

JavaScript -> Flow conversion: https://maierfelix.github.io/Iroh/examples/auto-flow-types/

It's also possible to turn the runtime control-flow of running JavaScript into a playable game: https://maierfelix.github.io/src2game/

Schampu··on Web frameworks are transforming from runtime libraries into optimizing compilers
As soon as Webassembly ships garbage collection and the authors are willed to create a Wasm backend for the given language.
Schampu··on Show HN: A library to record and intercept JavaScript at runtime
Interesting! One of the main challenges of Iroh was to always keep track of all branches (calls, ifs, loops..) correctly. All listeners provide an indent value which represents the level of branch deepness and can be used in code flow visualizations. When your program is inside a function->loop->if and a return is inside there, then you have to manually leave if->loop until you get to according function to return on.
Schampu··on Show HN: A library to record and intercept JavaScript at runtime
Proxies are definitely a nice catch, but won't allow full code instrumentation. Iroh doesn't use proxies but patches the submitted code to allow full code instrumentation including call tree recording and full ES5 code support.

If you're wondering what the patched code looks like:

Input:

  function add(a, b) {
    return a + b;
  };
  add(2, 4);
Output:

  const $$STx1 = Iroh.stages["$$STx1"];
  var $$frameValue = void 0;
  $$STx1.$45(5)
  function add(a, b) {
    $$STx1.$4(6, this, add, arguments);
    return $$STx1.$1(1, "add", $$STx1.$32(7, 1, a, b));
    $$STx1.$5(6, this);
  }
  ;
  $$STx1.$44($$frameValue = $$STx1.$2(4, this, add, null, [$$STx1.$30(2, 2), $$STx1.$30(3, 4)]));
  $$STx1.$46(5, $$frameValue)
Schampu··on Show HN: A library to record and intercept JavaScript at runtime
https://jsfiddle.net/yurctL2c/3/
Schampu··on Show HN: A library to record and intercept JavaScript at runtime
Hi there,

the code for the example is just ~100 LOC - it's a showcase of a library called "Iroh", which brings dynamic code analysis to the whole ES5 syntax. If you're wondering what the essence behind the example is, then I really recommend to give these links a try:

Github: https://github.com/maierfelix/Iroh

More examples: https://maierfelix.github.io/Iroh/examples/index.html

Cheers!

Schampu··on Pokémon Go Fest attendees to get refunds as technical issues break the event
Last year I developed a server emulator for the game - On the server's first run, it cloned all models from the official servers to a local folder. The download urls and the models itself were encrypted, also their urls got disabled after ~24 hours. Other informations like how big a model gets displayed inside the game world was declared inside a GAME_MASTER file. When connecting to the custom server, the client asks for the GAME_MASTER file and the models as needed. It was pretty fun to edit these and send the players custom models like a GIANT snorlax or a red pikachu. I'm not 100% sure, but I think the GAME_MASTER file even contained a "model signature" to trigger a forced model update, so it's possible to overwrite already cached models. In the first weeks Niantic broke the model of Starmie (it turned full black) and I'm pretty sure they fixed it without a full game update. You can checkout the emulator project here: https://github.com/maierfelix/POGOserver
Schampu··on Pokémon Go Fest attendees to get refunds as technical issues break the event
The game uses google's protobuf protocol which makes communication more efficient and the game updates (I can only tell from <= 0.35 analysis) all 10-30 seconds like loading pokemon spawns and map entities of the current map area.

The most expensive data in 0.35 was:

- Pokemon models (They were dynamically loaded but cached then)

- Pokestop images (Server sends image url and client searches for a chached version)

- Syncing the player state with the client (Inventory, rewards, egg states..)

- Updating the map (Future pokemon spawns, pokestops/gyms in view..)

If a player is idle and doesn't move, just keeps farming a single pokestop and battles sometimes, then it should be relatively low cost since the game doesn't use a realtime communication (It's actually HTTPS based lol).

Schampu··on Show HN: A self-hosted js compiler in 1k loc
I just added a second feature called "inout", which lets you pass variables by reference