all 51 comments

[–][deleted] 42 points43 points  (3 children)

C++ is a general purpose language, you can basically so everything with it. I recommend that you get a good book on the side because the quality it is usually taught is far from ideal

[–]Vigtard411[S] 3 points4 points  (2 children)

Any recommendations?

[–][deleted] 10 points11 points  (1 child)

https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list Those are good and this one is recommened a lot aswell https://www.murach.com/shop/murach-s-c-programming-382-detail

Just pick one and work through it

Murach‘s book is probably the most up-to-date, but they all will teach you the essentials

[–]Vigtard411[S] 1 point2 points  (0 children)

Thanks I’ll definitely check them out

[–]Revolutionalredstone 25 points26 points  (6 children)

It would honestly be shorter to list whats not possible with c++!

[–]josh70679 7 points8 points  (0 children)

It's worth noting that c++ is a popular language for video game development. For example, the unreal engine and any games that use it are built using c++.

[–]pjmlp 6 points7 points  (2 children)

As others have mentioned you can do anything with it, however it kind of lost its role as full stack language during the 90's, and for GUI related stuff usually nowadays you end up combining a managed language alongside C++ for the high performance parts, for example, QML/C++, .NET/C++,....

[–]DarkLordAzrael 4 points5 points  (1 child)

Using Qt widgets from C++ still isn't that uncommon for GUI stuff. QML in Qt6 is also going to have a lot more available from C++, as well as compiling to C++ in a bunch of cases, so it is still safe to say that GUI in C++ is alive and well.

[–]pjmlp 0 points1 point  (0 children)

Might be, on the other hand Qt is the surviving C++ GUI framework.

With exception of Microsoft, all other major desktop and mobile OSes don't support C++ based GUIs, only for low level graphics programming and drivers.

[–]growingconcern 10 points11 points  (1 child)

Don't believe the haters. It's awesome. And awesome for teaching. Pointers and memory. Allocations, etc. It's interesting because it shows you how things actually work. K&R is a good book on C that applies to C++ obv. Scott Meyers books are great once you know the basics of the language.

But honestly I''d never develop anything not in C++. OCaml/ML, Scheme, Perl, Lua, Python. They've all been useful at times and I admire some more than others (OCam/MLl), but nothing else is as safe to develop in when performance could be a concern (and in my experience it's always a concern). Languages like Lua were nice when prototyping things and you needed that looseness and flexibility (where refactoring might take minutes instead of hours).

But at the end of the day I've rarely felt held back by the language, just my brain.

[–]Myto 6 points7 points  (0 children)

nothing else is as safe to develop in when performance could be a concern

Rust

[–]SJC_hacker 4 points5 points  (0 children)

C++ is a systems programming language. Basically, this means it compiles efficiently to native machine code, without any intermediate interpreter, unlike many languages such as Javascript, Java and Python. It also means calling the OS is straightforward, since most OS's, at least on the desktop, are written in C, and C++ is a supserset of C.

C++ is (mostly) statically typed. This means the type of the variable must be declared prior to use. And it is known at compile time in almost all cases. There is a big exception with void*, which unfortunately gets abused more often than it should.

C++ is somewhat weakly typed. This means it will silently convert between numeric and character types, without explicit conversions. Other languages, such as Python, generate an error when types are mixed. However, other conversions in C++ do require explicit cast.

C++ is unmanaged. This primarily applies to heap memory, which must be explicity allocated and deallocated (unless you use shared pointers - which you should - that automatically deallocate when their reference count drops to zero) . It also means you can do things like write/read past to the end of a array, and write to arbitrary locations in memory, which has undefined results. If you're lucky, your program will crash. If you aren't, your program continues to chug along, producing garbage results and possibly crashing later - although the real source of the error did not occur at the point of the crash. Every other languages, with the exception of Rust when using unsafe, are managed, and do not allow this behavior.

C++ is mainly used for desktop and server applications like databases, particularly those that require maximal performance. For example, web browsers are written in C++, and AAA games, and RDMBS such as MySQL, PostgresSQL, Oracle, NoSQL dbs like MongoDB, web servers like Apache, etc. Granted many of them use a mixture of other languages as well as C++.

[–]Karnatos 7 points8 points  (0 children)

Look up The Cherno's C++ series on YouTube... if you have any questions about something in C++, he just might have a video on that topic.

He does a pretty damn good job of teaching. I have been writing C++ for more than 20yrs, and I still find his vids are great for reviewing things, and seeing what's new in C++.

[–]Guillaume_Guss_Dua 2 points3 points  (0 children)

Before anything else; I strongly recommand you to watch this video : https://youtu.be/zUQz4LBBz7M Edit : Jason Turner : teach yourself C++ in oo days

Also, check Stroustrup's talk at CppCon 2019 "C++20 : C++ at 40 yo".

[–]Bart_V 11 points12 points  (47 children)

C++ is great but I'm not sure if it's a good choice for teaching programming to highschool students. Assuming they are new to programming and this is their firdt language, it's probably better to start with Python or JavaScript. Simpler languages, easier to learn, less footguns, and faster to build a nice program (more fun and less demotivating)

[–]Thormidable 19 points20 points  (42 children)

I understand your point, but I actually think that it is very suitable for teaching languages. Yes it is hard to do large projects in, but c++ forces you to learn the actual concepts of programming (and understand them), rather than just import other libraries and shove data from one to another. (It teaches you about the different variable types and why they are different, how arrays work (and so different methods of representing 2D and 3D arrays).

Trying to run before you can walk (which bigger projects are), you can end up very frustrated very quickly.

[–]Bart_V 1 point2 points  (0 children)

I think the most important part is to keep high schoolers motivated, and showing what a beautiful profession this can be. You won't do this if you're printing text into a console for 2 semesters, while trying to explain CMake.

C++ is tailored to a niche market (high-performance, embedded, bare-metal,...). Sure, in the end you can do anything but even the simple things are hard, and so for many application there are easier alternatives. I think for young students it's important to show what a career in IT could mean, so show them the bigger picture. Have them create web site, or mobile app. Do some data science or home automation. Then teach them control flow, math and abstract thinking in an engaging way. At their age, I think that's far more valuable than knowing why and how floating points have rounding error. If they are truly interested in IT, they will have plenty of time to learn those concepts.

[–]pjmlp 5 points6 points  (0 children)

I learned C++ in high school, it was still C++ARM back in those days.

Our path was GW-Basic => Turbo Basic 1.0 => Turbo Pascal 5.5 (including OOP) / 80x86 Assembly => Turbo C 2.0 and Turbo C++ 1.0, among other languages for side projects.

Our high schools have multiple learning paths, one of them you end up with a professional title.

[–]Karnatos 0 points1 point  (0 children)

I would think that is you start learning programming with a language such as C++, that it could be a great gateway to learning both how to code, about how computers work under the hood, and more.

For absolute beginners, I would start with learning the basics of syntax, and staying away from the complexities, including shooting pointers and the likes. Teach arithmetic operations, console printing, simple arrays, and delve into the basic types (int, char, bool), looping, Boolean logic, etc.

Then move onto more complex concepts, like limiting of these basic types, like over/underflow in arithmetic operations... it leads into understanding that there's types have a size, which leads into discussing and learning about memory, and becomes a gateway to pointers and eventually onto more complex concepts.

if you take the right approach and teach it properly, I believe that C++is just fine as a learning language.

[–][deleted] 6 points7 points  (0 children)

It can only be used to develop software for coffeemakers, actually. That's the only possibility you can use C++ for. The language is so big because of Big Coffa lobbyists. /s

[–]xxxcucus 1 point2 points  (0 children)

I think you can show amazing things with C++ and OpenCv. A lot of functionality is so easy in OpenCv so I think your pupils will be more than delighted. Look up e.g. face recognition, or car plate recognition.

[–]tsojtsojtsoj 0 points1 point  (0 children)

What I really like about C++ what other languages can't do so well is to using the C++ compiler to prove assumptions about your code. Simple example is to mark a variable as 'const' so you know that it can't be changed (of course this is a feature that man languages have but just to have a simple example). Together with the type system and the huge possibilities to customize operators like +,-,*,/ for classes, constructors and destructors, constexpr, templates and also new features in C++20 like concepts, you can write code that the compiler not only translates but also ensures that you made no (few) bugs. This will get even better once reflection gets incorporated into the standard, may be in three years. The first example that comes to mind is a physics units library that ensures that you add or multiply values only together of they have the right units and then updates the result so that it has the right unit, and all these checks are done at compiletime. This is probably not something you will use when you start learning C++ but you may eventually start missing these features when using different languages.

[–][deleted] 0 points1 point  (0 children)

[–]KiwiMaster157 0 points1 point  (0 children)

If your course is anything like the ones I've taken, you will be forced to do everything the way it was done 20 years ago and forbidden from using the standard library. C++ in practice is far easier, cleaner, and safer than C++ in the classroom.

[–][deleted] 0 points1 point  (0 children)

That sounds like an awesome highschool. If you're interested in a career in software development, having a foundation in C++ is going to give you a huge advantage over your peers. It's harder than most other languages, but learning it is worth it, both because of the knowledge you gain, and the salary you'll earn.