Ask HN: Getting back to C++ and looking for ideas

37 points by throwawaybbq1 ↗ HN
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 ] thread
Instead of searching for a project that you would do only to use C++, why not decide on something you would want to build anyway and then build it in C++?
https://github.com/SerenityOS/serenity 32bit OS being built in modern C++ by a friendly creator and community who regularly streams on Youtube
Andreas (the creator of SerenityOS) and the community have been an absolute joy this past year.

Andreas 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.

Ditto, love his videos even though I don't code C++ , Understanding the OS internals, security mechanisms and design decisions are worth it for me.
In my opinion, Orthodox C++ is the best and sanest C++ style nowadays, and it is not too difficult to learn.

https://gist.github.com/bkaradzic/2e39896bc7d8c34e042b

I would advise to read the code and tinker with Dear Imgui.

https://github.com/ocornut/imgui

"Orthodox C++" is an abomination: everything worst about C++, with none of its myriad joys.

You might like it if you already use C and hate learning.

Could you elaborate a bit about the myriad joys?
The language is wonderfully expressive, which is experienced most strongly when making or using powerful libraries. Because C++ can capture semantics so well, libraries can be easy and safe to use, yet much faster than you could afford to code yourself. So, you can use libraries with no worry that you may be costing yourself performance.

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.

I did this recently too. You might want to review the language changes from C++11 and C++17.

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).

Are there any little devices that you'd like to make or tinker with? C/C++ is still big in the embedded space and that's the first use case that comes to mind for me.

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.

I play with microcontrollers for fun, and enjoyed mucking with Freertos a few years back. But that was all C code. It did scratch the event driven programming itch. There were a couple of good Udemy courses on ARM and Freertos (also freely available content on Youtube) if you are interested in that. I still enjoy that but looking to do something purely software now.
If you've been away for 15 years, then you have a lot of great changes to absorb. I would learn C++20 and not look back.

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++.

Distributed computations with new stacks such as gRPC+Protobuff or Flatbuffers
I was in a similar position to you a few years ago.

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.

Thx to you and others for the suggestions (I upvoted everyone and appreciate it). Good point that CUDA is its own world and won't really give me that pure software feel. Part of it might be me getting old and missing the days of my youth where I could code non-stop for a week. Just want to get back into the flow.

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.

Rather go with C, or as was pointed out in this thread, Orthodox C++.

Less time being bogged down in the quagmire of C++ "features".

CUDA is a whole new environment and programming paradigm to learn almost from scratch. You can start from the examples and gradually move on to parallel applications from your area of expertise.
You could build some toy projects and compile to .wasm
Personally, when trying to get into a new language, I like to use https://www.projecteuler.net. It's a nifty way to try to use features of a new language. I tried it with go an learned quite a bit about channels and goroutines to optimize solving problems.

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...

If you've been using Python for DL, you can try using PyTorch's C++ bindings instead. They're remarkably similar to Python, and depending on what you're doing you may pick up a fair bit of speed. For example if you're doing some kind of RL-like simulation in Python, doing that in C++ will be much faster.
I have been working on a database engine in C++ by following along with the CMU lectures on youtube recently. It is quite fun and I am getting to learn a lot although I am just tinkering with the storage layer right now.