News for hackers. Stuff that matters.
Re:Build Your Own Redis with C/C++ by hewlett on Saturday March 18, 2023 @05:33PM (#35213313)
You can still use raw pointers and sockets in C++, which the code examples provided in the book do
Re:Build Your Own Redis with C/C++ by JTyQZSnP3cQGa8B on Saturday March 18, 2023 @05:54PM (#35213473)
I agree but no one calls this C++ anymore especially since C++14/17, and I fail to see why you would use a C++ compiler for such a code.
Re:Build Your Own Redis with C/C++ by gpderetta on Saturday March 18, 2023 @05:57PM (#35213492)
Well, if you are implementing something like ASIO, and of course c++ is a good language for that, you'll be dealing with sockets directly.
Re:Build Your Own Redis with C/C++ by _gabe_ on Saturday March 18, 2023 @07:15PM (#35214193)
> I agree but no one calls this C++ anymore especially since C++14/17

I do. Who's to say if you use C++, thou shalt always use: smart pointers, move semantics, OOP, templates, and more. Also, you're discounting a very large and very real industry of people writing code for embedded hardware that doesn't necessarily have the luxurious memory resources modern devices have.

Why could I ever possibly want to use C++ if I don't want to use smart pointers and OOP and all that other stuff? Well, generic type safety is very nice. Templates don't exist in C. Constexpr and references are also quite nice. They allow me to annotate my code to make my intentions clearer. Operator overloading is also insanely helpful at times. Matrix/vector math is so much nicer to write/read using mathematical operators instead of function calls everywhere. This also isn't possible in C.

Anyways, don't go making claims that if somebody doesn't use a language exactly the same way you do, then they're using it wrong. Especially when it's a language as massively overengineered as C++. There are plenty of reasons to prefer a subset of C++ to C, and plenty of valid reasons to prefer to use C instead of dealing with the complexities of C++.

Re:Build Your Own Redis with C/C++ by batty_alex on Saturday March 18, 2023 @11:30PM (#35215746)
The article doesn’t use any C++ features, though. It’s straight C code. Pretty sure that’s what they meant