Ask HN: Getting back to C++ and looking for ideas
Hello .. I used to code C/C++ about 15 years ago, and mainly used it for MFC/Windows programming. I spend years doing Java and enjoyed using it for Android development. I since moved to Python for most of my work (mainly working on deep learning). I'd like to get back to C++ again .. I mostly remember the language but need to dust off details like STL, generics, libraries, etc. Here is my problem .. I can't figure out what sort of tiny programs are a strong fit for C++ today. I don't want to build C++ or work with some large existing code base. Best place I can think of where C++ would be a good fit today is Cuda dev. Is there anything else that I am missing? I'm desperately looking for something to get excited about wrt C++ .. would appreciate advice!
29 comments
[ 3.1 ms ] story [ 73.4 ms ] threadAndreas recently setup a Discord server for the project and it is wonderful. It is full of people helping each other with OS development, enhancing the platform and building applications.
His regular streams cover many different areas of development and are always wholesome. Truly one of the best things I have found online in recent years.
https://gist.github.com/bkaradzic/2e39896bc7d8c34e042b
I would advise to read the code and tinker with Dear Imgui.
https://github.com/ocornut/imgui
You might like it if you already use C and hate learning.
Because the libraries can be so nice, you can code at a level where bugs mostly are revealed at compile time: if your code compiles, it usually runs right the first time; or if not, it is easy to see why. Most potential bugs are in the library code, but being a library used in many programs, it commanded enough attention to be made and kept correct and fast.
The above is why Rust will not displace C++: there are thousands of times as many competent C++ coders as Rust coders of any degree, and the problems Rust prevents don't happen in competent C++ coders' programs, but the extra work to make Rust code possible is not needed. In a very real sense, C++ libraries are doing the job reserved to Rust's compiler, which is a sensible choice because you needed libraries anyway.
You could try writing a raytracer, or physics sim, or small tools that would have been difficult/annoying previously (like dealing with JSON). You could revisit writing win32 apps. The WebView2 lib (which is Edge) is self contained-ish and interesting to learn with (lots of async).
I definitely empathize with your post since I haven't done any C++ in 10 years and I'd like to get back into it. The last job I had using it wasn't on C++11 yet and it seems like there's been a whirlwind of progress since then.
As far as projects... I probably wouldn't pick C++ for a tiny program.
But if that's what you want to do, maybe check out some of the new coroutine functionality. Some toy async web stuff might be an interesting challenge. There are plenty of services with public REST APIs. Make a toy client in C++.
My recommendation is to first read Scott Meyer's book "Effective Modern C++". This will give you a tour of the language features in modern C++ without wasting your time teaching you the basics, which are going to come back to you rather quickly anyway. It's a short book and it's not going to cover everything you need to know in modern C++, but you can read it quickly and after you've read it and done a little C++ programming you'll know which things you want to dive into further.
As for what kind of programs to write to get excited about C++, I personally feel like systems programming is the area where C++ really shines, and I would encourage you to find some kind of project in this area that excites you. For example, write a simple high-performance key-value database using mmap. Write a httpd using boost::asio or even just using epoll directly. Something like this. There are a million projects to choose from, just pick something that you find interesting.
With regard to CUDA, while it is true that it's an area where people use C++ today it's also fairly different from writing regular C++ programs since you need to use different tooling and the programming paradigm is a little different. If you're really passionate about CUDA I don't see any reason why you couldn't start there, but I think it would be easier to do regular userspace C++ programming first and then transition into CUDA later if you are interested in it.
I found one of my old File Systems text books the other day .. maybe I'll brush up on that with C++. Defn excited by async io in general, and totally unclear on how that works with modern C++. I guess boost:asio is a good starting point. Appreciate the pointer! In the old days, I'd spawn a bunch of threads but that is definitely old school (gotta checkout coroutines in C++!). I also fell in love with Systems programming in my youth writing socket software. So that is also a nice suggestion.
https://github.com/lewissbaker/cppcoro
This, or something like it, will eventually be standardized I think.
Less time being bogged down in the quagmire of C++ "features".
The place I see small C++ making gains is in IOT. With https://platformio.org it makes it a breeze to get a compiler to target the platform you want.
ESP32 modules have wifi/bluetooth and are $19 for 3 on Amazon and programmable over usb.
https://www.amazon.com/D-FLIFE-ESP-WROOM-32-Bluetooth-Develo...
It starts from the basics and goes into a lot of detail.
For a taste of what is possible with openFramworks, take a peek at this youtube series by Lewis Lepton: https://www.youtube.com/watch?v=dwt2NAd1ZYY&list=PL4neAtv21W...