Skip to content

Key Points#

Programming is a fascinating field and even though we've only covered the basics here, what you've learned is useful and enables you to better understand how computers work. Going any further than this right now is a bit overkill. In the ITOps Level Two course we will eventually cover Python, a more advanced language, so you can do more advanced things. For now, however, Bash scripting is a good introduction.

Languages

We have a couple of key types of languages that we encounter in the wild. The primary two are compiled and interpreted. With a compiled language, we're translating the code to match a particular CPU architecture and then we run the binary. With an interpreted language, we write the code and then it's interpreted and made to run on the CPU in real-time.

A compiled language tends to offer quite big improvements in speed and security versus an interpreted language, because the code is compiled ahead of time and doesn't need to be translated before being executed.

But interpreted languages are faster to write code with, at the expense of speed. So, you can develop and iterate on an interpreted code base faster and easier, but the end result will never run as fast (but it will run fast enough in a lot of cases.)

Variables

Variables are how we store information in the system's RAM. They're temporary and are not persisted to the local disk or disks inside of the system. To do that we must write the information to a file.

A variable can contain all kinds of information, small and large. You can store a simple word in a variable or a 100GB high-resolution video file if you have enough RAM to do so (and even then, there are tricks to get around that.) You then use the variable later on to perform some operation on the data inside it.

Functions

When you've written some code, it's possible you might need to repeat that code over and over. Instead of copy/pasting the code multiple times, you write it into a function and call the function instead. This reduces the amount of work you must do overall.

Functions is a key component in programming. It's a must that you understand the idea, even if at a high level.

Flow Control

Sometimes you actually want to write code that just flows in a linear fashion, from top to bottom. Other times you need to branch the code in a different direction based on some logic. It could be that a variable contains a certain value or that a particular file exists on disk. Whatever the test is, using flow control allows us to change how the code behaves based on conditions.

You'll see flow control a lot and, in fact, will likely never see complex code that's free of flow control as it's mostly unavoidable.

Loops

Like functions, loops let us repeat some code over and over, but in a different sort of way. With a loop, we're looking to repeat some logic (code) based on some test that proves to be true, but eventually is false, breaking the loop and ending it (and moving onto the next instruction.)

Loops are ideal for going over lists of data and performing operations on it (which could be in functions you write.)

Input/Output

Writing code is mostly useless without data to work with. That's why we take input from users and produce output for them, and or other programs, to consume.

Taking an input can be done in several ways: via STDIN, via a prompt asking the user to provide some value, or by getting the data from a command line argument... and way more.

Output can be in a lot of different forms. We looked at JSON, which is useful for sending output to another program or even across the network to another computer.