11 ms·
Porting my JavaScript game engine to C for no reason
- zoogeny 2y agoThe next logical step is to port this to WASM so that it can run in the browser.
- igor_akhmetov 2y agoThe engine already compiles to WASM, see TLDR.
- zoogeny 2y agoI skimmed right by that. Have you done any feature comparisons against raylib?
- azakai 2y agoDirect link to playable wasm version: https://phoboslab.org/high_impact/biolab/ https://phoboslab.org/high_impact/biolab/
- fragmede 2y agothe number of layers it takes to get it to work on my phone is so high, but it's amazing.
- uberman 2y agoThanks, this was a great read.
- senkora 2y ago> Many Web games were created with Impact [the game engine from the article] and it even served as the basis for some commercial cross-platform titles like Cross Code, Eliot Quest and my own Nintendo Wii-U game XType Plus. Cross Code is an excellent game. I knew that it used web tech and I was constantly amazed by how performant it was on the Nintendo Switch hardware. I would guess that this engine deserves some credit there!
- phoboslab 2y agoTo be fair, they modified Impact _a lot_. In some of their development streams[1] you can see a heavily extended Weltmeister (Impact's level editor). Imho, that's fantastic! I love to see devs being able to adapt the engine for their particular game. Likewise, high_impact shouldn't be seen as a “feature-complete” game engine, but rather as a convenient starting point. [1] https://youtu.be/4lZfnM9Ubeo?t=3215 https://youtu.be/4lZfnM9Ubeo?t=3215
- pdpi 2y ago> To be fair, they modified Impact _a lot_. You can't polish a turd. There would've been no point in modifying the engine a bunch if you hadn't given them a useful base to work with.
- BadHumans 2y agoIn game development this isn't true for better or worse. There is a lot of sunken cost mindset in games that we just go with what we have because we have already invested the time in it and we'll make it work by any means.
- Modified3019 2y agohttps://en.m.wikipedia.org/wiki/Dorodango https://en.m.wikipedia.org/wiki/Dorodango
- make3 2y agothat's just crazy bs, starting from open source code and adding specific features needed for a project is a very common strategy, doesn't mean at all that the tool wasn't good to begin with
- xtirpation 2y agoI think the point is that Impact is _not_ a turd because it could be polished.
- 2y ago
- two_handfuls 2y agoNice writeup! I didn’t see mention of the license: it’s MIT and the code is on GitHub.
- F3nd0 2y agoMIT/Expat, to be precise.
- nottorp 2y ago> for No Reason Out of respect for your player's battery life, perhaps :)
- muragekibicho 2y agoSomewhat related. Your QOI lossless file format coupled with 7Zip outperfoms lossless PNG. Amazing work!
- pornel 2y agoBMP coupled with 7Zip would outperform too (probably by a bigger margin). It just boils down to gzip vs gzip-replacement compressor.
- zX41ZdbW 2y agoI also found that BMP with ZSTD outperforms PNG while developing https://adsb.exposed/ https://adsb.exposed/ (it streams raw RGBA over HTTP with Content-Encoding: zstd)
- vanderZwan 2y agoNot to mention the part where adding compressors like this somewhat defeats the purpose of using a simple format like QOI (although at least zstd is faster than gzip, let alone 7zip). But if we're modifying things like that, then they might as well make use of Nigel Tao's improved QOIR format, and replace the LZ4 compressor it uses with zstd. That's probably faster and likely compresses better than QOI. [0] https://nigeltao.github.io/blog/2022/qoir.html https://nigeltao.github.io/blog/2022/qoir.html [1] https://github.com/nigeltao/qoir https://github.com/nigeltao/qoir
- rurban 2y agoReplacing lz4 with zstd will give you half the speed, with just better compression. https://gregoryszorc.com/blog/2017/03/07/better-compression-with-zstandard/ https://gregoryszorc.com/blog/2017/03/07/better-compression-...
- vanderZwan 2y agoSo to clarify: my suggested point of comparison was replacing QOI + 7Zip of GP with QOIR + zstd. QOIR already compresses better than QOI before the LZ4 pass, and zstd compresses faster than 7zip and often better. On top of that you can put zstd in the header option when streaming data on a browser so you don't need to increase the JS bundle or whatever if the use case is the web. So that's basically a guaranteed net improvement all around. Second of all, the speed/compression trade-off with zstd can be tuned a lot. The "half as fast as LZ4" stat is for the fastest setting, but for the proposed comparison point of 7zip a slower setting with better compression ratio is likely perfectly fine. [0] https://github.com/facebook/zstd/tree/dev?tab=readme-ov-file#benchmarks https://github.com/facebook/zstd/tree/dev?tab=readme-ov-file...
- Defletter 2y agoAs one of those 3000 licence holders, I'm happy to see a revival of Impact :) wonder how nicely it plays with Zig.
- kirbyfan64sos 2y agoHad to log in to my rarely-used HN account to mention that I had played Biolab Disaster over and over again years back but lost track of it and forgot the name. Kinda wild to find it again by sheer luck!
- leeoniya 2y agonow rewrite it back to JS with https://github.com/KilledByAPixel/LittleJS https://github.com/KilledByAPixel/LittleJS j/k :D
- deleted 2y ago[deleted]
- nine_k 2y agoWhy, from C to Zig, from Zig to Rust. Compile the Rust version to WASM to finally make it runnable in the browser.
- Defletter 2y agoDoesn't Zig compile to WASM too?
- flohofwoe 2y agoYes, for instance this is mixed Zig/C project (the C part are the sokol headers for the platform-glue code): https://floooh.github.io/pacman.zig/pacman.html https://floooh.github.io/pacman.zig/pacman.html The Git repo is here: https://github.com/floooh/pacman.zig https://github.com/floooh/pacman.zig ...in this specific project, the Emscripten SDK is used for the link step (while compilation to WASM is handled by the Zig compiler, both for the Zig and C sources). The Emscripten linker enables the 'embedded Javascript' EM_JS magic used by the C headers, and it also does additional WASM optimizations via Binaryen, and creating the .html and .js shim file needed for running WASM in browsers. It's also possible to create WASM apps running in browsers using only the Zig toolchain, but this requires solving those same problems in a different way.
- nine_k 2y agoYes, but the point of the joke was to make the loop longer, while keeping it somehow logical. I wish I managed to insert Purescript, Elixir, Pony and ATS somehow.
- leeoniya 2y ago
- moffkalast 2y agoWith WASM it might actually run faster in the browser as well.
- echelon 2y agoWASM still needs better multi-threaded support. We built a game in Bevy and it took minutes to sequentially load in all of the assets.
- flohofwoe 2y agoYou don't need multithreading to get concurrent asset streaming, a completion callback or async-await-style code will work too (after all, that's how most Javascript web games load their assets "in the background"). Also, browsers typically restrict concurrent download streams to about 6 (the exact number is entirely up to the browser though) - so you can have at most 6 asset files 'in flight'. In the end you are still limited by the user's internet bandwidth of course.
- echelon 2y agoNone of that worked out of the box, and we also spent most of the loading time CPU bound, processing the individual assets after they arrived over the wire. That was a blocking, non-async operation.
- andai 2y ago>processing the individual assets after they arrived over the wire Could this take place at compile time?
- flohofwoe 2y agoThen the next question is why your asset formats require such heavy processing after loading. Normally you'd convert any data into custom engine formats in an offline step in the asset pipeline so that the files can be dumped directly into memory ready for the engine (and 3D API) to be used without an expensive deserialization process. FWIW, POSIX style multithreading in WASM is supported everywhere for a while now again (it was disabled after Spectre/Meltdown) but is locked behind special COOP/COEP HTTP headers for security reasons (so you either need to be able to configure the web server to return those headers, or use a service worker to inject the headers on the client side.
- pjmlp 2y agoLove the honesty of the headline. The game looks cool.
- slowhadoken 2y agoI used to play X-Type all the time on iOS, it’s how I discovered Impact. I love web-based games but lately I’ve been tempted to write in C or C++. Did you notice dramatic gains in optimization porting Impact from JavaScript to C?
- mgaunard 2y agoThe history section does not feel quite accurate. From what I recall, what killed Flash wasn't iOS, but rather the acquisition of Macromedia by Adobe.
- lelandfe 2y agoFlash game sites were still huge and popular after Adobe’s purchase, so clearly it did not kill it. If you mean something like that the acquisition started the death… that’s a hard position to argue against, since it’s subjective. Perhaps you’re right.
- mgaunard 2y agoAdobe had competing products mostly based on open standards. They shut down many active product lines and merged what was left into Adobe AIR, which didn't take off.
- lelandfe 2y agoAIR and Silverlight and co. was a weird moment in the web’s history
- phamilton 2y agoWhen flash started to fade for games, many developers moved over to adtech where their skills were still valued. Flash continued for a few years to power ads as well as shims around other videos that would collect data and even trigger secondary ad auctions.
- andai 2y agoAdobe was well into the development of AS 4.0, then scrapped it after Steve Jobs' psyop.
- phamilton 2y agoOne of the final nails was the infamous Chrome 45 aka the Chromepocalypse in the video ad world. Chrome 45, in the name of performance, defaulted to only loading flash from 3rd party domains after a "click to load". This was bad for ads for obvious reasons, but it was much much worse due to an implementation detail. In order to get the page laid out properly, Chrome loaded the flash component and then suspended it after a single frame. From an ad perspective, that was enough to trigger the impression pixel, signifying that the ad had been shown and the advertiser should be billed. However, the ad was not shown and there was no way for the ad to detect it had been suspended. Just a nightmare. We (I led the effort at BrightRoll) had to shift a ton of ad auction behavior to special case Chrome 45 and it limited what kind of ads we could serve. That was the inflection point away from flash for ads. While ad formats like VPAID supported JS/HTML5, they didn't start getting popular until after Chrome 45 was released.
- fitsumbelay 2y ago"Thoughts on Flash" may just have saved the Web platform at its hour of greatest need, ie. creeping dominance of a single piece of software. I believe that somewhere in there was frustration with Adobe who seemed to abandon the MacOS platform support for Windows' much larger user base, eg. Mac versions were always behind Windows versions. Perhaps Jobs also may've felt that there would be no Adobe without Apple as much as the other way around but that's speculative The game looks slick af btw,
- golergka 2y agoEven PSP had Flash, and it was fairly decent. I wonder how much effort and money Sony put into that.
- olliej 2y agoFlash had numerous issues. The processing power available (especially on a PSP) is more than enough to be “good”, the problem with flash _performance_ is the power usage while achieving that perf. Even on laptops flash was a significant battery life drain whenever it was running, having it on all websites would kill battery life while browsing on a phone.
- thedragonline 2y agoYeah it did. I'm just sad that it took down ActionScript with it. IMO this is the language Javascript should have been.
- cpeterso 2y agoActionScript was a big influence on ECMAScript 4 until it was abandoned and scaled back for ECMAScript 5 “Harmony”: https://en.m.wikipedia.org/wiki/ECMAScript_version_history#4th_Edition_(abandoned) https://en.m.wikipedia.org/wiki/ECMAScript_version_history#4...
- fitsumbelay 2y ago... and the post has me poking around with C again. was always an ecmascript guy with a little Lingo in there from long ago, however I have an itch for all things low-resource and close to the metal (but not assembly lang close) and golfing my way towards somethings that encourage me to dig deeper
- hoten 2y agoAmazing work! FYI - in non-fullscreen mode, on my Mac / Chrome, the bottom of the viewport is cut off. So can only play in fullscreen.
- andai 2y agoI did 5 game jams this year, 4 of them in various WebAssembly languages (C++, Zig, Odin, Rust). In the end I switched back to JS/TS, because I found way more benefit from minimizing layers of abstraction and translation (WS is set up so you are forced to interface with JS to actually do anything), more than the benefits of any language or library. (An exception might be something like Unity, due to the excellent featureset, but the IDE has become so slow it's unbearable...)
- deleted 2y ago[deleted]
- jokoon 2y agoWhat amazes me is how modern javascript engines are able to optimize for a "hot execution path".
- cubano 2y agoohhh I love your use of UNION to create a polymorphic-type ENTITY data structure. Nice work and design. I still love futzing around in C...It was the original langauge I learned and God did I struggle with it for years. Like the OP mentioned, C is awesome because its such a concise language but you can go as deep as you like with it. Thanks for all your efforts and the writeup...the game has a throwback Commander Keen-type vibe to it and I loved that franchise for a minute back in Carmack's pre-3D days.
- esschul 2y agoRemember I was working on an impact.js game 10 years ago. Just can't seem to find the source code! First time I hired a guy to create some graphics. Very inspiring gaming platform.
- o11c 2y ago> high_impact is not a “library”, but rather a framework. It's an empty scaffold, that you can fill. You write your business logic inside the framework. I normally phrase this in a much more negative way: a "framework" is simply a "library" that does not place nice with others. It's good to hear a sensible positive phrasing for once.
- grecy 2y agoI studied Software Engineering, but never quite grasped the difference between a Library and a Framework until I started my first job developing with Web Objects. It is a joy to use such a rich and well thought out Framework that really does do 99% of everything you need. Adding in your own stuff is about the easiest development I've ever done, and it just works. It was magic, and I miss using it.
- mmoskal 2y agoThe way I heard it described is that you call the library while the framework calls you.
- 01HNNWZ0MV43FF 2y agoI do still think it's negative. My ideal framework is a library or set of cooperating libraries on the inside, with as little framework as possible. e.g. Qt is a framework. Qt "calls you". But you can run the QPainter code without starting the Qt event loop or thinking too hard about QObjects. You should ideally be able to use the event loop without buying into signals and slots, though it won't be as ergonomic. It's not always possible, it's not always worth it, but everything else being equal, I'd rather have no framework at all. (For game engines I understand why a little framework is necessary - When you're talking about compiling to a weirdo platform like phones or consoles, the engine must also be involved in your build process and sometimes even libc shit. So you can't just make a Win32 exe that is a PlayStation game.)
- tomcam 2y agoFun idea, open source for maximum learning value, seemingly flawless execution, vanity-free and clear writeup—what a lovely contribution to the world. I feel privileged just seeing things like this.
- jonwinstanley 2y agoLooks like it’s a great game engine. Why does the article state its near end of life? Are there new engines that are far better?
- phoboslab 2y agoThe original JavaScript engine “Impact” from 2010 is at the end of its life; the C rewrite “high_impact” is new and will (potentially) be around for as long as we have C compilers and some graphics API. The JavaScript engine had a lot of workarounds for things that are not necessary anymore and some things that just don't work that well with modern browsers. From the top of my head: - nearest neighbor scaling for pixel graphics wasn't possible, so images are scaled at load time pixel by pixel[1]. Resizing the canvas after the initial load wasn't possible with this. Reading pixels from an image was a total shit show too, when Apple decided to internally double the Canvas2D resolution for their “retina” devices, yet still reporting the un-doubled resolution[2]. - vendor prefixes EVERYWHERE. Remember those? Fun times. Impact had it's own mechanism to automatically resolve the canonical name[3] - JS had no classes, so classes are implemented using some trickery[4] - JS had no modules, so modules are implemented using some trickery[5] - WebAudio wasn't a thing, so Impact used <Audio> which was never meant for low latency playback or multiple channels[6] and generally was extremely buggy[7]. WebAudio was supported in later Impact versions, but it's hacked in there. WebAudioContext unlocking however is not implemented correctly, because back then most browsers didn't need unlocking and there was no "official" mechanism for it (the canonical way now is ctx.resume() in a click handler). Also, browser vendors couldn't get their shit together so Impact needed to handle loading sounds in different formats. Oh wait, Apple _still_ does not fully support Vorbis or Opus 14 years later. - WebGL wasn't a thing, so Impact used the Canvas2d API for rendering, which is _still_ magnitudes slower than WebGL. - Touch input wasn't standardized and mobile support in general was an afterthought. - I made some (in hindsight) weird choices like extending Number, Array and Object. Fun fact: Function.bind or Array.indexOf wasn't supported by all browsers, so Impact has polyfills for these. - Weltmeister (the editor) is a big piece of spaghetti, because I didn't know what I was doing. Of course all of these shortcomings are fixable. I actually have the source for “Impact2” doing all that with a completely new editor and bells and whistles. It was very close to release but I just couldn't push it over the finish line. I felt bad about this for a long time. I guess high_impact is my attempt for redemption :] [1] https://github.com/phoboslab/Impact/blob/master/lib/impact/image.js#L82-L112 https://github.com/phoboslab/Impact/blob/master/lib/impact/i... [2] https://phoboslab.org/log/2012/09/drawing-pixels-is-hard https://phoboslab.org/log/2012/09/drawing-pixels-is-hard [3] https://github.com/phoboslab/Impact/blob/master/lib/impact/impact.js#L180-L198 https://github.com/phoboslab/Impact/blob/master/lib/impact/i... [4] https://github.com/phoboslab/Impact/blob/master/lib/impact/impact.js#L458 https://github.com/phoboslab/Impact/blob/master/lib/impact/i... [5] https://github.com/phoboslab/Impact/blob/master/lib/impact/impact.js#L230-L354 https://github.com/phoboslab/Impact/blob/master/lib/impact/i... [6] https://phoboslab.org/log/2011/03/multiple-channels-for-html5-audio https://phoboslab.org/log/2011/03/multiple-channels-for-html... [7] https://phoboslab.org/log/2011/03/the-state-of-html5-audio https://phoboslab.org/log/2011/03/the-state-of-html5-audio
- theapache64 2y agodude is an OG!
- elfelf11 2y agoWould love to have a ruby binfing.
- jeden 2y agoor cristal ;) (or mrubyc)
- 38 2y ago> Except for SDL2, all libraries are bundled here (see the libs/ directory). https://github.com/phoboslab/high_impact#libraries-used https://github.com/phoboslab/high_impact#libraries-used yep. exactly why I dont use C anymore. the package management story is so bad/non existent, that the typical approach is to just vendor everything. no thanks.
- hammycheesy 2y ago> My decision to sell it was met with a lot of backlash but was successful enough to launch me into a self-sustained career. As someone who is interested in eventually freeing myself from the corporate job and diving head-first into my side projects, I would love to hear more about this aspect. For some reason the idea of trying to charge folks for the work I would normally do for the fun of it on the side is daunting to me, even though I know it could enable me to focus on doing the stuff I love full-time.
- h4ny 2y agoIt's perfectly reasonable to get compensated for the (good) work that you do if it's solving problems for someone, which you probably already know. So I think it's important to figure out why the idea of doing that is daunting to you. Some common "reasons" are: - People you interact with frequently tell you to not to do it. - Not having all the skills to execute what you want to do well. - Asking people for help feels embarrassing and/or is annoying to them. - The fear of having your work judged by others. - Losing the "safety" that part of, or all of, your current income offers; especially if you have dependents. For most people (in the context of what you said), those aren't really good reasons—it's just because it's difficult to leave the comfort zone (nothing wrong with that) because that will require at least some degree of readjustment that seem "risky". With that mindset it's actually very difficult to ever find a good time to do what you _want_ to do because all opportunities appear to be risks instead. On a somewhat related note, I think it's important to just do what you think is fun and show it to the world, but turning that into something that you can make a living with is an entirely different challenge. Most people don't actually get to do what they love doing for a living; even if you do, having the pressure that is the expectations of paying customers and/or maintaining revenue could take that love away from you. That's absolutely not to say that you shouldn't—it's just something that's good to be aware of before you jump into it.
- namuol 2y agoI owe a lot of the most informative programming work I’ve done to Impact. Impact was so ahead of its time. Proud to say I was one of the 3000 license owners. One of the best purchases I’ve ever made. The only game I’ve ever really properly finished was made in Impact. I loved that the source code was part of the license, and even modified the engine and the editor to suit my needs. I was so inspired that I worked on my own JS game engine (instead of finishing games - ha!) for years after. I never released it, but I learned a ton in the process and made a lot of fun gamejam games with it. I was also inspired by Impact’s native iOS support (Ejecta), but frustrated that it didn’t run on Android (at the time at least), so I fumbled my way through writing JVM bindings for V8 and implemented a subset of WebGL to run my game engine on Android without web views.[0] I made the repo for V8 bindings public and to my surprise it ended up being used in commercial software. I won’t bore you with the startup I tried to bootstrap for selling access to private GitHub repos, which was inspired by Impact’s business model… Anyway, it warms my heart and makes me laugh with glee to see Impact getting an update for the “modern” web with a C port! I’d say these are strange times for the web, but I can’t remember a time when things were anything but strange. Cheers! [0]: https://github.com/namuol/jv8 https://github.com/namuol/jv8
- jdnxudbe 2y agoI might be missing something, but isn't the original Impact a JavaScript & browser based engine, thus it should run on Android in a simple Web view just fine?
- cookiengineer 2y agoHonestly I would never ever execute any code from this guy. He is the inventor/founder behind the coinhive crypto mining network. [1] This guy made billions illegally [2], and maintained the biggest ransomware crypto coin network for years, by offering the tools and SDKs to fund dozens of cyber war involved agencies across the planet. [3] I have no idea how he got away with it, because his name keeps appearing in lots of crypto trading companies and trade registries. (Not gonna post them, but you can google his name to find this evidence) He even organized a doxxing campaign against brian krebs at the time called "krebsistscheisse" via his pr0gramm platform [4] [5] [6], to somehow defend the idea that abusing user's computers for personal enrichment is a legit way of making money if you donate some low percentage to cancer research with it?!? Sorry, but I would never trust this guy's code again. You should be careful, and audit any code he writes before you execute it. [1] https://krebsonsecurity.com/2018/03/who-and-what-is-coinhive/ https://krebsonsecurity.com/2018/03/who-and-what-is-coinhive... [2] 30% fee of monero/XMR went to coinhive: https://coinmarketcap.com/currencies/monero/ https://coinmarketcap.com/currencies/monero/ [2b] Schuerfstatistik on pr0gramm, where it all started: https://web.archive.org/web/20231005033135/https://pr0gramm.com/user/pr0gramm/uploads/2048362 https://web.archive.org/web/20231005033135/https://pr0gramm.... [2c] Troyhunt analysis after he snatched away the coinhive TLD: https://web.archive.org/web/20240804081830/https://www.troyhunt.com/i-now-own-the-coinhive-domain-heres-how-im-fighting-cryptojacking-and-doing-good-things-with-content-security-policies/ https://web.archive.org/web/20240804081830/https://www.troyh... [3] https://www.trendmicro.com/vinfo/us/security/news/cybercrime-and-digital-threats/coinhive-miner-the-6th-most-common-malware https://www.trendmicro.com/vinfo/us/security/news/cybercrime... [3] https://krebsonsecurity.com/tag/dominic-szablewski/ https://krebsonsecurity.com/tag/dominic-szablewski/ [4] https://krebsonsecurity.com/2019/03/annual-protest-raises-250k-to-cure-krebs/ https://krebsonsecurity.com/2019/03/annual-protest-raises-25... [5] (German) https://www.t-online.de/digital/aktuelles/id_83466874/tausende-pr0gramm-nutzer-spenden-aus-aerger-ueber-brian-krebs-gegen-krebs.html https://www.t-online.de/digital/aktuelles/id_83466874/tausen... [6] https://www.heise.de/news/krebsistscheisse-Spendenwelle-an-Krebshilfe-als-Protest-gegen-IT-Journalisten-4007994.html https://www.heise.de/news/krebsistscheisse-Spendenwelle-an-K... (Lots of other articles about it, and that dominic szlablewski was the guy behind coinhive, and the original owner of pr0gramm, while still doing development work for the company that owns the imageboard officially nowadays)
- syockit 2y ago> The name high_impact is a nod to a time when C was considered a high level language. Weird, considering that JS is an even higher level language.
- creesch 2y ago"To a time", meaning the past... :)
- taf2 2y agoNow to compile with wasm so we can use it in a browser
- dgb23 2y agoI like the part about memory management. Arenas are so simple. In the (toy) web server I'm writing I initially also started with arenas. However I quickly realized that I don't actually need to grow and shrink memory at all. Currently I'm simply allocating the memory I need up front then slice it up into pieces for every module. When we're programming, we often pretend like we could be needing arbitrary amounts of memory, but that's not necessarily the case. Many things actually have very clear limits. For the rest one can often define them. And if you enumerate those, you know how much memory you will need. It is fun to think about and define those limits up front. It builds a lot of confidence and promotes a healthy frugality.
- i80and 2y agoThe TigerBeetle database is built this way, and I kind of love the concept https://tigerbeetle.com/blog/a-database-without-dynamic-memory https://tigerbeetle.com/blog/a-database-without-dynamic-memo...
- TillE 2y agoRight, I'm always annoyed when people talk about how std::vector has terrible performance (especially for games), which it certainly does if you just start with an empty vector with no memory reserved and append a few thousand items. But it is very frequently possible to find the actual maximum you will need, allocate that upfront, and everything's great.
- dgb23 2y agoCoincidentally that's how I started thinking about limits and allocating everything up front. I wanted to try out arena allocation, with one arena per http request (and one for the entire lifetime). But when I realized that if I wouldn't allocate a large enough backing array (capacity) then memory would grow by n+(n+1)+(n+2)... every time I allocate on the arena during a request. Now you're right that this is not necessarily a problem. But this is a side project that I just write in order to learn and explore stuff. So I thought I would need to figure out a static capacity and was thinking about how to go about this. Then I realized I don't need a data structure that grows, but only a slice of a static memory region, which then means I don't need an arena (which can arbitrarily grow) in the first place. Now I'm exploring all kinds of things that a web server does and where I would normally use a dynamically growable data structure. Like parsing JSON, form parameters, HTTP headers etc. And I can find natural or self imposed limits for all of those things. For me, the most interesting thing about this isn't even performance. It's the mere fact that you _can_ figure out and design those limits. And the resulting code doesn't become complicated, but looks much simpler than I would have guessed. I really like the exactness of it all and how it changes the way I think about these things.