Is it really worth learning C++ When C ....

Hi everyone.. I studied C++ a little a college (Didn't get to complete my exam 20+ years ago though: i was young and thought i knew it all - so i was also dumb lol)

I have recently come back to it and see i should never have quit all those years back then, so i have a lot more to learn..

I have noticed some of the C++ features have been removed; also a need to type things like:
using namespace std::experimental::filesystem::v1;
namespace fs = std::experimental::filesystem;

As my memory serves/served me right, i thought C++ was supposed to be an improvement of C?? I have much reserve now if not more than when i started out with 'Hello World'.

Am i just better off learning 'C', or is this language being Nulled out?
C++ 20 years ago was right when C++ was being standardized (1998, but revised with fixes in 2003), so some of things you learned then may now no longer apply or be considered bad practice. The most major change since the original standardization was C++11, which added an abundance of features. Since then, C++14 and C++17 have happened, with experimental features for C++20 on the way.

I don't know of much that has actually been removed. std::auto_ptr is deprecated has been superseded by smart pointers like std::unique_ptr or std::shared_ptr. Features like std::random_shuffle are also now deprecated (use std::shuffle). But they aren't removed.

The filesystem library in C++ became standardized in C++17, though may still only be accessible in the "experimental" namespace on some compilers, you are correct. There is no filesystem library, or smart pointers, or improved random library, (among many other features) in C, so I'm not sure why you even brought up the std::filesystem namespace.

i thought C++ was supposed to be an improvement of C

C++ is a different language than C. They are two separate languages, although they may have various overlapping use cases. I'm sure Bjarne Stroustrup wanted C++ to be completely better than C, but giving an absolute answer like "C++ is better than C" is just an opinion, that people still disagree on to this day.

In practice, C tends to be used in applications closer to the hardware, embedded environments, and is used when machines need to talk to each other. That doesn't mean you can't use C++, but there are various challenges.

Learn what you want to learn. C learning material isn't going away any time soon, but neither is C++. Any decent programmer should have a basic understanding of how to accomplish tasks in both C and C++, anyway.

In my opinion, C++ is much more powerful than C, and can be much safer/faster to develop in through improvements on type safety, templates, classes, and a great standard library. C++ offers features for abstraction without the usual runtime cost of abstraction -- this puts a lot of the responsibility on the compiler to optimize C++ code, which modern compilers are very good at doing.
Last edited on
C is still used. C++ has changed a lot, I am also having to relearn it after a long break. In some ways its much, much better. In some ways it is worse to :)

learn the one you want. C makes you work a lot harder if you do a big project, though.
C++ as a "better C" is still a thing, but for a large part that isn't the driving philosophy anymore. instead, they're working on adding a lot of common functionality into the language to provide consistent, portable interfaces to these things. Filesystem is an example of that, and as far as I know as of C++17 it's out of experimental and you can now just use std::filesystem. Though that is a mouthful so I'd put a using fs = std::filesystem; in a few places just to help out with that.

There have been some significant improvements to the language mostly in C++11 though. First and foremost are things like std::shared_ptr and std::unique_ptr. Before, memory management in C++ was a bit of a nightmare. Together with move semantics (which allows you to make objects that cannot be accidentally copies, but efficiently moved to another location). But now it's much more difficult to get a memory leak. There are also some great improvements like lambda functions, which allow you to have small unnamed functions that are extremely expressive.

C, on the other hand, doesn't help you with anything. It isn't C's job to help you. It isn't C's job to make sure your program is valid before compiling further than a cursory check. It isn't C's job to help you manage memory. So it really depends on what you're doing and what you want out of a language. If you want modern features and a strong type system and a compiler that actively tries to help you have correct programs before spitting out machine code, you want C++. If you want raw functionality and a simple language that can be easily understood that works fine as long as you wield it correctly, you want C.

Honestly most people want C++. However, I glossed over something in there: C is a language that's easy to understand. While that is only a 3/4 truth (all languages have their deep dives and things that just don't click until years after using them), it does imply that C++ is not an easy language to learn. And that is correct, even though C++ goes out of its way to try to make sure your programs are correct, it often times gives you incomprehensible error messages. Understanding C++ is hard, learning C++ can be hard, using C++ can be hard. You can pick up Python in an afternoon, you cannot pick up C++ in an afternoon. For some people this is a commitment they're not willing to make. For other people, it's a necessary evil for the power C++ affords you.
Thank you, that has helped clarify my questions regarding the two.

I will continue with C++, but i think learning C is appealing too, and perhaps help me learn those incredibly difficult error messages lol.

It is nice to know that the two languages are still going strong, and change is inevitable in this world.

@Jonnin: it is good to know that i'm not the only one returning to the developers world :-D
Last edited on
Topic archived. No new replies allowed.