C, C++, and Rust in 2022
I'm sitting at the kitchen table on the last night of the year, with 12 minutes to go before 2023. Everyone is in bed and asleep and the house is quiet. I've just finished doing some C++ examples out of a book about modern C++20 features and I'm reflecting on 2022 and the future of native code.
2022 was the year that I really dug into Rust. I'd done a little bit of Rust in 2021 (even a couple of things for work), but in 2022 I made a concerted effort. I bought books and read them (mostly). I read the Rust Book online and in dead tree copy. I coded a few demo projects. I finished Rustlings. And by the end of the year, I'm feeling a lot more comfortable with the language. Maybe not productive, exactly, but definitely more comfortable.
I also did some projects in C this year, including some minor contributions to open source. I've always had an appreciation for the C programming language. I like that it's small and "simple". I like that it requires great care to use well. I appreciate that it is so incredibly portable, and I also appreciate that it's pretty darn tough to write error-free code in C. That being said, I'm impressed by the number of awesome header-only C libraries. It feels like the community of programmers is injecting new life into the language even as the industry is trying to find a way to replace C as the lingua franca.
I've felt conflicted about C++. It was the first language I picked up when I got back into programming in the early 2000's, and I've tracked it over the last couple of decades. This year I did a tour of C++ build systems, got comfortable with CMake and vcpkg, and learned how to use Google Test. I watched the announcement of Carbon, followed the progress of Zig and D and other C++ competitor languages with interest. I observed the mounting pressure to find safe alternatives. I didn't write much modern C++ until the last few weeks of the year.
What I found was that, despite not knowing much about the new language features, it has been really easy for me to get productive in modern C++. Compared to Rust, it has been a breeze. I haven't had to use a single pointer yet, but with unique_ptr
and shared_ptr
it seems a lot less daunting than in years past. The new std::filesystem
library is very useful, and between the STL and Boost, I have a ton of power at my fingertips. I like the tradeoffs. I like the proximity to C. I like the ergonomics that the new standard features offer. As much as Rust's borrow checker is a remarkable tool, I have to admit that C++ feels immediately comfortable to me in a way that Rust hasn't (yet).
Looking ahead into 2023, I wonder if I may end up investing more time into C++ than I would have predicted a year ago?