C versus C++, which one is your favorite?

If you were to ask me, I would say C++ is “a better version of C”, but which of the two is your favorite? Classes are nice, but is the intense learning curve worth it, considering that printf("Hello world!"); in C is std::cout << "Hello world!" << std::endl; in C++?

C or C++?
  • C
  • C++

0 voters

2 Likes

Had more experience with C++, but still very low experience.

I think I’ve only done a cout. That’s the farthest I’ve gotten in C++. I have not tried C at all.

3 Likes

I’ve never done C but I have “attempted” C++. That language just confuses me :rofl:. With all the >> and the <<. My brain just can’t understand. Whereas something that is probably easier (Python) has more instructions than some arrows.

3 Likes

You realize you can do

#include <stdlib>
using namespace std; // Important to get rid of all the `std::`

and then you can do

cout << "Hello world!" << endl;

or

cout << "Hello world!\n";
4 Likes

you realize that doing using namespace is one of the worst practices in c++ and that no official prod will use that.

5 Likes

To add to @bigminiboss, let me explain why this is bad practice. (Not necessarily in your case, its really only if your using multiple namespaces)

Let’s say you had two namespaces, foo, and bar, and you used using namespace for each. foo comes with a function, function1(), and bar comes with another function function2().

using namespace makes it easy to access these functions, but let’s say a new foo update was just released. This new foo update has its own function2(), and if you were unaware of that and updated, you could unknowingly be calling functions that you were not aware of.

foo::function1() and bar::function2() ensures something like this won’t happen.

Sorry this is kinda off topic, just thought it was important

2 Likes

also, it ensures readability since then you can know the lib they’re taken from

3 Likes

So kind of like how you shouldn’t use from module import * in Python?

2 Likes

That DOES make C look a lot better.

HOWEVER, I must say that I’m pretty sure it was a lot easier to jump right into C++ than C (well, I haven’t tried C before but this is just what i think so idk).

1 Like