Stop talking in codes, stop talking in codes. Let me know what's up, can't do it no more.
In this tutorial I'll explain programming from the beginning.
I'll start explaining some concepts about how computers work. I think this is important to better understand how programs work.
More than anything I wanna fly in strange machines.
Computers are everywhere. They're not just PCs or Macs. Any fairly complex machine has a computer inside. Mobile phones, calculators, electronic watches, TVs. Cars and other vehicles are also equipped with computers. Some ovens, fridges and other home appliance also run computers inside.
A computer might be really simple but, for our purposes, it's anything with at least two components: a processor and memory.
The memory is used to store programs and data used/generated by those programs. The processor (CPU) is a chip that can run programs. So, the processor reads a program stored in the memory and executes it. When a program is running, it may read/write things in memory. We'll learn more about this later on.
Computers usually contain two kinds of memory. One is called RAM and the other is usually the Hard Drive (HD). RAM is faster than the HD, but it's cleared when the computer is switched off. The HD keeps data even when the computer is off.
Programs and other files (like documents, pics and songs) are stored in the HD, otherwise you would lose them every time you switch off your computer. When a program is executed, it's copied to the RAM, so it can be executed faster. Then, a program may read/write things in RAM, usually things that the program only needs when it is executing. A program can also read/write things in the HD, especially when the program needs to create files that should persist even after the program is closed.
In order to work with a computer, you will also need some kind of input and output devices. At least, you will hook up a keyboard (input), a mouse (input) and a display (output), unless they are already integrated in the computer (like in laptops).
So, devices are usually input or output devices (or both at the same time). In this tutorial we will only use the keyboard to write our programs and input things to the program, and the display to see the output of our programs. But programs can also "talk" with many other devices like printers (out), scanners (in), speakers (out), microphones (in), etc.
A program is a file (or a bunch of files) stored on your HD. A program contains a list of instructions that the processor can perform.
When you run a program, it's copied from the HD to the RAM and then the processor reads its instructions and executes them one by one, religiously doing anything that the instructions say.
When you're writing a program you're writing those instructions. You should be careful because the processor will follow those instructions exactly as you write them, even when they contain mistakes or make no sense. Don't worry, you won't be able to do anything dangerous (unless you tell the computer to delete files, but we won't do that in this tutorial).
// Java program System.out.println("Hello there!");
A program may have multiple instructions (instructions are also known as statements). When a program is executed, the computer (the processor) will perform the instructions one by one.
There are a few kinds of instructions/statements. Not many, actually. The following list could be fairly approximated
For now, we'll focus on the first three. We have already seen an example of the third one, a function call.