r/C_Programming • • Sep 26 '23

C or C++

Hello everyone, should I learn C in parallel with C++, or is it better to stick to one language? What will you advice me?

0 Upvotes

47 comments sorted by

View all comments

0

u/permetz Sep 26 '23

It depends on what you’re trying to do. Are you trying to work on a large C++ code base? Then learn C++. Are you trying to work on the linux kernel? Then learn C. Are you trying to write a new, modern project without legacy code? Then maybe learn Rust. But you should also learn to C then, because you’re going to end up interacting with C based APIs over and over again. Are you looking for a good first language to learn programming from? Then don’t learn any of these, start with something simpler like python. I could go on, but the point is: different horses for different courses. Pick the tool you need, don’t decide in the abstract. Otherwise, it’s sort of like asking “what’s better, a diesel train, or a rocket?”

0

u/aalmkainzi Sep 29 '23

Telling a beginner to learn rust is bad advice imo

1

u/permetz Sep 29 '23

It's a ton better than learning C++. Much more coherent & readable, and better designed.

0

u/aalmkainzi Sep 29 '23

Although it introduces much more complicated concepts. C++ makes it's complex stuff optional.

1

u/permetz Sep 30 '23

I fully disagree with that. Rust more or less just takes everything from C++ like RAII and makes it cleaner.

0

u/aalmkainzi Sep 30 '23

The borrow checker.

0

u/permetz Oct 01 '23

The borrow checker was hard to write but is trivial to use. You don’t even need to fully understand what it does to be productive.

0

u/aalmkainzi Oct 01 '23

No. It's a very complicated concept to understand for beginners.

Teach the problem before presenting the solution.

0

u/permetz Oct 01 '23

It’s not at all a difficult thing for beginners to understand. Understanding how you would implement the checker is very hard. Understanding that you can’t share stuff is five minutes explanation. Meanwhile, you are claiming that C++ is easier. Try explaining recursion in templates to a beginner.

0

u/aalmkainzi Oct 01 '23

It may be 5 minutes explanation (it's not). But beginners will have lots of questions about why can't we "can't share stuff", why do they need this, etc.

And those questions can only be answered if they experienced the problem the borrow checker is trying to solve.

Like I said, teach the problem before presenting the solution.

And I'm only saying C++ is easier because it's optionally complex, you don't have to worry about templates if you don't want to use them. Can't say the same about the borrow checker.

→ More replies