Are you teaching yourself how to program and write code? Or do yous have extra fourth dimension to kill and want to brush upwards on your skills? Did you already make the "Hi World!" plan in your language of choice, and mayhap a Fahrenheit-To-Celsius converter, and at present you lot're wondering what to do? While I was just starting out in the world of programming I often ran into this hurdle. Forth the style I institute some neat resources and sources of inspiration to keep me going. Whether y'all're hoping to go a game programmer, write the adjacent mobile app, or but desire some practice, I retrieve whatsoever of these exercises will help. Even advanced programmers may observe some of the resources helpful (or they may already utilise them!)

All of these suggestions are language-doubter. Y'all can (and should) use whatever programming language you lot are comfy with. I'chiliad not suggesting that y'all exercise all of the post-obit. These are just some ideas-- figure out what works best for yous! I listing the following exercises because this is what worked for me. I completed all of  post-obit goals and walked away with a lot of satisfaction and knowledge. I promise you can too.

Some elementary programming exercises after Hello World

I've heard many people say, "I want to make a website that permit'southward you make other websites. Should I learn PHP jQuery or should I learn HTML? Tin can I brand a site like Yahoo in Dreamweaver?" Another question I've seen is "I desire to get a game programmer. What's a good book for XNA programming that is for beginners?" Or, "I accept this idea for an iPhone app. How practise I brand it?"

My reaction: Woah buddy! Slow down!

Permit's just get this straight: Programming is (often) long, difficult, and very involved. Many games, mobile apps, and custom websites accept months or peradventure years to make. If you attempt to dive headfirst into creating the next hitting mobile app or the latest and greatest website single-handedly you'll become frustrated and discouraged very quickly. Yous'll likewise probably brand a lot of mistakes or end up going down the wrong path.

For beginner programmers who would rather not get discouraged my advice is to keep it simple. If you plan on making the next big thing you need to know how to do the small things first. So if you can make a How-do-you-do Globe application, can you too make a game of tic-tac-toe?

Write (in your language of choice) a text-based game of Tic-Tac-Toe

This is actually the get-go pace towards making the latest and greatest website or mobile game/app. "But how does that make sense?" you might wonder. By completing this exercise you will surely ground yourself in the reality that is programming. You need to know how to read input in from a user, perform some logic on it, and spit out some new information back to the user. You demand to understand how to go along repeating a loop until a goal is met. If you lot aren't able to perform these relatively pocket-size tasks, good luck making the adjacent mobile app. Still this project is pretty simple and makes for a slap-up next-stride exercise. Once you complete this you'll feel accomplished and ready to take on a more complicated projection. Here'south the project goal:

  1. Assume the user (histrion) is an Ten and the computer is a O
  2. Ask the thespian where they want to identify their X
  3. The computer places an O
  4. Output the ix tiles showing where each player went
  5. Ask the actor where they desire to place their 10
  6. Repeat until a winner is determined

Sound pretty elementary? Go and go far! Then play information technology. Attempt and intermission it. Put an Ten where an O is. See what happens when there is a "Cat" game (no winner). As well, when I hateful text-based, here'southward what I am suggesting:

Write (in your language of choice) a text-based game of Hangman

Now that you take a working game of Tic Tac Toe, let's endeavour Hangman. The underlying programming that you'll have to practise volition be fairly simple. Take what you lot've learned in creating Tic Tac Toe and utilise it to write really awesome code.  Did yous plan out your game of Tic Tac Toe earlier you lot started coding? Did you make functions, objects, or methods (or was it all in one big function?) Did y'all comment your code oftentimes and employ meaningful variable names? If y'all didn't do any of that while creating Tic Tac Toe, commencement doing it while yous're working on Hangman.

Here's the steps:

  1. Pick a random five+ alphabetic character word, peradventure from a list.
  2. Ask the player to estimate letters
  3. If they guess correctly, show the progress.
  4. If they estimate incorrectly, tell them how how shut their person is to being hung.

Here's what I would imagine a text-based version looks similar:

Write (in your language of choice) a GUI based game of Hangman

At present that yous have a basic idea of programming and tin can write the underlying game logic it is probably fourth dimension for a more than user-friendly interface. Even if you plan to make a game engine yourself or hope to forever write console-based programs, learning how to piece of work with a a GUI (or any framework for that matter) is a vital skill for programmers. Aspiring programmers have to learn how to use other people'southward code or frameworks and get their code to piece of work nicely with information technology. This is something that comes upward again and again. Software programming is not about reinventing the wheel every fourth dimension you need to exercise something. For this reason I would suggest learning about what sort of GUI kits are available for your language of pick. For Coffee, yous might desire to cheque out Swing. For Python, you might desire to check out TkInter. Do some research in which GUI frameworks are available for your linguistic communication. Withal, don't stress too much about which framework to utilize. You'll be building a fairly elementary game (and you already wrote the underlying game logic).

The primal here is that you'll gain some experience with some of the more avant-garde topics of your language. You might not have had to worry well-nigh inheritance or objects and classes upwards until this point. However sooner or afterward you'll need to learn how to read the documentation for another framework and implement it correctly. You may realize that your game logic isn't as squeamish or modular as it could be. Or you lot may realize that you didn't do plenty testing on i component of your software and now when you put everything together you can't figure out where the error is. You may even learn almost design patterns (gasp!), such every bit the observer pattern that most GUI's are based upon. Regardless, this is often a very challenging pace only a necessary i if y'all want to succeed as a developer. It'southward difficult to name fifty-fifty the most unproblematic of software that wasn't built without other frameworks. Minecraft was built upon the LWJGL (which is actually congenital upon OpenGL and OpenAL), 3d Sound System, and JOrbis frameworks. Namebench was built upon Python, Tkinter, PyObjC, dnspython, jinja2 and graphy. Bioshock was built upon UnrealEngine 2.5 and Havok Physics. You lot take to know how to make your code work with other code.

I'll also throw in one more than suggestion for making your Hangman game more exciting and fleshing out your skills-- try interfacing with a random discussion generator API to get a discussion before each game. For more information on using an API, see my tutorial hither.

Write (in your language of option) a simple 2D platformer

At present that you take the experience of writing simple game logic and the feel of working with a GUI framework y'all can move onto something more than personal. A elementary 2 dimensional platformer should have enough constraint and simplicity that you don't get overwhelmed and discouraged, but too enough flexibility to let yourself  to make this your project.

What if your end goal is to make a website? Or the side by side mobile app, or a search engine or a web crawler?Why a platformer game? Because programming games makes you lot think about writing practiced code. It forces you to think nigh the all-time data construction or the best algorithm. Game programming is not entirely different than programming for something else. If your game is running slowly you know your code isn't that swell. A unproblematic FPS (frames per second) counter allows you to continuously criterion your progress. And all-time of all, programming a game from scratch is a lot of fun.

Merely recollect, go along it simple! Start with really modest goals:

  • Create a stationary crimson foursquare and display it on the screen.

Once that is taken care of, try adding animation. Here y'all'll have to determine how your programming language or GUI framework deals with threads and blitheness. (Hint: If y'all're using Coffee y'all'll probably implement a Runnable.)

  • Have the ruddy foursquare move and bounce around on the screen.

Now once y'all take figured out basic blitheness you can add code so the red square responds to keyboard input. Hither you'll have to determine how your programming language or GUI framework deals with keyboard input. (Hint: If you're using Java y'all'll probably implement a KeyListener).

  • Instead of random bouncing movement, take the cherry square respond to keyboard buttons. (It moves up when the Upwards button is pressed, left when the Left button is pressed, etc).

Now pace dorsum and look at your lawmaking. Give yourself a pat on the back. Those three simple goals might not accept turned out to be so simple after all. The good news is that now yous tin start customizing your game. Permit's learn how to bargain with File I/O and manipulating PNG images.

  • Draw a small 20 by 10 pixel image and salve it as a .png file.
  • Take your game read in this image and display it instead of the ruby square.

If y'all are developing on a Windows machine, I would recommend using Pigment.cyberspace to depict the image instead of the Microsoft Paint that comes with every copy of Windows. I also recommend saving it equally a .png file because most programming languages have libraries that allow yous to manipulate .png files more easily (and especially on a per-pixel level which may exist very helpful down the road). Once you figured out how to read in and display a custom image, let's brand this platformer feel like a platformer:

  • Decide how y'all're going to shop and display the level.
  • Make the level.
  • Display the level.

What does this mean exactly? Well, a platformer game is composed of platforms. Your actor (the motion picture y'all only drew) will movement around and interact with this platform. Maybe in that location are death spikes somewhere on the platform, or peradventure just grass, or maybe there is snow. Regardless, you need to take a level that contains "blocks" or elements that the histrion interacts with. There are a couple ways of representing this level-- You could shop the entire map and go along runway of every single pixel, or y'all tin can suspension up your level into discrete elements (i.e. 1 block is v x v pixels). I adopt the latter approach considering information technology allows you lot to create levels speedily and reuse components. Here are ii ways of storing the level data:

The text file arroyo:

                          

The .png file approach (100% magnification):

The same .png file (at 400% magnification):

Detect that these two approaches contain the same sort of information. Either way you will have to write code that reads in a file (probably the .png or the .txt file), loops through the data, and builds the level. Hither'due south what the level looks like afterward information technology translates the 54 x forty chemical element level into a 638 ten 480 pixel game (each "element" is a 12 x 12 pixel cake).

As you can see this is quite a simple game which was the goal of the projection. One time you lot take figured out how to create, shop, and return out a level you can get-go having fun. Hither are some side by side steps (in no particular order) to exercise and develop your programming knowledge:

  • Create dissimilar blocks (a sticky block, death spikes, spawn points)
  • Try calculation gravity
  • Figure out how to implement collision detection
  • Add some other level. Determine how you lot will "load" levels or switch to the adjacent one. Does the "camera" follow along, or does the level change when you motion to the border of the screen?
  • Put a measurable metric such as a Frames Per Second (FPS) counter somewhere in your game. How will yous decide your frames per second?
  • Create different blocks (a sticky block, death spikes, spawn points)
  • Add other entities to the game such as enemies
  • Make your static graphics move. Animate your character walking effectually.

Once again these are just some ideas. I'll go out information technology up to you lot to figure out what you want your game to expect like and to ascertain your own goals. You'll apace realize that this simple game may non be so elementary afterwards all. Yous'll also beginning realize the advantages of object-oriented design, or maybe why Flash ActionScript is a popular programming language for developing games in (animations, collision detection, graphic manipulations are all very niggling to perform in ActionScript). Nevertheless all of these things will make you a more knowledgeable and skilled programmer in the end if you actually code them yourself.

As you lot struggle to make this "uncomplicated" game please realize that y'all are not lone. You will get stuck (and often). When I was working on this game and got stuck I gave myself a little break. Take a walk, get some coffee, surf the net. Some other practiced option is to see what the customs is up to. Peradventure someone else is making a very similar game and y'all tin can look to them for inspiration (Hint: Here is Minecraft Developer Notch'south simple platformer in Coffee, every bit well every bit his source code (.nix) (which he released openly for Ludam Dare)). Take a look at what others are doing and how they handled the problems that you lot are facing.

Join a community (ask questions and answer questions)

Whether you lot are taking a break from your programming project (and you should take breaks!) or you merely woke up and aren't quite fix for brain puzzles, a good center ground is a programming customs. Some suggestions are Stackoverflow, Reddit's /r/learnprogramming (for beginners), /r/programming (for advanced topics or news), or one of the many other communities that exist to bring people together and share noesis. The of import affair to remember as you struggle forth on your journey is that you are not lone. All of the questions that you have or problems that are volition come across have likely been brought up and discussed somewhere online. Have advantage of that!

Another perk of belonging in a programming community is that yous'll frequently discover new means or different approaches to tackling a problem. It also keeps possible solutions or technologies on your radar. Somewhere down the route you may accept to do some specific task and thank you to frequently skimming the Q & A' due south of a community forum you may accept already read people'southward past experiences, problems, and solutions.

It can also be said that by teaching or explaining something yous volition exist a better master of your craft. This is exactly why I started this website. The purpose of this website isn't just to teach you. My goal is to become a better author, communicator, and developer. If you can explain a concept to a consummate stranger in a concise fashion and have them walk away knowledgeable so you volition succeed in life. Your colleagues and friends will similar you more than. You will practice better in job interviews. Your boss will appreciate you more. Communication is incredibly important for only nearly any task, and programmers are mostly terrible at it. Take a look at some of the nigh successful scientists, engineers, and programmers of our time. Are they expert communicators? Yous bet and so.

Bring together a customs (such every bit a game competition)

Another community to look into are ane of the many game competitions that exist out at that place. Even if you have never made fully working software, a game, or an app before you lot probably know enough to make something. Even if your game is as elementary as a ii push button, poorly drawn animation loop, it'south still an awesome accomplishment (no offense to Shadow's game, I remember information technology's smashing).  Just remember, keep it simple. Some of the well-nigh successful games and software are often the simplest.

There are and then many reasons why you should enter and participate in a game competition. You'll learn a lot. You will go throughall of the stages of game/software development-- brainstorming, prototyping, creating, bug hunting, and publishing. Y'all'll get a lot of publicity. People volition actually play your game and give you feedback. And all-time of all, at the cease of it, yous can expect back and point to a completed project. Just how good does that feel? Reply: really good. Instead of talking nigh all of your good ideas, this volition actually forcefulness one out of yous.

If you're unsure of which ones to join, here are my suggestions: Ludam Cartel has an amazing community of fun, respectful, and sometimes famous developers (this competition can exist partly attributed to Minecraft developer Notch's online following). Ludam Dare also has really fun "I'k in" videos and hosts to kick off each competition. Some other competition worth checking out is the Java4K competition where participants try to develop a game in under 4 KB of Coffee lawmaking.

Notice and solve short programming problems

Another resource worth tapping are one of many websites that provide unproblematic programming bug. A website that immediately comes to listen is Projection Euler. On it there are some 350+ problems that brand for perfect piffling programming puzzles to piece of work through. They are organized from the virtually hands solved to the ones that few people accept solved. What I really constitute helpful was that you know when you solved the trouble. There's a box to input your judge and the website will tell yous whether yous got information technology correct or wrong. In one case y'all've proven your merit you volition exist presented with a forum to await at other people's solutions to see how it was solved in another language or perhaps with a novel algorithm or approach. Many of the initial problems tin be solved by beginner programmers with sloppy inefficient solutions, but every bit you progress you may realize that you brute force approach will get you the correct answer somewhen (but could take hours), forcing you to rethink your approach and create the optimal solution.

Other places to wait for programming problems and exercises are academic courses. Many informatics professors put upward all of the lectures, assignments, exams, and sometimes solutions on their course website allowing people from around the world to gain critical noesis without paying absurd tuition rates. Some institutions deliberately open up their course data for this reason-- MIT has curriculum available, and Stanford has a program also.

Take advantage of these resources. As mentioned at the superlative of this article, only past programming volition you gain programming cognition. Tackle complex problems, and at all times challenge yourself. Athletes don't stay in shape past taking a walk. Driving to work doesn't make you a professional person commuter. Replying to emails doesn't improve your typing skills. Good programmers don't get any better by writing code that they knowhow to write. Challenge yourself.

Books I plant helpful

And finally take a infinitesimal to think books. For many of us who are constantly reading blogs or accept gone to school and then long ago we may frequently forget that there is a plethora of textbooks available whose sole purpose is to teach usa and provide knowledge. In each field in that location are always the classics (such as Strunk and White's standard for English majors) and informatics is no exception. Many people will point to the widely regarded K & K book on C programming as required reading. For those in software development, a required reading often cited is Design Patterns written by the "Gang of 4". And for whatever reason, figurer scientists and programmers often reference Lewis Carroll's Alice in Wonderland equally well as Through the Looking Drinking glass, so it might be a adept fun volume to read before bed.

With those "required readings" out of the way I volition briefly mention two books that really bound started my journeying into programming. The first is Larry Ullman'south PHP half dozen and MySQL 5 for Dyanmic Websites which allowed me to create fun, useful, and interactive websites chop-chop. I had attempted to learn various other languages before picking up that book, but that was the first fourth dimension that I really felt like I was learning and creating. I believe that Larry Ullman has recently (summer 2011) written a 4th edition of his book which you may want to cheque out at too.

One time I had picked up the basics on programming I found an amazing Java volume that I used to swoop into the deeper aspects of programming. I believe that I am not alone in recommending Head First Java by Sierra and Bates (have a wait at the reviews as well). Though it may not exist ideal if you lot are only starting out (read my lessons learned as a beginner programmer here), it is definitely worth checking out after you know the nuts (which is what this article is aimed at).

Disclaimer: I receive a small percentage of the auction when you buy those books (or annihilation from Amazon for that matter) by following one of those links listed above. It doesn't increase the price for y'all, but it helps pay for this web hosting. Thanks!

Conclusion

I hope you lot plant this helpful! If you accept any tips or resources that you've used along the way delight share them in the comments. I hope you've noticed that I've deliberately left out advice on picking a programming language and but well-nigh all of my examples and resources are attainable in whichever language you lot want. For my reasoning behind that, you may desire to read my article reflecting on my journey into programming.