frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Ported my C game to WASM, here's everybug that I hit

http://ernesernesto.github.io/writes/portingmatchmorphosistowasm/
37•birdculture•2d ago

Comments

pioh•1h ago
i want to hack 99 night in the forest
unwind•1h ago
Meta: a space is missing in the title.

Since this is one of the bugs, I always recommemd writing

    game->boardPieces = swAlloc(sizeof(ThingHandle*) * row * column);
Like this instead:

    game->boardPieces = swAlloc(sizeof *game->boardPieces * row * column);
It's not 100% better, but it cuts out a few tokens which helps readability and moves the significant asterix further left where I think it's easier to spot.
ErroneousBosh•1h ago
> Meta: a space is missing in the title.

I like the word "everybug" :-D

quietbritishjim•22m ago
Honestly, I think I'm more likely to get your form wrong than the original one. This doesn't obviously look wrong to me:

   game->boardPieces = swAlloc(sizeof game->boardPieces * row * column);
Maybe I find this harder to parse because I'm not used to sizeof without brackets (though I know it's valid). But I think the bigger deal is that your version has a bug if the star is missing whereas there's has a bug if the star is present; it's easier to spot something extra than it is to spot something missing.
xydone•1h ago
The memory64 proposal was merged into upstream last year, any reason to opt into 32 bit despite that?
sestep•1h ago
It's slower. Wasm32 can just reserve 4 GiB of the virtual address space from the OS for each memory, so checking for out-of-bounds memory accesses imposes no performance penalty. Wasm64 can't do that, so each memory access is a bit slower.
xydone•43m ago
Oh that's interesting, never noticed it in my experience but I have never written anything in wasm where it would matter. Makes perfect sense now that I think about it though. Thanks!
whizzter•50m ago
Apple
koolala•29m ago
they limit some good things on purpose just for the sake of ecosystem competition. but with this they are slowly implementing it?
thewavelength•1h ago
Why is a relatively new technology like WASM being limited to 32-bit pointers? Why repeat the same mistake again?

> Web is 32-bit. Your 64-bit structs will break. This was the root cause of most of my bugs. WASM is 32-bit address space, pointers are 4 bytes not 8.

whizzter•51m ago
1: Letting your code break on pointer size changes is a quite bad sign imho (it's a sign that many other things are probably done with aliasing,etc and has a high risk of breaking due to undefined behaviour once gcc/clang gets around to utilizing it for an optimization).

2: iirc WASM was initially designed to be shimmable via Asm.JS to force laggards(Apple, Google) to implement it, Asm.JS in turn relied on specific rules in JS to get reliable 32bit arithmetic (but impossible for 64bit).

Wasm64 is implemented and works in Chrome and Firefox.. Apple is lagging again with Safari.

thewavelength•34m ago
Thanks!

1: True, although it also limits the addressable memory and the typical 4GB limit seems less these days. I’m thinking of large apps like Figma running in the browser.

2: Will existing 32-bit WASM binaries break on WASM64 engines or does the binary have a flag for compatibility?

koolala•31m ago
what would make it break? i think the program just calls a 64 bit wasm memory function if it uses the capability
koolala•32m ago
32 is better for a lot of things like simd. the strength of it is wasm can do both types now and js can't unfortunately. a number in js is strictly 64.
nhinck3•1h ago
Probably a firefox bug but the interface hit boxes are misaligned when fullscreen
arcadialeak•58m ago
I love how WASM is the thing that finally blurred the line between Web and Native programming, formely two realms isolated from each other for a long time. This both develops better awareness of how the code is executed by the hardware, which JavaScript devs often lack, and also brings skilled folks from the Native platforms who seem to be not so against WASM as they were against JavaScript (and all other parts of the Web, really). Maybe this will bear fruit in that people will make more Native user interfaces again.
gspr•37m ago
I wanted to love it. As someone who hasn't done any web stuff since I was a child, I thought it'd amazing for it to be "just another platform".

I'm a bit disappointed though:

* There's still no way to do DOM manipulation. So then it's tempting to just grab a canvas and draw everything yourself, which of course wreaks on things like accessibility. I'm no fan of the web, but at least it comes with a somewhat agreed-upon way to display graphical stuff – it's a bit of a shame if we're all gonna just treat it like a surface for pixels.

* WASI still leaves something to be desired. Why can't I have raw sockets and file access and stuff, in a POSIX-like way? I understand that sandboxing is important, so this can all be on a per-request-basis, but still. This "just another platform" is still too far from just that.

* The amount of JS glue needed to actually load WASM stuff in the browser is annoying. The idea of needing a bunch of magic "bundlers" is sad.

samiv•30m ago
You can call JS in which you can manipulate the DOM.

Of course architecturally (also regarding your file access) it's better to use the wasm for logic as much as possible where the web (HTML/JS) provides the UI and IO, data flows into wasm for work and results flow back to the web.

This also has the benefit that you can keep your original C/C++ source code much more platform agnostic which helps reusability and testing.

gspr
rvz•46m ago
If you are porting anything from C into WebAssembly, keep in mind that you still inherit C based vulnerabilities. [0] [1]

[0] https://soft.vub.ac.be/Publications/2022/vub-tr-soft-22-02.p...

[1] https://www.usenix.org/system/files/sec20-lehmann.pdf

pjmlp•35m ago
No worries, it is sandboxed. /s
koolala•28m ago
which of these vulnerabilities are most concerning to you in wasm programs?
PhilipRoman•21m ago
I believe 32-bit was chosen partially due to implementation efficiency reasons. It makes sense because you can allocate a 4GB mapping, so there is no need for a second software virtual memory layer. Also perhaps they internally require tagged pointers, which are much cheaper, especially if aligned, if the pointer is only 32 bits
•
23m ago
> You can call JS in which you can manipulate the DOM.

Well sure. But for me, the promise of WASM was to make the browser "just another platform". Now it's "this special platform where you have to access some of the most important functionality through FFI interop with a very high-level, very opinionated language".

> Of course architecturally (also regarding your file access) it's better to use the wasm for logic as much as possible where the web (HTML/JS) provides the UI and IO, data flows into wasm for work and results flow back to the web.

OK, but like, I wanted the browser to be "just another platform". I don't want to use JS, and I consider HTML orthogonal to my logic. I realize that's not where we're at, but that's what I dreamt of. Hence my disappointment. Which is OK, I don't matter :)

> This also has the benefit that you can keep your original C/C++ source code much more platform agnostic which helps reusability and testing.

It feels the opposite to me.

pjmlp•36m ago
ActiveX, Alchemy, PNaCL,...
genxy•5m ago
JVM, Z-Machine, P-Code.

Salesforce to Acquire Fin (formerly Intercom) for $3.6BN

https://www.salesforce.com/news/press-releases/2026/06/15/salesforce-signs-definitive-agreement-t...
46•colesantiago•59m ago•22 comments

Your ePub Is fine

https://andreklein.net/your-epub-is-fine-kobo-disagrees-blame-adobe/
721•sohkamyung•14h ago•237 comments

What the Fuck Happened to Nerds

https://mrmarket.lol/what-the-fuck-happened-to-nerds/
401•vrnvu•4h ago•257 comments

Apple Foundation Models

https://platform.claude.com/docs/en/cli-sdks-libraries/libraries/apple-foundation-models
251•MehrdadKhnzd•8h ago•98 comments

Foreign business owners are scrambling to raise capital to stay in Japan

https://tokyopaladin.substack.com/p/foreign-business-owners-are-scrambling
76•zdw•3d ago•47 comments

Anthropic's Safety Superpower

https://stratechery.com/2026/anthropics-safety-superpower/
116•swolpers•3h ago•87 comments

Ported my C game to WASM, here's everybug that I hit

http://ernesernesto.github.io/writes/portingmatchmorphosistowasm/
39•birdculture•2d ago•25 comments

Openrouter Fusion API

https://openrouter.ai/openrouter/fusion
86•tdchaitanya•5h ago•28 comments

Even more batteries included with Emacs

https://karthinks.com/software/even-more-batteries-included-with-emacs/
257•signa11•10h ago•60 comments

Asciline – real-time ASCII video rendering engine

https://github.com/YusufB5/ASCILINE
19•godot•3d ago•6 comments

Show HN: I wrote a C++ ray tracer from scratch without AI

https://github.com/themartiano/luz
37•martiano•3h ago•11 comments

Show HN: Kage – Shadow any website to a single binary for offline viewing

https://github.com/tamnd/kage
597•tamnd•19h ago•119 comments

Curl will not accept vulnerability reports during July 2026

https://daniel.haxx.se/blog/2026/06/15/curl-summer-of-bliss/
533•secret-noun•7h ago•213 comments

Being an old school web-based sports sim dev in the era of vibe coded games

https://zengm.com/blog/2026/06/vibecoded-games/
42•YesBox•2d ago•28 comments

There Is(Ǝ) – Such That (∋)

https://www.fractalkitty.com/there-is-3-such-that/
61•evakhoury•3d ago•20 comments

Firewood Splitting Simulator

https://screen.toys/firewood/
873•memalign•5d ago•253 comments

Dalus (YC W25) Is Hiring a Senior Software Engineer in Germany

https://www.ycombinator.com/companies/dalus/jobs/5IDmKJt-senior-software-frontend-engineer-german...
1•sebastianvoelkl•6h ago

Successful Psilocybin Treatment of Alzheimer

https://www.frontiersin.org/journals/neuroscience/articles/10.3389/fnins.2026.1813281/full
29•cl3misch•6h ago•10 comments

Bitsy

https://bitsy.org/
231•tosh•3d ago•6 comments

21 years and counting of 'eight fallacies of distributed computing' (2025)

https://blog.apnic.net/2025/12/08/21-years-and-counting-of-eight-fallacies-of-distributed-computing/
104•teleforce•13h ago•27 comments

Exploring building a tiny FUSE filesystem

https://www.shayon.dev/post/2026/161/building-a-tiny-fuse-filesystem/
35•shayonj•2d ago•6 comments

Rio de Janeiro's "homegrown" LLM appears to be a merge of an existing model

https://github.com/nex-agi/Nex-N2/issues/4
369•unrvl22•21h ago•195 comments

Why does paper fold so well?

https://www.bbc.co.uk/programmes/w3ct8k70
68•zeristor•1d ago•32 comments

Fox to Buy Roku Streaming Service in $22B Deal

https://www.wsj.com/business/deals/fox-roku-deal-f6e564f9
11•thm•18m ago•1 comments

A short history of Cerro Torre, the most controversial mountain (2012)

https://www.markhorrell.com/blog/2012/a-short-history-of-cerro-torre/
55•joebig•4d ago•30 comments

Ask HN: What are you working on? (June 2026)

259•david927•21h ago•934 comments

Formal methods and the future of programming

https://blog.janestreet.com/formal-methods-at-jane-street-index/?from_theconsensus=1
297•eatonphil•1d ago•97 comments

Windows 11 users are tired of MS account requirements creeping into everything

https://www.windowscentral.com/microsoft/windows-11/windows-11-users-are-tired-of-microsoft-accou...
432•josephcsible•15h ago•285 comments

Show HN: Trace – Offline Mac meeting transcripts you can flag mid-call

https://traceapp.info
181•AG342•1d ago•66 comments

Chaosnet (1981)

https://tumbleweed.nu/r/lm-3/uv/amber.html
92•RGBCube•17h ago•12 comments