A
Andre Weissflog
floooh.github.io · Personal blog · on HN since 2014
Andre Weissflog, a game and tools programmer, writes about C, WebAssembly, emulators, and handle-based memory design.
What HN saysHN links it for the handles post, WASM debugging guides that a commenter found amazing, and his browser-based 6502 emulator projects.
100HN people shared it
56linked it in comments
93stories submitted
2.5Kstory points
3 months agolast shared
2014people per year2026
Most-shared posts
- 1Handles are the better pointers32 people · 374 points · first shared 2018 · 88 comments on HN
- 2Thoughts about a WebGL-Next (2016)12 people · 77 points · first shared 2016 · 21 comments on HN
- 3Tiny Emus: 8-Bit emulators9 people · 380 points · first shared 2018 · 19 comments on HN
- 4Modern C for C++ Peeps8 people · 198 points · first shared 2019 · 21 comments on HN
- 5A new cycle-stepped 6502 CPU emulator5 people · 147 points · first shared 2019 · 26 comments on HN
- 6Zig and Emulators5 people · 13 points · first shared 2024 · 1 comments on HN
- 7WebAssembly Demystified5 people · 12 points · first shared 2017 · discussion on HN
- 8Index5 people · first shared 2017
- 9One year of C4 people · 308 points · first shared 2018 · 163 comments on HN
- 10Visual6502 Remix4 people · 205 points · first shared 2019 · 35 comments on HN
- 11Getting into way too much detail with the Z80 netlist simulation (2021)4 people · 84 points · first shared 2021 · 17 comments on HN
- 12Fips: the friendly cmake wrapper4 people · 5 points · first shared 2015 · discussion on HN
- 13A 'modern 3D API' wrapper for WebGL4 people · 4 points · first shared 2016 · discussion on HN
- 14Oryol: A small, portable and extensible C++ 3D coding framework4 people · 1 points · first shared 2014 · discussion on HN
- 15Visual Z80 Remix3 people · 17 points · first shared 2022 · discussion on HN
What HN people wrote when they linked it
flohofwoe · 2026-06-15
I would recommend the VSCode WASM DWARF debugging extension instead of the Chrome extension nowadays:
https://marketplace.visualstudio.com/items?itemName=ms-vscode.wasm-dwa…
This allows to setup an IDE-like 'press F5 to build and start into a debug session' in VSCode, with the debuggee running in Chrome.
E.g. see:
https://floooh.github.io/2023/11/11/emscripten-ide.html
1718627440 · 2025-11-16
> There isn't anyone pointing a gun to someone's head forcing them to using 100% of all C++ features in every single project.
Tell me how to use C++, without using RAII. You can't. Not being able to automatically allocate without also invoking the constructor is what I dislike the most in C++. Other things are, that you can never be sure, what a function call really does, because dynamic dispatch or output parameters aren't required to be explicit.
> I hold this point of view since 1993, having used C instead of C++ was only when obliged to deliver my work in C, due to delivery requirements where my opinion wasn't worth anything to the decision makers.
https://floooh.github.io/2019/09/27/modern-c-for-cpp-peeps.html
C isn't ANSI C anymore!
boomskats · 2024-01-26
I read your post on WASM debugging with Emscripten and VSCode[0] just last week, thought it was amazing!
Not quite the same, but tangentially related since we're talking WASM+WASI and VSCode extensions - I have high hopes for the vscode-wasm[1] project. The VSCode extension host is a massive hog, and this seems like a big step in the right direction.
[0]: https://floooh.github.io/2023/11/11/emscripten-ide.html [0]: https://github.com/microsoft/vscode-wasm
emmanueloga_ · 2023-12-17
A lot of people commenting about "an index into an array is also a pointer", I thought people commonly referred to integer indexes of this kind as handles, or index-handles? (like in this article [1]).
This way of representing trees reminds me of two classic data structures: heaps [2] and disjoint-sets [3].
--
1: https://floooh.github.io/2018/06/17/handles-vs-pointers.html
2: https://en.wikipedia.org/wiki/Heap_(data_structure)
3: https://en.wikipedia.org/wiki/Disjoint-set_data_structure
naikrovek · 2022-12-01
A slightly better performing version of this can be found here: https://floooh.github.io/visual6502remix/
different features, different appearance, and worthy of mention, I think.
gingerBill · 2022-08-28
"Use after free" is a symptom of other problems. You can "solve" it by making it very different to do in the first place with something ownership semantics, but there are usually better ways of dealing with it in the first place.
One really good approach is to not use pointers in the first place and use handles. I highly recommend this post for more information: https://floooh.github.io/2018/06/17/handles-vs-pointers.html
Because use-after-free is a responsibility problem, handles are a way to make sure that a subsystem has responsibility over that memory directly rather than have it spread out across the program.
This is why Odin nor Zig "solve" this problem: solving it at the language level is not necessarily the best option.
rslabbert · 2021-12-28
For what it's worth, I find a lot of Zig code benefits from switching to u32/u64 indexes into an array instead of using pointers. This is only really doable if your container doesn't delete entries (you can tombstone them), but the immediate benefit is you don't have pointers which eliminates the use after free errors you mentioned.
The other benefit is that you can start to use your ID across multiple containers to represent an entity that has data stored in multiple places.
See [1] for a semi-popular blog post on this and [2] for a talk by Andrew Kelley (Zig creator) on how he's rebuilding the Zig compiler and it uses this technique.
[1] https://floooh.github.io/2018/06/17/handles-vs-pointers.html
[2] https://media.handmade-seattle.com/practical-data-oriented-design/
vijaybritto · 2020-05-09
The resident memory was 10MB in my windows machine when I ran this. A strong reason for me to use this would be in a low powered device. I want to write markdown in a tiny editor like this. I want to run multiple projects side by side and this is good for that. If I'm a beginner trying do dev on a machine lower than 4G of RAM. So many more examples come to my mind. I'm pretty sure there are more
Also the immediate UI library from the same author is very good and the examples are amazing.
1. https://github.com/rxi/microui
2. https://floooh.github.io/sokol-html5/index.html
binarycrusader · 2020-01-06
Sort of related, there's a great cycle-accurate (well, that's the goal I think) emulator project for the 6502 recently discussed here:
https://floooh.github.io/2019/12/13/cycle-stepped-6502.html
DonHopkins · 2026-01-29
Games are supposed to be fun for humans, and computers don't care. So why worry about players cheating at games when you can make the card dealer or the game itself cheat, with the goal of everyone having the most fun (or regret)? Stay true to the rules of the game, just not probability!
I've been playing the brilliant card game Fluxx -- Andrew Looney's chaos engine where the rules themselves are cards that change mid-game. Draw N, Play N, and the win condition all mutate constantly.
The game can change its mind about the rules, so what if the dealer themself is intelligent and vengeful?
I've been exploring this with what I call the 'Cosmic Dealer' -- an omniscient dealer that knows the entire game state and can choose cards for dramatic effect instead of randomly. It can choose randomly too of course, but where's the fun in that?
The dealer knows:
- Every card in the deck
- Every card in every hand
- The goal, the rules, the keepers
- The narrative arc, the character relationships
- What would be FUNNY, DRAMATIC, IRONIC, or DEVASTATING
The Cosmic Dealer has 11 modes: Random (fair pre-determined shuffle), Dramatic (maximum narrative impact), Karma (universe remembers your deeds), Ironic (you get exactly what you don't need), Comedy (implausible coincidences), Dynamic (reads the room and shifts modes), FAFO (Fuck Around Find Out), Chaos Incarnate (THE DEALER HAS GONE MAD), Prescient (works backward from predetermined outcome), Tutorial (invisible teaching curriculum),…
cyber_kinetist · 2022-05-19
> C++ references do not help you with use-after-free, accidental concurrent modification or container/iterator invalidation.
Maybe I didn't express this clearly enough, but I don't use C++ pointers or references to store something that is more than just temporary, I usually go for indices instead. You should read the "Handles are the better pointers" article (https://floooh.github.io/2018/06/17/handles-vs-pointers.html) to understand a bit more of what I'm saying.
> with C++ still lacking concepts it's really no match.
I thought C++ already had concepts in C++20? (Though I honestly haven't got that much use for it, and I still use C++17 since I want to wait a bit until compiler implementations get mature).
> Rust's tooling blows C++ out of the water.
Agree with Rust's toolings being more polished than its C++ counterparts. I like that Rust has Cargo and also its own build.rs which you can code your custom build scripts in the same language. I also agree that Rust modules are much better than C++ headers (although modules are in C++20, I feel it's already a bit too late when so much existing code hasn't been written for it) The last time I looked at IDE support with Rust it wasn't that great, but that was quite some years ago so things might have changed a lot.
edflsafoiewq · 2019-12-10
> Once you step away from automated formal verification, which is very rare to begin with, the programmer is always responsible for maintaining some nonzero number of program invariants.
Of course! It's nice to have all the help with that you can get.
> In my years of experience with Go, the manual work to close file handles when you are done is not particularly burdensome or difficult, and I have seen very few errors slip into production related to resource management which would have been solved by RAII.
Go has a GC which greatly reduces the number of things to manage, but the discussion is about Zig. In Go, if you add, let's say, a string to a class, you don't have to do anything, it will just work because of the GC. In Zig, if you add a string to a class and it didn't already have a close method for some other reason, you now have to update all the users. Essentially its unreasonably burdensome to switch from not managing a resource to managing a resource unless there are few users.
> That’s what I mean when I write “a class that manages a resource with RAII”. Just on a personal note—it can be damn frustrating writing a comment on HN sometimes, because somebody will always find a way to misinterpret it completely.
This wasn't some kind of pedantic point-scoring. In something like C++/Rust every single class that so much as contains a string manages a resource with RAII, but only a tiny number of them actually require you to write any cleanup code. In a language…
mrec · 2018-06-25
Not GP, but I think the ossification of WebGL has little to do with security concerns and a lot to do with the fact that the GL model is a poor fit to the direction hardware has taken over the past couple of decades. Realistically, any successor is going to be benchmarked to within an inch of its life too, so the same worry would apply.
The shape of that successor is still very vague, but it'll probably be closer to the Vulkan/Metal/DX12 generation. Various interested parties have been putting together exploratory proposals (see e.g. Mozilla's Obsidian), and Khronos appears to be accepting that "Vulkan everywhere" ain't going to happen and working on a "3D portability" initiative that's pretty much lowest-common-denominator. That would almost certainly have a web binding if it pans out.
Disclaimer: I don't work in this area, I just follow it out of morbid curiosity.
A few links:
https://www.khronos.org/api/3dportability/
http://floooh.github.io/2016/08/13/webgl-next.html
https://www.phoronix.com/scan.php?page=news_item&px=Mozilla-Obsidi…
rl3 · 2017-01-03
Orthodox style argument aside, this project uses a build system written by the same author called fips[0]. I've tried it myself, and it's an absolute joy to use. A few simple commands will get you up and running on any supported platform, and it does an excellent job of telling you what went wrong if there's a failure. It also has a system for compiling the same shaders to multiple platform targets.
Oryol's demos[1] are impressive as well. Especially the ones that showcase emulation and various integrations of immediate-mode GUI frameworks.
The entire project is underrated in my opinion. With web assembly slowly coming alive, there's a distinct lack of small, multi-platform engines designed with the web in mind. I only wish Oryol's ecosystem was larger, it could be a realistic alternative to Three.js perhaps—if it isn't already.
Keep up the good work floeofwoe. :)
[0] https://github.com/floooh/fips
[1] https://floooh.github.io/oryol/
ChrisArchitect · 2026-07-21
Related:
Tiny Emulators
https://floooh.github.io/tiny8bit/ (https://news.ycombinator.com/item?id=48884395)
rudedogg · 2025-09-09
The tagging mechanism reminds me of generational indices like https://floooh.github.io/2018/06/17/handles-vs-pointers.html, but I’m a bit out of my depth
lioeters · 2025-05-22
Yes I think it's similar in scope to Raylib. I'm learning this as I go, but here's a page with many demos compiled to Wasm.
https://floooh.github.io/sokol-html5/index.html
In the README they have example usage ranging from 8-bit emulators, games, command-line tools, integration with Dear ImGui and other libraries, bindings to languages like Zig, Rust, Odin, Nim.
> WebAssembly is a 'first-class citizen', one important motivation for the Sokol headers is to provide a collection of cross-platform APIs with a minimal footprint on the web platform while still being useful.
skywal_l · 2025-04-28
Flooooh's code is also very easy to read so it's a pretty good documentation for these old systems especially as the (some?) emulators are cycle accurate[0]
[0]: https://floooh.github.io/2019/12/13/cycle-stepped-6502.html
dang · 2025-04-28
Changed from https://floooh.github.io/tiny8bit-preview/ now. Thanks!
cassepipe · 2025-03-08
I remember reading this some time ago : https://floooh.github.io/2019/09/27/modern-c-for-cpp-peeps.html
I do use those so thank you :)
kps · 2025-01-09
‘Handles are the better pointers’¹ is a related writeup that has been discussed here before².
¹ https://floooh.github.io/2018/06/17/handles-vs-pointers.html
² https://news.ycombinator.com/item?id=36419739
Aissen · 2025-01-08
You might also want floooh's remix which has a nicer UI, with the ability to see instructions evaluated, modify memory, assemble/disassemble code, view traces, etc.
Visual 6502 remix: https://floooh.github.io/visual6502remix/ Visual Z80 remix: https://floooh.github.io/visualz80remix/
dsp_person · 2024-08-16
it's easy nowadays to compile imgui apps to wasm/html5
examples:
https://web.imhex.werwolv.net
https://floooh.github.io/sokol-html5/imgui-sapp.html
taminka · 2024-02-20
lowkey smart pointers are often just used to deflect the responsibility of thinking about memory layouts
https://floooh.github.io/2018/06/17/handles-vs-pointers.html
and most issues can be caught by using a static analyser of a memory leak checker (getting ppl to consistently use them is another issue, but still)
joeld42 · 2023-12-20
There's a bunch here
https://github.com/floooh/sokol-samples
For example, the basic demo window:
https://floooh.github.io/sokol-html5/imgui-sapp.html
zackoverflow · 2023-11-03
Most of the time you don't need to do this, usually its the solution for when creating a graph structure with cyclic references.
But when you do, and your data is mutable, generational indices are a legit and very useful strategy that is used in C/C++ too.
See this: https://floooh.github.io/2018/06/17/handles-vs-pointers.html
naasking · 2023-02-05
The point is that you can get some safety guarantees. Nowhere near the degree of guarantees available in safer languages, but still better than the status quo.
Edit: one example of a pattern, whose name I can't remember, was to switch from returning pointers to data structures, to returning pointer offsets as handles. Using these handles you can then track more information about validity and handle "null pointers" more sensibly rather than it introducing undefined behaviour. In superscalar processors the offset calculation basically costs nothing, but the additional safety can be considerable. I believe I read about this pattern in game engines, let me know if you know the name of it!
Edit 2: I think this is it:
https://floooh.github.io/2018/06/17/handles-vs-pointers.html
smcl · 2023-01-24
I clicked around your Github profile. You've implemented heaps of cool wee projects! I particularly linked "tinyemus" :D
edit: maybe I should actually link the page in case people think you're trying to create a smaller pet-sized Emu through selective breeding: https://floooh.github.io/tiny8bit
stan680 · 2023-01-04
lots of good examples of why this is wrong here: https://floooh.github.io/2019/09/27/modern-c-for-cpp-peeps.html
sph · 2022-12-23
> https://floooh.github.io/sokol-html5/nuklear-sapp-ui.html
The check-box being an empty square when it's checked, and a filled square when it's unchecked is an unpopular design decision.