Hacker News new | ask | show | jobs
by Panzerschrek 12 days ago
Yet another attempt to reinvent a better C. Curious, but unpractical. If one need a better C, C++ should be used instead.
2 comments

C++ is like PHP: it used to be a terrible language, and you can still reach for everything terrible if you wish. But during last maybe 10 years, C++ made a lot of effort to become a language with fewer footguns and more safe, high-level tools.

Still I won't start a new project in C++. If I wanted high-level features and zero-cost abstractions, I'd take Rust. If I wanted working really close to hardware, do bit-twiddling and knowing where every byte is allocated, I'd take Zig. If I wanted to write a small piece of code intended to run absolutely everywhere, including old and esoteric architectures, I would still have to go with C (plain, old).

> If I wanted working really close to hardware, do bit-twiddling and knowing where every byte is allocated, I'd take Zig

Why not C++? It allows as many low-level operations as one wishes, but don't forces you to manage memory manually where it isn't necessary.

> If I wanted to write a small piece of code intended to run absolutely everywhere

GCC and Clang have support of C++ since many years. Is there any modern platform for which no GCC or Clang backend exist?

Why not C++: build system(s), stdlib, modularity (though C++20 has modules, who uses them?), presence of UD. Better languages don't carry the unfortunate baggage of 1970s which C++ needs to be compatible with.
> Yet another attempt to reinvent a better C. Curious, but unpractical. If one need a better C, C++ should be used instead.

Those two languages are on the opposite ends of any complexity scale. Someone looking for a better C has a ton of options before getting to "lets use C++ and ask our devs to practice discipline".