how to program
HOW TO PROGRAM . IT - learn how to program - online interactive programming tutorial and programming course
Hello World

Lesson 01: Hello World is the first program that every programmer beginner learns to program. The idea behind this program is to get the student familiar with writing a program that can output something visible that can be seen right from the start. This will be useful in future lessons, and it is especially useful to know how to tell a program to output information to you when you are trying to fix a faulty program.

The following code demonstrates a hello world program, to run it, click on the "Run Program" button at the bottom right of the code window. The program, when run, should provide some output to the "Output Window" underneath ...

Program Code:

The first line, starting with // is a comment line where any text can be added as a way for the programmer to document and comment on the program. Comments are not part of the program in that those comment lines are ignored and not run.

In this example the second line is the actual program line that gets run, and the program overall consists of one statement, the env.out( "Hello World" ); statement. env.out is a function (more precisely an object method or function) which accepts a string as its input or parameter value, that is what goes inside the function's ( ) brackets.

Although this is the first program most people write, it doesn't do much in the way of teach the core programming language, since it deals with output, and the output functionality is generally part of the programming or target environment rather that the core language. The 3 visible components of the hello world program are:

// send the... comment Core Programming Language
"Hello World" string literal Core Programming Language
env.out output functionality Auxiliary Programming Environment

   central core language and auxiliary language environment
So only the first 2 are core to the programming language and core concepts to learning to program (the central area in the diagram). The 3rd part, the output function, is not core to the programming language but particular to the programming environment/platform (the outer area in the diagram), and as such it will probably be different in every programming environment/platform you develop for, be it Windows, web page, web server side, Flash, mobile phones etc. This site is mainly focused on teaching core programming skills, so you get a deep understanding of what is common to most environments. env.out is a function specific to this site's programming environment only (where env is short for environment).

Output functions will be different depending upon your programming environment. If you are programming server-side pages (writing programs that run on your server) on your website then there is no screen you can output to on your server, instead you might send output to the client browser (e.g. using echo in PHP, or response.write in ASP.NET). If you are programming for the client side browser environment using JavaScript, then the output function might be document.write. If you are programming for event driven windows based graphical environment, then the output might be very different again. You might also want to write programs that have no output (e.g. overnight processing programs), in this case you might only output text to log files.

Suffice to say that with the lessons on this site, we wont get into the intricacies of various programming environments, in order that we can focus on core programming language concepts.


1. Change the "Hello World" to some other text like "Hello Everybody!", and run program
2. Instead of 1 line of output, get it to output 2 lines. To do this you will need another line of code after the first env.out line, a copy and paste of the env.out line but with a different message

To return to previous page click here

by running the tutorial programs on this site, you are agreeing to our terms and conditions (please check these first).
Tue 20 Oct 2020 web design | login © 2020 Abstract Worlds Ltd