4 ms·
My experience with Zig is that it's also a plausible replacement for C++
by superlopuh 2y ago
My experience with Zig is that it's also a plausible replacement for C++
- fuzztester 2y agoexplanation needed, bro. nerdy langnoob or noobie langnerd here. not sure which is which, cuz my parsing skills are nearly zilch. ;)
- infamouscow 2y agoC programmers have long suffered the cumbersome ritual of struct manipulation—resorting to C++ merely to dress up structs as classes. Zig shatters that with comptime and the 'type' type.
- chongli 2y agoZig’s comptime feature gives a lot of the power of C++ templates. This makes it easier to implement a lot of libraries which are just a pain to do in plain C. Even seemingly simple things like a generic vector are annoying to do in C, unless you abandon type safety and just start passing pointers to void. I believe Zig even has some libraries for doing more exotic things easily, such as converting between an array of structs and a struct of arrays (and back).
- fuzztester 2y ago>Zig’s comptime feature gives a lot of the power of C++ templates. This makes it easier to implement a lot of libraries which are just a pain to do in plain C. Even seemingly simple things like a generic vector are annoying to do in C, unless you abandon type safety and just start passing pointers to void. I get it, thanks. in C you have to cast everything to (void *) to do things like a generic vector. >I believe Zig even has some libraries for doing more exotic things easily, such as converting between an array of structs and a struct of arrays (and back). yes, iirc, there was a zig thread about this on hn recently.
- pjmlp 2y agoDepends on which C++ version you're talking about.
- fuzztester 2y ago[flagged]
- dang 2y agoPossibly your GP comment came across as a snarky attack because of the first sentence. It's clear that you didn't mean it that way, but there isn't enough information in "explanation needed, bro" to disambiguate your intent (https://hn.algolia.com/?dateRange=all&page=0&prefix=true&query=burden%20disambiguate%20by%3Adang&sort=byDate&type=comment https://hn.algolia.com/?dateRange=all&page=0&prefix=true&que...).
- fuzztester 2y agosaw this just now. will reply in a day or two after reviewing my own comments, yours, and your link.