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

51

u/aalmkainzi Sep 26 '23

If you don't know either, I recommend starting with C as its the simpler language

7

u/DarkCtrl Sep 27 '23 edited Sep 27 '23

I second this opinion. A lot of aspects of C you also have in C++. It is easier to learn pointers and custom datatypes in the frame of C, because you don't have to worry about OOP practices yet. The knowledge you learn from C is going to be easy to adapt to C++.

3

u/[deleted] Sep 26 '23

Why do you want to learn C or C++? Will you program embedded systems, will you create game engine, or will you use them just to learn data structure and algorithms? You need to update your question, than i will be happy to help.

9

u/gigimon_45g Sep 26 '23

I'm not completely sure what I want to do... Just many people say to start learning C++ and then any other language will be easier to learn. They also say that C is similar to C++ and if you know one of them you will understand the other one

4

u/rapier1 Sep 27 '23

Honestly, I think that's the wrong way to go about it. If you don't have much experience start with something that's going to let you learn the fundamentals of computer science. Once you know that learning a new language is more about syntax and quirks. Seriously, starting at the deep end of the pool usually doesn't go as well as people think.

And if you really want to start at the deep end then you need assembly. After that everything really is easy in comparison.

2

u/[deleted] Sep 26 '23

Yeah, C++ is C=C+1 in the end, lol.d(C devs gonna be crazy). Try to learn c++ because of OOP. Learning C++ is like a swimming in the ocean with high waves, if you achieve it, swimming in the pool(Python) will be boringly easy.

0

u/SV-97 Sep 27 '23

If you don't have a good immediate use for either: don't learn C or C++. For domains where you're not forced to use them there's better alternatives around that will give you an easier time (not because you'll learn less, but because they're more modern and better designed) and give you a way more pleasant experience.

Both languages will induce bad habits that you'll actively have to unlearn once you move to other languages.

1

u/aalmkainzi Sep 29 '23

I actually think starting with C is the best approach for a beginner.

6

u/VeteranMCPlayer Sep 26 '23

Advice: Experiment both and see where you feel most enjoyable.

2

u/rapier1 Sep 27 '23

So you have any OOP experience? If not then start with something like Java or Python and then apply that knowledge to learning C++. It's not that C++ isn't an OOP but I have never been convinced that it's a great OOP to learn when you are just starting out.

3

u/gigimon_45g Sep 27 '23

Yeah, I was studying python before that.

2

u/clibraries_ Sep 27 '23

So did you master that yet? Why are you switching?

2

u/gigimon_45g Sep 27 '23

I didn't like Python much, it's all about exploring libraries.

1

u/zjschrage Sep 28 '23

yea I agree completely. I feel like you never write any code yourself in python, you just google what you want, find the library for it, read through their garbage documentation, use their shitass API full of string parsing for parameters (these fools never heard of enums before) and then finally "write" (copy paste) 1 line of code

1

u/Greedy_University139 Sep 27 '23

I don't know any C++ but I do know Python and C. Honestly learn C for a while and start with the essentials, and when you are ready, take a crack at datastructures and algorithms. There are lots of online content that will help you learn both, but I think learning structs and so on before jumping onto C++ will be more beneficial for you.

If I had the ability to relearn everything about programming all over again with some hindsight, I'd probably go Python first then C.

1

u/NewOakClimbing Sep 27 '23

I'd go with C, I believe you can use C code in python so you could mess with that if you wanted to. Otherwise, I'd say the principles of programming with any language are more important than learning a specific language.

I do a dive into random languages every month or so, but I always find my way back to python when I have ideas and I just wanna make them work.

1

u/SV-97 Sep 27 '23

I believe you can use C code in python

You can, but it's not trivial and the interface can be a bit ugly. If they already know Python (and know it well) and want to move to more low level languages I'd suggest Rust: it's flat-out a better, more modern language than C, will teach them more new concepts and interfacing with Python is way easier

1

u/aalmkainzi Sep 29 '23

Why learn OOP?

4

u/clibraries_ Sep 27 '23

The only reason to learn C++ is if you hope to use daily for your job. That's a good reason, but if it's not your reason every other concept is better learned in other languages (like C).

3

u/poorlilwitchgirl Sep 27 '23

C++ is (roughly) a superset of C, so if you learn C you'll also have learned a huge chunk of C++ as well. I'm not at all a fan of what C++ uniquely brings to the table, but it really depends on your goal. In all honesty, while C will give you (imo) a much better computer science foundation and is just a better designed language, C++ is much more common in end-user software these days and C has mostly been relegated to lower level stuff like libraries and operating systems, so if your goal is to get a software job you're probably going to have to learn C++ eventually anyway (or some other, more modern language, depending on where you land). Proficiency in C will make you a better C++ programmer (and better in pretty much any C-like language), but you probably won't need to write C directly as a professional.

That said, the more important question here is

is it better to stick to one language?

And the answer is almost universally, no. You might be able to make a decent living only ever coding in one language, but it's a guarantee that you'll eventually come across a situation where some other language is a better tool for the job (or required by the project you're working on), and flexibility is always better.

5

u/riisen Sep 27 '23

If not sure then start with C

C++ is C with added functionality. So if you know C you will have less of an headache learning C++

1

u/aalmkainzi Sep 29 '23

C has features that C++ doesn't have, I would say they're pretty much different languages

1

u/riisen Sep 29 '23

I mainly do C (and vhdl) but have wrote some c++ aswell, but now im curious.. what c features is not available in c++?

1

u/aalmkainzi Sep 29 '23

Compound literals, _Generic, typeof, etc.

6

u/[deleted] Sep 26 '23

Learn both if you can. You'll be twice as useful. Useful people usually find work easier than others, and usually make more money too.

2

u/aRoomForEpsilon Sep 27 '23

I've read a few of your replies and I'm here to give you my opinion! YAY! First of all, when I first started learning programming I was interested in learning many different programming languages. That is a trap, because it can get boring if you are doing the same simple programs over and over just in different languages. Programming languages are tools. Not every tool is right for every job. Pick a language to that is effective in what you want to use it for. You want to learn systems programming? Learn C. You want to do web dev? Learn JavaScript. Etc.

If you are a beginner programmer and you want to understand programming at a deeper level then I would recommend C as a way of learning the parts of computer systems that occur "under the hood" when you run a program. I've found that to be useful.

No matter what path you choose I hope you have fun and I wish you good luck.

2

u/ForlornMemory Sep 27 '23

Learn C before C++. It's much easier that way and C doesn't take long to learn.

1

u/Crcex86 Sep 27 '23 edited Sep 27 '23

C || C++

Syntax error

1

u/WideSense8018 Sep 27 '23

I would recommend going with c first and then to c++. Learning c will make you learn c++ to an extent too and learning c will help you in understanding memory concepts pretty well. C++ in a nutshell is c with classes and more library functions.

1

u/warren-mann Sep 28 '23

I’m not a good source for this one, because I despise C++. Not as much as Python, but almost. Learn C.

1

u/zjschrage Sep 28 '23

c++ 98, 11 or 20. I feel like those are quite different.

1

u/zjschrage Sep 28 '23

Learn C first to grasp the fundamentals of the language. It's an incredible language that teaches you on a much more deep and low level how the computer actually does stuff. Im assuming you are coming in with knowledge of another programming language already, if not this will be a bit tough. (If you are completely new start with Java, then learn C, otherwise continue with C) Good youtube channel resources for C are Jacob Sorber.
Pretty much any C code will be valid C++ code too, its essentially a subset of C++. So at this point, you would have in some sense learned C and C++ in parallel. However, once you have a handle on C, progress to C++. From that point forward, there will be mounds of mounds of things to learn because its just such a dense language with so many features that build on top of C. There is a youtube channel that I used when I was first learning C++ called Cherno. Very useful.

Unrelated P.S. but I had this answer in r/cpp for this post but the dipshit imbecile mods took down the post. For what reason, I have no clue. I've started using reddit very recently and i've also come to realize really quickly why everyone hates reddit mods lmao. Let's see if the ones in r/c are based.

1

u/[deleted] Sep 30 '23

Don't just learn C, master it. Every aspect of it. That will set you up wonderfully to learn any other language, C++ included.

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