How do you 'learn' a programming language?

Started by
21 comments, last by Tutorial Doctor 10 years, 5 months ago

The topic header might be a bit ambiguous and rage-inducing, so let me clarify it for you before I end up with life threats rolleyes.gif I have only recently put my foot in the waters of game development, and it's mostly theoretical stuff about it. My story with programming -and desire to develop games- though has begun at least 6 years ago, in High School, in an extracurricular class, but that was mostly Pascal-based procedural algorithms. Lately, and after finding a few good men who would like to join me in my quest (and they are serious about it) to learn and finally develop a game or two, I started putting a more serious effort in it. Before you bash me about gathering a small team when even I can't stand on my feet, I have to say that it's just two friends (one is a coed of mine in Physics school) and it really helps keep the motivation up, since we insist on learning together and every time someone gets disappointed, another member of the trio keeps him enthusiastic.

Now, on to the actual question. Since I have fallen flat on my face many times when I thought making a small game would be a piece of cake, I have gotten a more realistic picture of what is in store for us. So, I wanted to start from the basics: learn a programming language, and learn it really, really well. I know I can't master it in the next 5 or even 10 years, but I want to achieve a solid understanding of its elements. That language is C++. I know it's rough and low-level and I didn't pick it because 'it's what the pros use'; I actually love it with all its shortcomings, and I find its attention to detail to be parallel to game development itself. Thus, I shelled out some cash to pick a book after some brief research: that book is C++ Primer, 5th Edition. I have to say it is pretty readable and goes very deep where it is needed, so no complaints about the book itself. It's me who has the problem. Whenever I establish a good reading routine, some kind of OCD kicks in and all in all, I give up. What usually happens is that I read a lot of material, and even if I leave it for a couple of days because of college work, I believe I will forget everything and insist on starting all over again. And yeah, I do most of the problems in the book and write my own code. Also, whenever I get stuck at something I don't understand, I get disappointed. This pattern repeats and it is usually one or two month gaps that I don't do any work. The result? I end up actually having to re-read.

This may be suited better for a psych forum, but before I visit the shrink with such a ridiculous problem, I wanted to ask you people. Which do you think is the best way to absorb the material of such a big book? Do you have to actually understand every single line to even consider stepping into a game development framework? Or can someone go through the book once, fully understand the basic concepts like OOP, and just hop up in the pages again if further reading is needed?

Advertisement

I taught myself C++ from Bjarne's book (and some others). I did it in 2 stages:

1) read the book cover to cover to get an overview

2) go back and start at the beginning, not advancing until you understand the concepts (doing the exercises would be done in this step).

So I skim once, then go back and read carefully. Reading a lot of other people's code helps a great deal too.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

not advancing until you understand the concepts

... and completing every exercise at the end of every chapter and redoing every exercise once you learned how to build it better.

I took a different approach to this.
Reading too much books without doing something you want to do with it can be a source of demotivation.
Therefore, read enough so that you understand the basic concepts such as pointers, vectors, basic data types, object oriented class design, that stuff.
Now take that, and start making a game.

As you do this, you will automatically run into problems, which you will then seek to fix. These won't just be design related problems, but some will result as a lack of fully understanding C++. When you tackle this problem, you will learn alot from it. This pattern will repeat and you'll always improve your skills. The most important bit is to never, ever give up. Some problems might be tough, but eventually you will crack it.

My starting point was using SDL to make a simple tile-based farming game, I used these tutorials as a reference: http://lazyfoo.net/SDL_tutorials/

Don't expect your first game to be a work of art, both in terms of graphics, nor in terms of game design. But you will learn so much from it, alot of things you shouldn't do.

Take it one step at a time, but keep working on something. That's how it worked for me.
Hope this helped!

Cheers

Agreed with the above - start working on a small game! I'd you've never successfully completed a game yet I'd suggest starting with Pong/Tennis, but any relatively small/simple game idea will do.

Just get an image displaying on screen, then allow the user to control it via mouse or keyboard, then add another image, then detect collisions between the two, and so on and so forth.

Whenever you get stuck refer back to your book, check online resources, or ask here. Working on an actual game should provide more motivation for you, and actually applying the information in a useful way should help you to properly understand it.

- Jason Astle-Adams

really the best way to learn programming is to just code and keep coding. You said you read something and you do the examples. Ok good, but is that all? I used to do the same thing and well I thought I knew all the concepts but I found later on when it came to applying them to a different program I hadn't really learned them. Then what I started to do was create my own examples. Ask yourself questions while reading. While your reading try creating your own examples before you even get to your exercises in the book. What you will end up doing is helping yourself understand this concept in a lot of different ways. The ways/examples you do might not be meaningful or useful but that is ok.

Next after you do the examples in the book, try to extend on them and make them into a more "complete" program/example.

Finally if you don't understand a certain concept try writing it down. Work through that concept on paper like the program would run it step by step. Then put that concept into a program and use your debugging tools to attempt to run the program step by step. Look at what values changed? Why did they change? Work that out on paper and compare the results. If you are getting the same results on paper as you would get in the program then you're understanding the concept more.

It all comes down to, just keep programming. Their will be concepts you don't get or understand right away. Just keep programming. We all need breaks and everyone here understands that. Though in the end make sure you come back and keep programming. When you come back instead of thinking that you have to reread everything try testing yourself on what you read previously without looking at your book. If you keep doing all of this before you know it you will solving problems all on your on.

Just remember though we all need help sometimes. Don't be afraid to ask questions. Everyone here be it professional or not need to ask questions sometimes and we have all been there before and we all understand (ok their are a select few people I've noticed that do believe they are above everyone and think they understood everything first try, but ignore those people).

Yep, the best way to learn is just to start doing it and figuring things out as you go along.

I know many programming languages and it is really not the language that is difficult to learn this is often just various API, and Syntax. The best way others have mentioned is to learn by doing and researching as you get stuck. By doing this you learn various algorithms and data structures they carry over across programming languages and then it is really just about the syntax. This follows suit for all imperative languages and does not really break down till you try to learn a functional programming language where all the design patterns, algorithms, and data structures must be represented in a completely different way. So as long as you are sticking along the lines of C++, C, Java, C#, Python, etc... Learn by doing/researching eventually it will start to click and make sense. There is no way to just learn by just reading a book it really takes personal projects to get the total picture.

Start some projects that would be fun to you, if you aren't good enough to start a project yet then read a book on the subject.

If this post or signature was helpful and/or constructive please give rep.

// C++ Video tutorials

http://www.youtube.com/watch?v=Wo60USYV9Ik

// Easy to learn 2D Game Library c++

SFML2.2 Download http://www.sfml-dev.org/download.php

SFML2.2 Tutorials http://www.sfml-dev.org/tutorials/2.2/

// Excellent 2d physics library Box2D

http://box2d.org/about/

// SFML 2 book

http://www.amazon.com/gp/product/1849696845/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=1849696845&linkCode=as2&tag=gamer2creator-20

How about a challange? See if you can solve 5 problems on Project Euler :)

This topic is closed to new replies.

Advertisement