How to code C++?

Mukhtar

Member
I'm interested in learning C++ since its a pretty common coding language. Can someone whose experienced explain how they learned it so I have some insight about what I need to do. I'm sure other people in the community are interested in this topic aswell, and sorry if someones already made a post about this. (2lazy2srch)
 

vincismurf

Legions Developer
You'll learn if you watch tutorials, and apply it to, for example visual basic 2006, make small little projects, and go from there.
 

Sharp

Private Tester
Good decision in learning to code - everyone should. It teaches you how to think:

I took CS50 (the thing in the reddit post) and that'll give you exposure to a little bit of everything in coding - encryption, compression, web, games(e.g. scramble or sudoku). You'll know enough to know how to figure something out. If you want to work on games though, you might as well just start in C++ since you'll just stay in one language.
 

Volt Cruelerz

Legions Developer
C++ is a popular language because it is powerful and fast. Java often ends up being used for things because it is easier to program in. Legions is written in TorqueScript whereas the Torque engine itself is written in C++. Most any game company that uses a proprietary engine will require you to know C++ because it's probably written in it. Overall, I find programming in C++ to be an enjoyable experience, but the problem of course is how much of a pain debugging it can be which is much of why Java is used in many cases where speed isn't as important.


My personal experience with learning languages was as follows (I don't include things like Lego Mindstorms, GML, or EasyC because you don't actually write code in those). Perhaps it can be of some use to you in some way.
  1. Visual Basic: didn't really enjoy the language comparatively, but Visual Studio made designing GUI's easy at least. After noticing I was getting two-week projects done in a day in that class, I thought maybe I should be doing this with my life.
  2. Java Attempt 1: overall terrible, though this had more to do with trying to learn via independent study which is something I'm not good at and the fact that my high school's computers didn't play nice with Eclipse (a popular Java IDE).
  3. HTML/CSS: overall, decent, but not fun for me. I was working for my brother's web design company at the time. It was alright, but I learned enough to know I could never do that with my life.
  4. Java Attempt 2: took a formal class at college and finally understood it. It was during this class that a lot of the things from my VB days started to make sense, what all those scoping things meant that I just did for the sake of doing at the time.
  5. C#: While I wouldn't say that I'm a master of this language by any means, I learned the basics after hearing that TorqueScript was based on it and I wanted to learn TS so I taught myself the basics of it in a weekend. A club I'm in at Purdue also built its engine in this language so I've used it to program in that too.
  6. TorqueScript: perhaps it's just from the sheer volume I've done in the language (between LTS and Legions and a few other projects I've done in it, I probably have more code in TS than all other languages combined), but I really enjoy the scripting language. It's certainly not fast, being a scripting language, but the expressiveness is nice IMO. Personally, I'd recommend you start here since you're familiar with Legions, you'll be able to see your changes more easily. It should help you with understanding the basic logic that programs follow. If nothing else, it'll give you a huge codebase to look at.
  7. C: C started out painful and though I hated the class (the class basically made us make a day-trading bot for the stock market), as the semester dragged on though, I found myself liking the language more and more until eventually it overtook Java. That said, segmentation faults (segfaults or SEGV's) were a pain and I coined a phrase that was used at some point in that class by almost everyone I knew: "Do or do not, there is only segfault."
  8. MIPS Assembly: the actual assembly code (when you write code, it is in a form computers can't directly understand so your compiler will turn it into assembly code which are discrete instructions which are themselves equivalent to a single binary sequence) used by things like the PS2 and other older systems. I did a tiny bit in x86 Assembly (what your computer is running right now), but it was a pain and something I really would like to avoid in the future.
  9. Python: the aforementioned club's engine eventually integrated Python scripting for game objects. I didn't work with it much, but I did use it some.
  10. C++: this is the most recent language I've learned and while it may just be a superset of C, it feels friendlier. I really do enjoy it. While still not as comfy as Java, I've found thus far that programming in it is overall quite pleasant. The two major projects in this I've worked on in this language are a sound editor and what I am currently doing is a shell. Despite the problems I run into, I never find myself blaming the language. Whenever a bug is found, I never find it being because the language can't do what I want. Idk... It's less frustrating programming in this than other languages, though perhaps this is simply from having programmed in several before it.
As said, I would personally recommend learning TorqueScript. No, it won't help you in the long run in and of itself, but learning the logic of programming in a more comfortable environment where you can see your changes more readily (in the game itself) may be of use to you. C++ is great to learn in the long-run since so many things use it and it's fast. That said, as Belb said a while back, "C++ is one of the most powerful, and least productive languages in existence." Another thing to note is that once you learn C/C++, you'll understand things at a much deeper level than before. If you have the patience for the segfaults and crashes that are bound to happen rapidly in C++, I'd say start there. If you want to do more dabbling first to try to get a better handle on things and ease yourself in, I'd recommend modding Legions a bit first (just stay away from Engy core; that thing is NOT a good place to start lol).
 

Jordahan

World Leader of The 21st Century
I am doing some VBasic stuff right now. Like Volt said, it's an easy enough language to learn and it'll give you insight into whether or not you wanna follow it. (I do not, I find it boring as all hell)

But it's a decently easy language to learn, just go download Visual Studio and watch some youtube videyas. It gives you some insight into GUI's too.
 

Dabbleh

Legions Developer
My (limited) experience in C++ is that it takes ages to write the smallest bit of code compared to a higher level language (obviously). So it's great for learning the 'nitty gritty' but not so great if you want to jump in and start making interesting programs. Personally, I find TorqueScript severely infuriating since you have to work off already shoddy code that you have no idea or documentation as to how half of it works.

Python is great for beginners because you don't have to remember much syntax (apart from hitting tab, which it does automatically half the time), once you get the grips and concepts of that, you can look at what 'CPython' (the vanilla Python version) runs on, C. Python also has built in Garbage Collection, which means that it clears the memory you have used once you are not using it anymore, in C this would be your job, this is just one of the aspects in which you need to wrap your head around when learning C++.

Ultimately it comes down to how much time and dedication you are willing to put into this, following YouTube tutorials (bucky is a great) is a good way to start, but I find that I want to go off and figure out my own stuff as I get to grips with the syntax and basic ideas of the language. There are also some great books out there to read when you aren't in front of the PC.
 

WildFire

Warrior of Linux
My college teaches VB as its easy to pick up and doing GUI's are really easy as others have said. I would really recommend doing VB before c++ as it'll teach you basic coding fundamentals in an easy-to-learn manner (things like loops, functions, recursion, etc)

I did this first and now I'm starting to mess around with c++ and I'm finding stupidly easy to pick it. Once you work past the syntax (which in my opinion is the hardest part of picking up a new language) its great.

Edit: Don't do torque script unless you're interested in legions, its as ugly as *dance*, hard to get around the syntax etc I really wouldn't recommend doing it first thing.
 

57thRomance

Member
I had a course in computer applications, in which I learned the basics of MATLAB and C++. Although I had an awful professor, I can say that both languages are incredibly easy to learn. C++ is a bit more universal than most languages you'll come across, so I would say start there. It should give you a good base so that when the time comes to play around with games and such, learning another language is easier.
 
Top