HNHacker News
TopNewBestAskShowJobs

Panzerschrek

460 karma · joined September 10, 2025

submissionscomments
Panzerschrek··on Show HN: Cppbolt – A lightweight C++ to WebAssembly compiler written in Rust
A C++ compiler in three weeks? Is it vibe-coded?
Panzerschrek··on Union Types and Option Types (2025)
Pointer arithmetic on modern computers is basically free. But cache-misses caused by accessing a union tag located far away are not free.
Panzerschrek··on Union Types and Option Types (2025)
> The option type, despite being simpler than union type introduces many new concepts and requires additional knowledge that make the language more complex.

That's why I do such things in my language in a different way. Optional and union types are just library container classes. More methods may be added if necessary, internal layout may be changed, etc. without changing the language core itself. But in such an approach the language itself should provide necessary means allowing creation of such library abstractions.

Panzerschrek··on Union Types and Option Types (2025)

  var value = maybeValue.notNil // I know what I'm doing
How does it work exactly? Does it perform a runtime check, or just trusts the programmer?
Panzerschrek··on Handles are the better pointers (2018)
> First, you're obviously paying indirection tax on EVERY lookup

It's not true for typical use-cases, when objects aren't processed one by one, but in bulk.

> Next, you have type bloat

What's the problem? Do you pay a special tax each time you need create a new type?

> Prepare for a lot of this

That's not how it's done in C++. You typically have a template for handle types, so that PlayerHandle is just Handle<Player>.

> Handles are also a lot bigger.

The article mentions, that handles are typically smaller than pointers. A pointer is 8 bytes (on 64-bit machines), but handles can be smaller if not so many objects are needed to be created.

> Next, you have the issue of resizing your memory array.

There is only problematic to resize it down, which is almost never needed.

> dozens of arrays

> manage the lifespans and scope of all these object pools

It's not a problem. Each subsystem owns its arrays and destroys them only when the subsystem itself is destroyed.

Panzerschrek··on Handles are the better pointers (2018)
Nice approach! I did something similar in my recent project (even if it was not C++). But I didin't bother handling overflow of generation counter, since for my purposes 32 bits were more than enough.
Panzerschrek··on Copper – A minimal low-level programming language with OOP and generics
Is it memory safe? Or is it yet another "better C"?
Panzerschrek··on Ask HN: I'd like to request Microsoft open source Windows XP
https://github.com/DeDf/winxp_source

Knowing that Github is owned by Microsoft, they probably are fine with it.

Panzerschrek··on Show HN: NES Contra (1987) port (ASM –> C and then C –> WebAssembly)
Recently I did something similar (or even more labor-intensive). I recreated an existing game from scratch by manually rewriting its code without even thinking about LLM/"AI" tools usage. (see my submissions).

But I agree, that using an "AI" tool may be a serious temptation and thus way less new porting projects will be done with such care.

Panzerschrek··on The importance of communities around software
> there is something more important than license: community

Is there such thing as "community" at all? As I know, the majority of open-source projects are developed by a single person, where others only contribute bug reports (in best case). It's not a community, if there is such imbalance in contribution and power.

Only a handful of projects (a small percentage) has actual community with many members doing meaningful contribution. But they are most notable ones, so that one may think, that all open-source projects function like this.

Panzerschrek··on Iterating Backwards in C
I do this in another way:

  for( size_t i_plus_one = count; i_plus_one > 0; --i_plus_one )
  {
      const size_t i= i_plus_one - 1;
      // actual loop code
  }
It's in my opinion better than using i-- as condition, since I generally avoid using results of -- and ++, because doing so is bug-prone.
Panzerschrek··on Billion-query-per-second lookup tables in C++
> How do we find the association values? We sort the characters by how many keys they touch. We then take them one at a time and try 0, 1, 2, … until we find a value that does not cause a collision.

This sounds too easy to be true. As I understand, that's the core of the whole approach - to find a table filled with some magic values giving perfect hashing. And it shouldn't be that simple, since search space is huge (a table with 256-values each with 8 bits size at least).

Panzerschrek··on Billion-query-per-second lookup tables in C++
Nice approach. I hope some time compilers will eventually learn to detect code containing a bunch of if-else with string comparison and replace it with perfect hashing.
Panzerschrek··on The Goose Programming Language
Look at my language: https://github.com/Panzerschrek/U-00DC-Sprache/. It has plenty of interesting ideas, but is fully human-written (and will remain human-written).
Panzerschrek··on The Goose Programming Language
> Memory is a handful of data stacks that the compiler assigns statically

I doubt this can work well in all cases. Sooner or later one needs proper heap.

Panzerschrek··on The Quake Fan who built the map editor everybody uses
I don't know what Unreal Tournament did use internally, it's hard to investigate, since there is no (official) source code release for it. But I do know, that brush-based (additive) approach isn't strictly necessary for creating maps for Quake/Quake II/Quake III, it's technically possible to write a map compiler taking maps in some subtractive format. The reason why it's not done (or at least not common) is because it's not a trivial task and because existing infrastructure adds some friction.
Panzerschrek··on The Quake Fan who built the map editor everybody uses
Trenchbroom is very good, but I still think, it's not the best possible map editor. It uses brush-based approach, which isn't the right way of designing maps for games in closed spaces (like Quake). Creating each room requires creating at least 6 brushes for its walls/floor/ceiling, which is way to much for such stuff. On the other hand Unreal Editor (for first Unreal and Unreal Tournament) supports creating rooms directly (as subtractive brushes), when two room primitive touch each other, they are automatically connected.
Panzerschrek··on We have traits at home
I see little to no benefits of introducing such "traits" into a language having duck-typing in templates. It may sometimes improve code readability (slightly), but with more boilerplate code for traits handling in exchange. And the result machine code will be identical to code with no traits at all (with only duck-typing).

C++ is a good example of this. It had duck-typing in templates for decades. Then some sort of trait-like mechanism named concepts has been introduced. The only benefit of them seems to be slightly better error messages if someone misuses a template class/function.

Panzerschrek··on I can't believe PowerShell is good
Does it have automatic error handling, so that if one command fails, the whole script fails too? Last time I tried it, I needed to write

   if ($LastExitCode -ne 0)
after each command.
Panzerschrek··on Composite objects and C++26 the std:polymorphic type
Typical C approach. In C++ this should be done with std::variant instead. It has the exact same binary layout, but is type-safe (compared to union usage).
Panzerschrek··on Composite objects and C++26 the std:polymorphic type
Does std::polymorphic require passed types to be copyable?
Panzerschrek··on JAXA is about to perform a Phobos sample return mission
Russia tried such mission back in year 2011: https://en.wikipedia.org/wiki/Fobos-Grunt. Sadly it failed shortly after the launch.
Panzerschrek··on Flatpak – An Insecurity Nightmare
My app doesn't require sandboxing. And vulnerabilities aren't important, since it's not intended to work with untrusted data and/or use network.
Panzerschrek··on Flatpak – An Insecurity Nightmare
I once tried packaging my application using Flatpack. But I saw no benefits of using it. I can as well just link all my dependencies statically (which I eventually ended using).
Panzerschrek··on Constructors Shouldn't Throw
> Turn your Database class into a state machine with an uninitialized and a connected state. Then have a Database.connect()

It's a bad advice. It's preferred instead to have a connect function returning a database instance in a successful case or an error otherwise.

Panzerschrek··on Parser Combinators
All this seems for me to be overcomplicated. Naturally parsing is just a function, which may call subfunctions, sometimes recursively. Sometimes it can do it in a loop - in order to parse sequences. I have written many parsers in such a way and I didn't even require such terms as "parser combinators".
Panzerschrek··on I Love Software Rendering
Software renderer of Quake II has no colored lighting. It's OpenGL-only feature. Half-Life and Unreal do this better, they support colored lighting in their software mode.
Panzerschrek··on I love software rendering
> Games worth trying

I can add more:

Unreal (and Unreal Tournament), Thief, Quake II (a slight improvement over Quake), Half-Life (a great improvement over Quake), Shadow Warrior, Any modern port of Doom supporting software rendering, Heretic, Hexen, Descent, System Shock, Homeworld.

Panzerschrek··on I love software rendering
I too. So that I have written many software renderers in many years. A video with my recent project having a software renderer: https://www.youtube.com/watch?v=NepOPAPDvwA
Panzerschrek··on The Double Headed Stack Allocator
> Imagine that you had a streaming world game where as the player ran around the world, old level geometry would deallocate, and new level geometry would allocate and stream in from disk.

In such case stack-like allocator isn't the best strategy. One can use some sort of cyclic allocator instead. As I know Quake did this for surfaces cache.

Page 1 of 16Next →