Getting Restarted With Programming C++

Wondering if anyone can help me getting restarted programming C++. I did it before back in high school, but I can’t remember how to do it. I think we had some kind of Microsoft software on Windows, but that’s about it. I can’t remember how to create projects, etc…

You would likely have used Visual Studio, you can get the Community Edition these days for free.

However there are other options outside of Visual Studio if you would prefer to use something non propriatary such as CodeBlocks which has a decent IDE and uses GCC as it’s compiler.

3 Likes

Visual Studio Code isn’t really proprietary nor is it really FOSS. It’s weird. You can obtain it’s MIT licensed version

Look up VSCodium

2 Likes

Just to be clear to the OP though, Visual Studio Code is an entirely different product to Visual Studio, but is likely the better option to start with.

3 Likes

I second that. There’s a lot of great plugins. It’s not maximum autismo like NeoVIM even though I love VIM it’s not for everyone.

I think the best C/C++ IDE out there is cLion but you have to pay for that. Visual Studio code feels and behaves like a paid IDE but is free. I really can’t complain too much about it and definitely recommend it for the reentry types. It’s used in the field alot. Just about as much as Eclipse (and it’s clones)

1 Like

@Virtual_Law

While it’s dry the ISO C/Cpp 2011 standards are good to have a PDF of. Be the nerd. Read the appendixes. They have a lot of good nuggets in there.

If you want a PDF copy I think I have one laying around.

There’s a ton of resources out there and while you can spend a lot of time doing things with them… the easiest way to learn is to take other projects and begin to port it to C. You know what to expect. You know the general layout of your program and it’s processes. Translate it to C. You’ll learn a lot

Want something more hands on? Embedded development is a big portion of the C/C++ coding community so maybe grab an ST or a pSoc 61 or microchip and start coding the arm chip to control things or blink LEDs. It’s a good basic introduction to C and C++ and you get to play with what you create

Shawn Hymel

Search his name on YT. Lots of great videos on C, C++, freeRTOS, coding for various platforms, IDEs, projects etc

You’ll find that while C++ entire creation was to combine all the good and power and simplicity of a low level language as C and add classes and a little object orientation. Otherwise you basically still just 0.5 steps above the assembler anyways :joy::+1:. So while you want to learn C++ you might as well learn C alongside it. Gonna be frank as a person who knows both well enough and is working on adding go and rust to the skillet… if I could do over my learning… I would learn C then add the object oriented and class oriented stuff in. It’s way easier to understand in that order

P.S allocate … Deallocate… Allocate… Deallocate :wink::wink:

Nah, just be sure to add tons of ram to the system and a daily reboot :rofl:

That said, yes, another option is to make use of std::shared_ptr and std::unique_ptr etc… worth reading up on before you start a large project in C++ and discover them later on because you didn’t keep up with the language (like me, lol)

But I entirely agree, C is a better starting point and you will learn a lot more about the hardware, OS and performant code that C++ may confuse due to it’s layers of abstraction. (Not to say C++ is not performant, just easy to make a mess of things with when learning early on)

3 Likes

Don’t worry. Just wait till he gets frustrated with it’s syntax eccentricities (relative to object oriented programming) … a coworker and I spend almost all our time in C and ASM and we saw some OO code and we were both like… Mannnn… I miss OO programming. It was so pretty and easy to read :joy:

The famous “K&R” book The C Programming Language is written by the creators of C and its priorities reflect the simple practicality of programming. You might find it a useful source of inspiration and guidance; I also like the pragmatic programmer

2 Likes

I’m going to take a different stance to this and ask:
What kind of projects are you interested in?

If you’re a visual learner, I recommend people to start with graphics programming with ShaderToy. You write shader programs in GLSL instead of C++, but you learn many of the same paradigms.

On the other hand, if you’re more of a kinesthetic learner, I would suggest getting started with an Arduino, Teensy, or even an Espressif developement board.
They’re pretty inexpensive these days, and the Arduino IDE has oodles of tutorials and documentation.

If you want to go into the deep end, you could start out with VSCode or QtCreator and follow one of those basic C++ game tutorials too.

Here’s one of the channels I followed when I was getting started:

His videos are pretty old at this point, but you’ll learn the basics in a much more intuitive way IMO.

C++ is one of those “Franken-languages” that keeps getting more blobs attached to it over time. So I would suggest to take the path of least resistance and start with more classic C-like tutorials and adopting newer features at your convenience.

I hope this helps. I don’t believe there’s a “one size fits all” approach to learning systems programming like this.

2 Likes

If you’re still considering this I would also recommend the Community edition of Visual Studio 2022 on Windows. It’s the best IDE out there, and the Community edition is free.

The lighter, electron (Javascript engine)-based VS Code is great because it runs everywhere (have it on Linux, Windows and macOS) but it’s nowhere near as slick or helpful as the full-fat Visual Studio, which the Community edition is, especially for writing C++ programs (that aren’t aimed at Azure or other enterprise computing).

The only downside to Visual Studio in my opinion is that you’ll need a lot of disk space, and it’s easy to get sucked into installing everything from the get-go: C++, C#, Python, yada yada. I’d just stick with the bare minimum C++ installation: you can add the rest later with the handy-dandy installation app that comes with.

Good luck getting back in C++! (It’s quite a bit better than it used to be IMHO, but also it’s still a crazy mish-mash of techniques and features. But I love it - it’s the Porsche 911 of computer languages: takes a lifetime to learn how to drive it properly but is very rewarding once you’ve mastered it, and survived the crashes…)

As an alternative to Visual Studio, there’s also C++Builder, or, there’s Delphi too which you could consider.

Delphi is significantly easier to learn than C++, while still offering the benefits of being native compiled and have tight integration with Windows, plus it also supports multi platform development as well.
Both exists in a free Community Edition. :slight_smile:

1 Like

If you’re a visual learner, I recommend people to start with graphics programming with ShaderToy.

On the other hand, if you’re more of a kinesthetic learner, I would suggest getting started with an Arduino, Teensy, or even an Espressif developement board.

While I get what you are saying here, I have to disagree. Arduino is the worst for this, but it’s the same issue with ShaderToy, the lack of debugging capabillity. Arduino teach people to use serial and print tons of debug messages, where ShaderToy you get a compiler warning, but due to the nature of shaders, it’s not possible to use a debugger on it in any meaningful way.

This is one of the main reasons I hate the Arduino ecosystem, the fact that they call their syntax highlighting text editor an “IDE”, even though it’s missing one of the most critical features for development, a debugger that allows you to set breakpoints and inspect memory. To make matters worse they confuse things by calling the projects “Sketches”, even though it’s literally just C and they are compiling with gcc.

If you insist on visual learning and want to use a micro I would suggest you get a ST-Link clone (<$5 on eBay) and obtain any one of the STM32F103 devices or clones (even the clones are fine for 99% of things). Something like the BluePill is perfect for learning on as it even has a header for SWD (Serial Wire Debug) which you connect the ST-Link to. Then just use the free and open opeoncd combined with gdb to give you full remote debugging capabilllity.

As for an IDE, any text editor will do, it’s C after all, and compile with gcc and good old Makefiles. This will give you all the skills needed to write and build applications not just for the MCU, but for Windows/Linux, etc as the development workflow is identical.

1 Like

All valid points here. I share your distaste for the Arduino IDE too, but consider it a nessasary evil in order to maintain library compatibility.

As far as debugging goes, I’ve always used printf macros with normal applications, or used framebuffer output for debugging shaders.

Personally, I’ve found GCC’s memory/address sanitize functionality to be much more helpful than using GDB directly.

FWIW, I also found a project to get GDB remote debugging working on the Teensy 4:

I’m not sure how well this works, but at least it’s an option if you still want to use this hardware.

1 Like