News for hackers. Stuff that matters.
Re:I still like C and strongly dislike C++ by gattis on Thursday May 27, 2021 @01:04AM (#27299585)
I used to feel the same. For a long time I got away with using C and python for everything. They paired well and I always came away feeling that my code was expressed elegantly enough for me. C was for stuff that had to be fast, python for things that were more functional or meta. Then I started a project that needed to be faster than python but also required some heavy-ish meta-programming. I wrangled for way too long with the C preprocessor, and while way more powerful than I had imagined, still fell well short of being able to do what I needed without it looking and feeling like a dog that had to be put down. I think I would have needed a code-generating script to do it and to me that sounds disgusting. But C++ templates did exactly what I needed. They look awful and I still don't even understand my own code when I try to go back and read it. But it made me understand and appreciate that C++ does have a place, and for certain projects it might actually be the best choice. I'm sure some fan boys of the newer C++ descendents (rust/golang/zig/et al) will disagree.
Re:I still like C and strongly dislike C++ by Glavnokoman on Thursday May 27, 2021 @03:25AM (#27300331)
Type parametrization is actually done better in Zig. I wish it departed from "no implicit actions" dogma and let RAII in. It would be almost perfect...
Re:I still like C and strongly dislike C++ by erdeszt on Thursday May 27, 2021 @04:15AM (#27300550)
I kinda like that `defer` is very visible. Although I haven't worked on large Zig codebases so I don't know how that scales.
Re:I still like C and strongly dislike C++ by Glavnokoman on Wednesday June 02, 2021 @07:51AM (#27367577)
`defer` does not allow passing ownership so it limits your designs quite significantly.
Re:I still like C and strongly dislike C++ by rramadass on Thursday May 27, 2021 @11:54PM (#27311568)
This is the usp of C++, it is a set of languages which can be combined as needed depending upon problem requirements (aka Multi-Paradigm). I personally always start with a subset and only add features as needed. Two old books which i found useful in thinking about how to use C++ are;

Scientific and Engineering C++ by Barton and Nackman.

Multi-paradigm design for C++ by James Coplien.

I have not as yet found any equivalents for "Modern C++".

Re:I still like C and strongly dislike C++ by LeCow on Thursday May 27, 2021 @03:26AM (#27300340)
I prefer Rust simply because it's safer and C++ has become monolithic. Also gotta love an excellent package manager.
Re:I still like C and strongly dislike C++ by vips7L on Thursday May 27, 2021 @12:11PM (#27304711)
The problem with Rust is that it still can't hit all of the targets that C++ can. I have to support IBM AIX and HP-UX and the only things that I know of that run there are C/C++ and Java.