Beginning Programming

From eLinux.org
Revision as of 18:51, 7 February 2013 by Tim Bird (talk | contribs) (Languages)
Jump to: navigation, search

This page is intended to help beginners get started with learning programming. Eventually, I'd like to provide a whole series of steps, exercises and tutorials about programming, to help anyone who would like to get involved with software development or game development.

Programming toolkits

"Questions Tips & Feedback Spin-Offs Documentation". "Spin-Offs" has sample programs related to the tutorial, video or program you're looking at, and "Documentation" has description of different functions or statements you can use in your programs.

Programming checklist

Follow these steps to learn how to program:

The very basics

  • learn what a program statement is (and what a "computer language" is)
  • learn what a variable is
  • learn what a conditional (if statement) is
  • learn what a loop is
  • learn what input is
    • different kinds of input (key press, mouse move, mouse button)
  • learn what output is
    • different kinds of output (text, image, sound)

Simple program 1: Write a program that counts how many times someone presses the space bar.

Simple program 2: Write a program that counts how many times someone presses each arrow key.

program 3: Write a program that starts counting when someone presses the space bar, and stops counting when they hit it a second time (like a stop-watch).

Program 4: Write a program that moves a ball to the right on the screen, when the right arrow is pressed.

Program 5: Write a program that starts a ball moving when key is pressed. The ball should keep moving until it hits a wall.

Note: For any of these programs, you can start with the program you used previously, and expand or modify it to do the next task. You should save it under a new name.

Program 6: Write a program that starts a ball moving in a different direction, depending on which arrow key (up, down, left, right) is pressed.

Program 7: Write a program that starts with a moving ball. When the ball hits a wall, it moves in the opposite direction.

Program 8: Combine programs 6 and 7. Write a program that starts a ball in a direction based on the key pressed. The ball should keep moving after the key is released. It should bounce off the wall and go the other direction when it hits a wall.

Languages

Programming can be done in many different computer languages.

Web Programming

Programming can be done in a web browser. This is a computer program, like Internet Explorer, Firefox or Chrome, that reads web pages from the Internet and shows them on your screen. Embedded devices, like phones, tablets and TVs also have web browsers.

In order to do web programming, you first need to learn how the browser presents information from a web page on your computer screen. It does this by processing the words on the web page (called "parsing" the page), and then drawing things like text, lines and images on your computer screen (usually, inside the browser window).

HTML

The words on a web page are part of a language called HTML (HyperText Markup Language). You can learn about this language here: http://www.w3schools.com/html/default.asp

Basically, the words and symbols are put into a file (or returned from a program running on the web server), and these words tell the web browser what to draw on the screen. The process of drawing things on the screen is called "rendering" the page.

Scratch

Here is a tutorial for a bouncing ball demo in scratch: http://scratch-time.blogspot.com/2008/12/how-to-make-bouncing-ball.html

Javascript

Here is a tutorial for a bouncing ball demo in Javascript: http://sixrevisions.com/html/bouncing-a-ball-around-with-html5-and-javascript/

Before you understand this language, and how it works, you first have to understand HTML.

Python (with PyGame)

Here is an introduction to pygame, which has an bouncing ball demo as part of the intro.

http://www.pygame.org/docs/tut/intro/intro.html