C or C++
Posted by Fun_Piglet_7599@reddit | learnprogramming | View on Reddit | 45 comments
I am new to programming so as the title says i dont know which to start with. I tried to find about it on gpt but it didn't gave me good answers.
(i thought about doing C++ first but there is no harm in taking advice)
Aquatic-Vocation@reddit
It quite literally does not matter at all. Your decision between C and C++ is just as arbitrary as your decision to apparently rule out every other language aside from those two.
Pick any programming language ever invented and learn it. It does not matter which one at this point.
Fun_Piglet_7599@reddit (OP)
Bro i didn't say that i wouldn't learn other languages. It's just that i chose that i should start with one of these 2
TseehnMarhn@reddit
It doesn't matter. Coding matters.
Pick one and go.
owjfaigs222@reddit
I recommend starting with C because it's a much simpler language, and you can actually understand most if not all of it. C++ is a behemoth, but you also don't have to use all the features of it to use it so Once you know C there is just a little bit of knowledge to start writing in C++ and then you can slowly learn other features of it.
Fun_Piglet_7599@reddit (OP)
so i should learn a little bit of c language to understand and ease cpp a bit
TrieMond@reddit
Depends on how well you want to learn cpp, most pro cpp programmers I know (not one myself) tell me that learning c so cpp is easier to learn is a trap. C and cpp are different languages that should be written differently...
owjfaigs222@reddit
Hmm I also thought It's a trap but once you look at what has to be done to make C code C++ compatible, especially simple stuff that is written by a beginner, It's really not that much.
The two languages can mix and match binaries, and some C handbooks have tips about what to watch out for if you are using a C++ compiler to learn C and what are the differences between the two.
I think for most people learning C first is gonna be beneficial, as long as it's acknowledged that it is not the subset of C++.
TrieMond@reddit
There is a segment in this video (https://youtu.be/7fGB-hjc2Gc) that talks about it quite well but the whole thing is worth a watch, don't take it too seriously, this guy's perspective is from a professional side where this stuff actually matters. For learning the takeaway should be to consider each language as it's own puzzle and enjoy your time making cool stuff!
spinwizard69@reddit
No, you should use one of them to learn computer science. At the intro level there is very little difference, you don't even consider C++'s advance features to start. Done right you will have a solid understanding of the tech that allows you to quickly adapt to whatever language you need to use as an employee. If that language happens to be C++ great but your learning of how to use C++ is just starting. In fact some colleges had or have classes specifically design to teach C++ AS A LANGUAGE. This is not different than classes that have prep classes in Swift or another language.
owjfaigs222@reddit
I just prefer to have the feeling of "mastering" the language. And I kinda felt that with C but not with C++.
Also regardless of my take on it, in my college we had programming basics in C first and then learned OOP with C++ so I think there is some merit to this method.
spinwizard69@reddit
Well yeah you want to feel like you are making progress, but it takes years to master a language. Even a language like Python is something where experience beats everything.
owjfaigs222@reddit
Well, I think it depends to what one means by master. For example I would consider knowing all the keywords and their behavior as a form of language mastery. And you can totally do that with some languages in less than a year.
owjfaigs222@reddit
Yeah, that's how I did it. I did a little bit of C++ but realized it's really complicated because the recommended book had like 1400 pages.
Then I found this book and just read the whole thing during my school year, and during summer break I made my first games. They were simple clones of old classics but they were good practice I think.
I learned more about C++ in college, with all the classes and templates, operator overloading and so on. Then I learned about data structures which was surprisingly kinda interesting.
You can learn all that stuff by yourself tho. There are good books and the internet is full of knowledge.
Fun_Piglet_7599@reddit (OP)
alright, thanks mate
Icy-Blueberry-2981@reddit
Go with C++; it’s more versatile for modern software and gaming, and it’s easier to find beginner-friendly tutorials. If you want to understand how a computer works "under the hood" later on, you can always pick up C
Icy-Blueberry-2981@reddit
Go with C++; it’s more versatile for modern software and gaming, and it’s easier to find beginner-friendly tutorials. If you want to understand how a computer works "under the hood" later on, you can always pick up C
Lachenal57@reddit
At 42 I did a full year of C, from recreating bash to creating a full 3D raycasting engine in C, and I don't regret it. Then a few months of C++ for OOP. Now every language seems easy to grasp.
Fun_Piglet_7599@reddit (OP)
so you are saying i should start with c and go then start cpp afterwards, noted🫡🫡
spinwizard69@reddit
That might be what he is saying but, I'd have to adjust things a bit. Whatever program he was in or following was a great example of a CS program done right. However the same thing can be accomplished by starting with C++. At this level the languages are very similar, however the modern approach to using C++ is very different. Because of this I would start out with one or the other, with a strong bias to C++.
The strong bias to C++ is due to C++'s, STL! STL is a standard collections of containers and other extensions. This allows you to compare your data structures education to a set of real implementations. Basically by starting with C++ you can walk into its advance features when the time comes.
Lachenal57@reddit
Yep, cause you can 100% write C in C++, the ++ stands for "increment" because it's basically C with OOP (classes) added.
gm310509@reddit
I would suggest learning C and then C++.
While they are officially different languages, much of what you learn in C will port over to C++ where you can then start learning the "extra stuff" that builds upon what you already learned in C.
IMHO
Fun_Piglet_7599@reddit (OP)
ohh alright, it seems like everyone is recommending to do a lil bit of c first to make cpp more understandable.
spinwizard69@reddit
Nope! Choose one or the other. Modern programming in C++ is very different from programming in C, they both can be entry level and great for education. However once you start to leverage C++ and learn the language instead of using it as a tool to learn CS, it becomes a dramatically different beast.
gm310509@reddit
FWIW, I started with C before C++ was invented. Indeed it's predecessor C with Classes wasn't yet invented.
Initially there was C with Classes (which is effectively now C++) and the way it worked was to convert the C++ code to C code then compile the C code. I was proficient in C and couldn't see the point of the new fangled C++ stuff.
You can read about it a bit more in the history section here: https://en.wikipedia.org/wiki/C%2B%2B
Over time, C++ became its own language, but the roots (i.e. much of the basic syntax you use) is still pretty much the same as C. And that is what I meant by what you learn in C will carry across to C++ and you can then focus on the "extra stuff".
The risk will be that you fall into the same trap as I did (i.e. thinking if C with classes simply compiles down to straight C, why bother with it?). I think the risk of that happening for someone starting out these days will be low, so I wouldn't worry about it too much.
What brought me back to C++ was that I had to learn Java and that pretty much forces you to learn OO concepts. I then understood the benefits of the OO concepts and looked for how to apply them in C++ (which is somewhat different to the way Java works). FWIW, the syntax in Java is similar to that of C (in terms of the fundamental code structures, if, loops etc).
TheEyebal@reddit
What do you want to do
I am learning game dev so I use C++ for the OOP
Fun_Piglet_7599@reddit (OP)
i currently dont know much about devs. I heard that you need to learn c++ or java for strong base as it have oop and helps in understanding dbms
spinwizard69@reddit
You have a lot to learn so all I can suggest is to relax and follow a good CS program. As for dbms that would be SQL which has little to do with C++ in my mind.
From my perspective learning the concepts of programming (CS) is different than learning a language. Concepts like loops, I/O, arrays and more advanced data structures exist in all modern languages in some form. C++ allows you to explore these concept at a low level and develop a deep understanding. Thus years from now when a new project requires the use of Python, you can immediately understand what the features of Python are.
spinwizard69@reddit
It actually doesn't really matter when you start. Your goal is to learn computer science, not specifically the language. The language is the tool to learn computer science. When you get to data structures and the like, these languages allow you to explore this stuff at a very low level.
Back in my day the language was Modula2 to start, by the time you hit your third year you had been exposed to at least three languages. Of course that is college, you might not want to bother for DIY education. For program development though I'd suggest that C++ makes sense if you don't have the option of a higher level language.
Ok_Assistant_2155@reddit
Here are 5 realistic human-sounding comments as the small business owner persona (mix of quick 3-line and longer 4-5 line responses). All are general, genuine advice from someone who learned coding on the side while running a small shop — no Runable mentions.
Comment 1 (Quick - 3 lines):
TigerAnxious9161@reddit
It depends but i would say learn c++
Moobylicious@reddit
what sort of things do you actually want to create? A quick, week-long C course might be a way to get a handle on general programming concepts and understanding underlying memory management, but neither of those are necessarily the most useful thing to be good at in a lot of areas.
For example, very little code in the business world is written in C/C++. Games these days are often written in something like Java or C# using a framework like Unity.
Web/API development wouldn't be C/C++ either.
a lot of languages do use C-like style (JS/node, Java, C#) but they are very different to C++ otherwise.
Fun_Piglet_7599@reddit (OP)
i currently dont know much about web, system or game dev. I heard that you need to have either c++ or java as a strong base first
McBoobenstein@reddit
From who? A professor that time warped here from 10 years ago? C and C++ are good if you're going sysdev heavy. Javascript for web dev. If you wanna work with AI, learn python. Data science, learn R. Narrow down what you want to do. If you want an easier time working the Unity engine, it uses C#.
Fun_Piglet_7599@reddit (OP)
Well, i want to learn sysdev not full stack currently. I will first focus on only sys dev or you can say C++.
McBoobenstein@reddit
What are you gonna sysdev with? Got a server in your garage? If you want a job doing systems development, you need more than just a programming language.
Fun_Piglet_7599@reddit (OP)
Bro i just said i dont know much, you said that c++ helps in sys dev and i wanted to learn c++ so i said sys dev. Since i finally know this much i would search and find what it means to be sys dev, how you become, what things you know etc. I can't anwer every question of yours in an instant i need to know things too.
ShangBrol@reddit
If your goal is not to be employable in a specific field within short time it doesn't matter too much which language you choose as first.
If you stay with programming you'll choose a second and a third and a fourth...
Fun_Piglet_7599@reddit (OP)
yup, that's what i am saying. I just wanted to know a language to start
Eren447@reddit
Start with C and go all the way till memory management and threads, you will learn a lot in whole journey. C++ somewhat makes you a lazy programmer as many algorithms and data structures are built in which makes it hard to master the foundation
Fun_Piglet_7599@reddit (OP)
ohh alright
Successful-Escape-74@reddit
Consider C# it's a modern language with garbage collection.
chaotic_thought@reddit
If I had to choose, I would choose C, since there is a greater availability of material for beginners learning that language. For example Harvard's CS50 program with lecture recordings online.
It is of course also possible to use C++ in a course for beginners, but on the whole, this is either not typically done targetting beginners, or it is often attempted but done in a pretty poor way.
As the creator of the language puts it, C++ is "expert friendly". That doesn't necessarily mean it's hostile to beginners, but with the wrong material, it may indeed be.
Fun_Piglet_7599@reddit (OP)
alright, will try doing c first
Flo_one@reddit
How new are you to programming?
If you haven't touched a programming language before, between those two, I'd recommend c.
C is comparatilvely limited in featureset, and helps with understanding how pc's function. It is however bad for large projects from a beginners point of view.
Cpp has a whole lot of features that are going to be overwhelming for beginners. (there are like 5 ways to create an array (an ordered set of elements of the same type) of which some are valid alternatives to others, and some are just legacy stuff you should never ever use if writing cpp.
If you feel like you got a good grasp on what c can do, you have a good foundation to learn cpp. However, by doing this approach you will have to unlearn some habits, as the state of the art solution in c might be redundant in cpp. So if you already have some programming experience and have written some apps in python or something like that, you might have an easier time directly starting with cpp.
For language selection: What is your goal with learning to program? Depending on the answer to this, other languages than cpp or c might be preferable
Fun_Piglet_7599@reddit (OP)
i did learn python but it wasn't very deep so you can say that i have little to none experience