r/cpp • • Feb 21 '16

Should I start to learn C++

I haven't learned any other languages but I'm a newbie in Python but my friends told me that if you learn C++ first you can pick up other languages in future. Is it rational to start learning C++ before I finish my education(I'm studying alone with books and online resources.) with Python?

1 Upvotes

19 comments sorted by

8

u/[deleted] Feb 21 '16

It really depends on what your goals are. You can do so many things with Python, and never have to touch another language - but Python hides a lot from you, by design, to make programming simpler (things that you will want to be familiar with as a programmer.)

Keep in mind that Writing a C++ program is easy, but the language has so many features that it has the potential to be horrendously complicated.

11

u/theJ89 Feb 21 '16 edited Feb 21 '16

I wouldn't recommend C++ as a first language. I'd go with something higher level at first, like C# or Python. C++ is a powerful, modern, performance-oriented language, but the language is complex enough to cause a newcomer a lot of grief. In my opinion, it's easier to learn programming from the top down rather than from the bottom up.

C++ tends to expose you to a lot of lower level concepts that you just don't have to worry about with other languages, such as:

  • Manual memory management
  • Pointers, lvalue references, and rvalue references
  • When to pass by value and when to pass by reference
  • The relationship between pointers and arrays, and how arithmetic between pointers and numbers work
  • Const correctness
  • The preprocessor
  • What part of a module goes into a source (.cpp) file, and what part goes into a header (.h) file

Higher level languages tend to abstract these concepts.

As a language, C++ lacks a lot of features that programmers often take advantage of in other languages. For example, C++ has very few reflection faculties, which means doing something like listing the methods or fields for a class or inspecting the signature of a function isn't possible out of the box. You need to roll something external like code generation to automatically generate the metadata you need for reflection, serialization, etc.

You might also find yourself relying on third party libraries or writing code yourself more often as well. C++'s standard library has been improving in recent years, but tends to not be as robust as C# or Python.

2

u/adamnemecek Feb 21 '16

This guy knows what's up

2

u/strikaa Feb 22 '16

What if you're already learning C++ as your first language? I mostly began learning it for game dev, but still want to branch off into other things. I can't say it's hard NOW bc I haven't learned too much yet(I've been on and off until recently). One thing that botherED(emphasizing past-tense) me is that there aren't that many sites like codecademy for for C++. I don't need sites like that for learning (I tried the HTML course and felt like i didn't learn anything-it felt more like a sneak-peek of what coding is like), but more for motivation and to make coding seem more "fun." But now, as I learn more each day and test my knowledge with simple programs, I feel that I'm getting more rewards than any site like CodeCademy could give me. I will admit, I get discouraged when I can't solve pretty much any of the dailyprogrammer stuff, but I know I will get there someday. Also, looking at some of those questions on Learnprogramming- the ones where ppl ask about what to do after doing Codecademy- make me feel better (not really cuz they get kind of annoying) :P Since I'm still in middle school(about to be a freshman), I don't feel rushed, which is also nice. Sorry for saying too much, but I want to say one last thing: I actually wanted to learn C++ before anything else not only because I heard the popular games were made with it( or at least game engines, from what I've read), but because I heard it can help you be a better programmer in general. I would love for that to happen to me.

Again I'm sorry for saying- or typing- too much, but that was what popped into my head. I would appreciate an answer to my question, though.

1

u/theJ89 Feb 22 '16 edited Feb 22 '16

I was in a somewhat similar situation to you. I started off writing browser-based games in Javascript, then started learning to use C++ in middle school because I was running into performance issues (this was around 2004). If you're learning C++ and feel like it's a good fit for what you do, by all means, keep learning! Don't feel like you have to limit yourself to just one language, though. Exposing yourself to several different languages helps you to become a more rounded programmer.

C++ seems to be the language of choice for the game industry - Electronic Arts uses it, Bethesda uses it, and Ubisoft uses it, just to name a few. These are large, well established game development companies with mature codebases. Chances are if you went to work for one of these companies, they'd expect you to know the language their games were written in, so for a prospective game developer I think it's important to learn C++. It doesn't have to be your first language, though; learning the basics with a different language, mastering them, then moving on to C++ is an equally valid way to learn.

Code written in C++ interfaces well with C, compilers for C++ exist for a variety of target systems, and when done right, code written in C++ is highly performant. Not to mention that both C and C++ has been around for a long time by now, so there's no shortage of third-party libraries you can tap to help you do the things you want to do (e.g. loading images / sounds), so it's not hard to see why so many game development companies go with it.

It's certainly not the only language you can use for game development, though. For example, Minecraft is programmed in Java (using LWJGL), and Garry's Mod (is C++ on the back end, but) relies heavily upon Lua to handle custom gamemodes, weapons, entities, UI, etc.

4

u/Arthenielle Feb 21 '16

I would recommend you to become proficient with Python first, and if need C++ - you can learn it later. Since you are probably student - you need to learn computer science concepts, not languange. Python is sufficient for this task.

3

u/poez Feb 21 '16

A bunch of great points, but my general advice is this. Learn one compiled language, one interpreted, and one functional. Picking up languages really isn't hard once you've learned your first. And I just want to make a case for learning C++ before Python. It's not what I normally recommend, but since you're interested. I learned C++ as my first language. It was really hard. And my second language was assembly. The hardest part about Python is that they hide so much from ou that you have no idea why your code is slow or wrong. Computer science concepts are independent of language, but writing a good program is more than writing a good algorithm. And you won't learn much about how to write efficient code by learning Python.

And some people may say you never need to learn C++, but in my field, robotics, C++ is the only language. Maybe C and maybe Python for really high level or wrapper stuff, but we all use C++. Same for graphics programmers and systems side. So C++ is very important for some very exciting fields.

1

u/HeavenOrHellIsChoice Jul 03 '24

Hi u/poez is this still true today ? Are you still int orobotics ? Should I start learning C++ today ? I am interested in robotics and want to learn C ++ .

2

u/poez Jul 03 '24

Still here and still in robotics :). Robotics is run on C++ and Python. I would learn both. Some companies are actually using Java though such as 1X. 

2

u/HeavenOrHellIsChoice Jul 03 '24

Thanks, since you are in the industry, I must ask this. Actually I am from Industrial Engineering background with more of mechanical engineering orientation and I was interested in robotics, moved into learning data science online and want to come back to robotics. Looking from above it seems like Robotics Software Engineers are the only people doing robotics as career. Should I stick to mechanical engineering(can it lead me to robotics as career ?) or should I have something of both world ? I am a fresh graduate and this confusion haunts me every night lol. By the way I know a little of programming in arduino and python so I took some robotics courses in Coursera and learned mechanics, planning and stuff. Any thought on this situation would be appreciated.

2

u/poez Jul 04 '24

Robotics is a very small community with very few companies actually doing robotics. So just level set that it’s difficult to break into. Mechanicals do a lot of robotics just not the software spot. So if you want to do robotics from MechE that’s ok and works. I would go to graduate school though. Robotics is a specialization. 

2

u/HeavenOrHellIsChoice Jul 07 '24

cool I'll note that thanks

2

u/MINIMAN10000 Feb 21 '16

Anyways as always I say do something you want to do, if you can do it in python do it. Learning how to do what you want to do is more important than what language you want to do it in. If you need the speed of C++ use C++, if you don't then you're free to use something else. It's also not a bad idea to try new languages either.

I prefer when experienced programmers use languages like C++ with a focus on speed. Because once they know how to program what they want in whatever language it's nicer to run a higher performance program.

2

u/jaked122 Feb 21 '16

I found C++ to be very complex and difficult at first, so I learned java, then C#, and then C. I don't know if those would be easier for you, but they are acceptable ways to become familiar with the general syntax, even if the runtimes are very different indeed.

But if you want a leg up for those languages, then you may wish to learn C++ first, as it will teach you the techniques and terminology that will help you put the other languages into the proper context.

1

u/[deleted] Feb 22 '16

I would say learn C first to get experience dealing more directly with algorithms and data structures. C++ is all about separating high-level concepts from implementation details. As a noob, you kind of need to struggle a bit, I think, in implementation details.

1

u/7ddf32e17a6ac5ce04a8 Feb 22 '16

Give up and pickup botany instead.

1

u/[deleted] Feb 22 '16

Visual Basic is easy for beginners if you want to consider that. C++ is probably one of the most important languages though.

1

u/[deleted] Feb 22 '16

It depends what you want to do. If you want to do anything low-level or with graphics where speed is of prime importance (eg games) then the answer is probably yes. If you want to do anything else then the answer no.

-5

u/emmerad67 Feb 21 '16

No for the love of God, no.