Eposode 147: Functions

Comic Transcript

Panel 1.
Kodu: Once you have your start point and have initialized your variables, you enter the source code for what you want the program to do.
Laby: Kodu, you think you are so smart! What about functions to break up the code?

Panel 2.
Baltie: They are smaller sections of computer instructions, aren’t they?
Kodu: Hey, I am the one explaining computer programming…

Panel 3.
Kodu: Functions are separated chunks of computer code that are written in such a way that they can be used again without repeating the code.
Ludd: Programming doesn’t sound hard.

Panel 4.
Alkina: It isn’t, once you learn the rules of the programming language. And programming languages share many similarities that allow a programmer who understands one language to understand another even if they cannot write complete programs in it.

Panel 5.
Laby: Alkina, how much longer for Epo to fix the navigation system?

What does it mean?

Source code – the set of computer instructions that makes up computer programs.

(Computer) Function – small sections of computer instructions that perform a particular task. Source code is broken up into functions so that programs can easily use the same code over and over without having to enter that code into the program many times.

Programming language – Just as there are many human languages, computers also have many different languages, and each language has its own rules that a computer programmer must know and understand in order to write programs in that language.

In human speak please!

A complex computer program may be able to do many things, and it usually jumps between them. For example, a calculator program may need to add numbers given to it by the user in one instance, and multiply them in another. It needs to be able to repeat these operations without the user having to restart the program. That is what makes functions so useful. The program can take two number inputs and an operation from the user and pass them to another function that either multiplies or adds them depending on the operation chosen by the user. The next episode of Epo’s Chronicles will show an example of what this might look like in computer code.