HNHacker News
TopNewBestAskShowJobs

Panzerschrek

465 karma · joined September 10, 2025

submissionscomments
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.

Panzerschrek··on The Double Headed Stack Allocator
> Once again, these allocators work fine in multithreaded environments

How? As I understand, for such double-headed allocator to be multithreaded one needs to update two counters atomically, which is tricky.

Panzerschrek··on A Modern Web App in C
> There's no separate database server. You open the database file through SQLite's C API.

> Every request spawns a fresh process.

How does it work when multiple concurrent requests are possible? Does SQLite allow simultaneous write access from multiple processes?

Panzerschrek··on Fingerprints are the new cookies
> A news site doesn't need to do audio processing on my machine and read back the buffer? It doesn't need to use webgl to render triangles to an offscreen buffer?

We should go further. A web-site with mostly static content should not use user-side scripting (Javascript) at all, it's unnecessary for it. It should be required only in rare cases where a site is basically an application and require manually turning it on each time such application is opened.

Panzerschrek··on Valen's Memory Safety: A New Kind of Borrow Checking
Try my language: https://github.com/Panzerschrek/U-00DC-Sprache/. It's memory safe (as Rust), but is way simpler (no explicit borrowing and traits hell) and it's already pretty developed (not in an experimental stage).
Panzerschrek··on Valen's Memory Safety: A New Kind of Borrow Checking
The ability to hold a reference to a container and its member seems to be interesting. But I don't think it adds significant value in practice (behind some synthesized examples) and doesn't worth to increase language complexity language compared for a more coarse reference analysis (variable-based).
Panzerschrek··on Valen's Memory Safety: A New Kind of Borrow Checking
> the compiler remembers where a reference points to

> So we spent months sharpening the explanation and figuring out its benefits, and wrote a post 8 on it last year, hoping other languages would pick it up.

My language (see my submissions) has this feature since many years. In its current form it exists roughly since year 2020, but some under-the-hood changes and slight improvements have been done since.

Panzerschrek··on No portable way to detect string-to-float conversion errors in standard C
C number parsing functions are fundamentally broken, since they are locale-dependend. There are many bugs when one parses a number assuming it has decimal point, but later on systems with locale different from one used on developer's machine it may be suddenly comma instead of point. So, one should avoid using them almost always and use std::from_chars (available in new C++ versions) or some other thirdparty library.
Panzerschrek··on Telegram Desktop vulnerability allowed any user's file to be stolen
Download an image from Facebook into browser's private downloads directory, copy it using a file-manager application (one of the exceptional applications having full filesystem access) into Telegram's private directory, upload it into chats you need to post it.

The file-manger application managed above is a single point of failure, of course. So, it should be allowed to use only one provided by OS vendor.

Panzerschrek··on Telegram Desktop vulnerability allowed any user's file to be stolen
> Not all user processes upload those files somewhere surreptitiously.

Only if you have access to full source code, can audit it (including each update) and somehow can prove that it has no vulnerabilities. Otherwise one should assume that any application is potentially-harmful and/or vulnerable.

Panzerschrek··on Telegram Desktop vulnerability allowed any user's file to be stolen
I didn't say it's not a vulnerability. It is clearly one. But allowing such vulnerabilities to deal damage beyond data of its host application is an OS vulnerability.
Panzerschrek··on Telegram Desktop vulnerability allowed any user's file to be stolen
It's not strictly-speaking a Telegram-specific vulnerability. It's a vulnerability of all modern desktop operating systems allowing any user process to read/write any user file. Ideally all programs should be isolated from the underlying filesystem and be able to read only their own files and files from per-program data directory (like downloads for a browser or Telegram-client).
Panzerschrek··on Show HN: Quake ported to safe Rust, playable in browser
How? Was it a LLM-assisted rewrite?
Panzerschrek··on The complement of true is true, except when it's false
Bool should be logically 1-bit, when stored in memory only least significant bit should be used and the rest is allowed to be garbage. Such approach gives compilers as much room for optimizations as possible. Forcing them writing some specific bit-pattern may lead to suboptimal code generation.
Panzerschrek··on The complement of true is true, except when it's false
-1 is not -1 for different sizes of integers. Which exact -1 do you want? 32-bit? 64-bit? int-sized (as int is defined in current implementation)? With current approach it's simple, boolean type is expected to have 1-bit size (which is rounded to 8 bits if stored in memory).
Panzerschrek··on The complement of true is true, except when it's false
With such example:

  bool Complement( bool x )
  {
      return ~x;
  }
GCC gives a warning if compiling with -Wall:

  test.cpp:3:10: warning: ‘~’ on an expression of type bool [-Wbool-operation]
    return ~x;
So, it's surprise that C++ does this, but ones who enable compiler warnings are not in trouble.
Panzerschrek··on TurboPython – A Python-to-C++ Compiler
> there's no notation, the compiler infers that from function body

Good. My language has such ability too (if return type is specified as auto). But I do need a notation for some cases, like if no body definition is available or for recursive functions. How do you deal with recursion?

> the caller gets a warning when b is modified while the borrow is held

Why a warning and not an error?

Panzerschrek··on The technology to eradicate mosquito-borne disease exists
I don't understand how it works. Suppose I can create male mosquitos, which can mate with wild females and affect their offspring in such a way that it can't survive or infect people. But in order for this to be effective, I must also somehow prevent wild males doing their job. Also I need to be able to release very large quantities of modified mosquitos (comparable to overall population size), which seems to be impossible.
Panzerschrek··on Type Safe Generic Data Structures in C (2025)
> m[1] = 42; // implicit alloc

operator[] of associative containers is mutating and may allocate. It's mentioned in the documentation. And there is no operator[] overloading for const instances, so that you can't trigger an allocation by just reading elements from it.

> auto m2 = m; // implicit too

Taking a copy requires making an allocation. Do you expect some other behavior in such case?

> Making everything const correct is too painful in practice, often impossible

Maybe you are dealing with some legacy codebase (from 90s)? I have worked with multiple codebases in past 10 years or so and keeping things which shouldn't be mutated const wasn't a problem at all. All the code was written using such approach.

> why include allocation mechanics with some existing data that never gets changed

I don't think I fully understand this question. What never gets changed? In your example you are mutating a container and taking a copy of it (which can be changed later).

Panzerschrek··on Type Safe Generic Data Structures in C (2025)
> How do you make a shallow copy of an object in C++

Shallow copies aren't generally possible for classes storing something indirectly, since it violates ownership semantics. That's not how things are done in C++.. Operator = is usually used for making copies, which is optimized to memcpy for POD structures, but for something more complex may perform extra work for doing an actual deep copy.

> How do you create a stable ABI in C++

It's a complex topic. Basic ABI for calling functions is identical to C. But one need to keep in mind, that type layouts and internal implementations of library types (like containers) may differ from implementation to implementation and from version to version.

> knowing that all my exported functions will mostly just work and be stable as long as I don’t change the interface

Nothing prevents you doing this in C++. You can have C-style external interface and use all goods of C++ internally.

← PreviousPage 2 of 16Next →