Erik Engheim
1 min readJun 16, 2021

--

C++ is a multi-paradigm language, and modern C++ is moving away from OOP style programming. Generic programming has been a much stronger focus over the last decade or so.

Lots of people use C++ as a "better" C. That has been a habit in the industry for a long time. Many of us will of course reject this notion although I was admittedly among the "believers" for many years earlin my career.

C++ is not a particularly good object-oriented language. If you Object-Oriented programming is what you truely care about then Objective-C is a far better language.

C++ however has stronger support for generic programming.

About memory allocation. What you describe is just a custom allocator. People have been doing that for ages in languages like C and C++. The difference in Zig is that it gives you a bunch of language features which makes dealing with allocators a lot easier, such as defer and errdefer.

In Zig all memory allocation is done with allocators, which means you can pass our custom allocator to the standard library functions. The custom allocator you are describing it not something you could pass to a C++ standard library.

That is important when doing e.g. embedded programming and you have a very specific chunk of memory you want to allocate memory from.

--

--

Erik Engheim
Erik Engheim

Written by Erik Engheim

Geek dad, living in Oslo, Norway with passion for UX, Julia programming, science, teaching, reading and writing.

No responses yet