Better HN
topnewbestaskshowjobs
Log inSign up

Panzerschrek

496 karma · joined Sep 10, 2025 (1y ago) · 497 submissions

Submissions

comment 17h ago · link · parent

> What are the core issues?

Memory safety, race conditions, unhandled integer overflows. Look at all newly-discovered vulnerabilities, they almost all caused by these issues.

> Some of the C pains are hard to solve without breaking the language.

That's why it's necessary to do such breaking change, to stop using C and to switch to better languages having no issues mentioned above.

comment 17h ago · link · parent

Yet another example showing, that handling panic is a bad design decision. It adds so much complexity into the language and degrades performance in the majority of use-cases, since very little projects actually rely on panic being recovered.

It would be better to handle panic as termination of the whole process. Ideally it can be achieved by single instruction like ud2 allowing the OS doing the job.

comment 18h ago · link · parent

Yet another project adding bells and whistles into C without solving its core issues. Now vibe-coded.

comment 18h ago · link · parent

Strictly-speaking just regular break/continue is also some sort of goto. But they are not so harmful compared to actual goto, since they transfer control flow out of a scope (from current loop iteration or from the entire loop) and thus don't allow skipping variable declarations.

comment 1d ago · link · parent

> Adopted this week for draft C++29: break label; continue label;,

Something is terribly-wrong with the standardization committee if such useful feature as labeled loops (proven to work fine in other languages for decades) are still not in the standard, but questionable things like std::regex or contracts are.

comment 2d ago · link · parent

> But it felt wrong to depend on a library that was several times bigger than my entire game just to handle a few seemingly simple tasks.

In my recent project I linked SDL2 statically and disabled all unnecessary components, so that it doesn't add much to the result executable size. In seems to be more practical to do so, rather than ditching it entirely.

comment 4d ago · link · parent

> An accidental negative (signed) value will

If you use mostly unsigned values it's not a huge problem, as long as you don't perform subtractions or operations with possibility of overflow. If obtaining a negative value or getting an overflow may occur, you should perform proper checks before calling an API function. And in case of WinAPI or something similar usually no extra computations before a call are necessary, arguments are already precomputed (like with buffer sizes).

comment 4d ago · link · parent

I don't think it's that necessary to return back to manual memory management (Zig-style) and abandoning proper RAII (Rust-style) to spare some memory. With a little bit effort it's possible to achieve good memory efficiency without sacrificing safety (by manually managing allocators).

Chromium-based applications consume so much memory, not because they don't use manual memory management, but because JS used for application code isn't nearly as efficient in memory usage as any other proper language. Also the browser engine itself is optimized in such a way, that it sacrifices memory usage to gain more speed.

comment 4d ago · link · parent

That's why it's recommended to use size_t for passing sizes of buffers. It's unlikely to get overflow with it. In this particular case input buffer needs to have size larger than half of address space in order to trigger overflow, which isn't possible (64-bit systems usually have only 48 bits of actual address space, 32-bit systems don't allow allocating so large blocks).

comment 5d ago · link · parent

The next step is to support proper encryption (sine in modern days raw HTTP is out of favor).

11.

Unit-testing in the Ü programming language(panzerschrek.github.io ↗)

14 points · by Panzerschrek · 5d ago · 3 comments

comment 5d ago · link · parent

I suppose this function has been written first in assumption, that case conversion doesn't affect length, but later ß -> SS conversion has been added without proper testing.

comment 1w ago · link · parent

Quake II uses old 8-bit approach in its software rasterizer, which isn't capable of applying colored lighting. It's a shame, that no progress was made since original Quake. Half-Life (also derived from Quake) did better job and supports colored lighting in software mode.

In OpenGL mode colored lighting is there. But map designers overused it too much, especially in outdoor locations having yellow sky lighting, which looks somewhat depressive.

comment 1w ago · link · parent

Let's assume I can eliminate NaNs and use bit-patterns reserved for them for storing more numbers. For a 32-bit float it's roughly 8 millions of new values available, but it's only +0.4% increase. For 64-bit double it's even less (roughly +0.05%).

comment 1w ago · link · parent

For any bit width, they have a larger dynamic range, higher accuracy

Isn't it a contradiction? One can't increase range without sacrificing accuracy.

comment 1w ago · link · parent

The problem is not in decaying programming culture, it lies deeper. There are little to no economical incentives for writing reliable code, perform proper system design and technical debt reduction. Costs reduction and delivery speed have greater priority.

comment 1w ago · link · parent

> manual memory management

Ergo memory leaks.

> arena and pool allocators

A poor's man replacement for RAII.

> go style err!=nill style exception handling

Literally the most criticized part of Go.

> first class support for defer statements

Again, defer is used, because there is no RAII.

> consider it

No, thanks. I will continue using Rust or even C++. I don't want wasting time debugging memory leaks and corruptions.

comment 1w ago · link · parent

> But many operations in Rust can panic, from out-of-bounds indexing to calls into user-provided code, and by default a panic unwinds

That's why I think having unwinding in Rust is a mistake. It gives a false sense of safety, but it's very hard to write unwinding-correct code. So, it would be better to handle panics as immediate process termination instead.

comment 1w ago · link · parent

> In safe mode, C3 checks array bounds, null dereferences, shifts, casts, unwraps and so on, and each check that can fail needs code to report the failure with a message, a file, a function and a line

It's basically debug information. Why not putting it into a separate file?

comment 1w ago · link · parent

> These are zip archives with C3 sources, headers, prebuilt binaries per target and a manifest.json

What's the point of distributing prebuilt binaries? It seems to be a point of failure in case of an ABI change.

comment 1w ago · link · parent

> it is considerably safer than C

to what extent is it safer than C? Does it eliminate safety issues common to C like out of bounds memory access, use-after-free, double-free, race conditions? Or maybe some other kind of safety issue present in C isn't possible in Micron?

> unsafe parts are explicit

Does it have unsafe blocks or something similar?

comment 1w ago · link · parent

> There exist companies who scan newly published crates

There is only one logical step left - make such scanning mandatory. Even better would be to perform proper audit with real humans involved. In order to cut down costs of such measures, there should be some limit on how often a package may be updated, let's say, once in a week.

comment 1w ago · link · parent

> global-min-publish-age = "3 days"

It's not a proper solution. A malicious crate can just contain a time-based switching mechanism in order to be undetected some time (let's say a couple of months) in order to become widespread.

comment 1w ago · link · parent

Is it memory-safe? Or just as safe as C?

comment 1w ago · link · parent

On modern CPUs such tricks are irrelevant. They are able to process multiple instructions in the same time, so that the main bottleneck is no longer executing instructions, but accessing memory.

comment 2w ago · link · parent

malloc has terrible interface.

It has no way to specify custom alignment. So, if more than 8 or 16-bytes alignment is needed, custom user-code tricks are necessary (allocate more than necessary, round up).

It has no way to report how many bytes are actually allocated. Sometimes it may be useful, like if I reserve 9 bytes for a string and underlying allocation granularity is 16 bytes, I want to know that I can increase string size up to 16 bytes without calling malloc again.

It's a single entry point allowing no allocation size customizations. So, if I allocate objects of fixed size, I still need to pass a dynamic size parameter to malloc and it needs to perform branching in case if it does have some optimizations for particular sizes.

free has no size parameter, which is a mistake. This forces the allocator to maintain size values somewhere inside, which is often an unnecessary overhead, since user code already knows size (like for fixed-size allocations or containers storing explicit capacity).

With interface fixes described above a malloc implementation can be much more performant and (sometimes) even easier to use.

comment 2w ago · link · parent

Modern C++ is nice to use, except cases where stupid mistakes caused by its heritage can be made (like returning std::string_view to a temporary string).

comment 2w ago · link · parent

A C++ compiler in three weeks? Is it vibe-coded?

comment 2w ago · link · parent

Pointer arithmetic on modern computers is basically free. But cache-misses caused by accessing a union tag located far away are not free.
12345
17