Video: The basics to start programming
Let's start with what's necessary to get started in programming... what is programming?... what is a computer?... how is it structured?... what is an operating system?... the minimum prior knowledge before creating our programs.
# What is programming?
At a very high level, we can say that programming is giving orders to a computer, we tell it what we want it to do.
# I said "computer"... But what is that?
For a programmer, a computer is a box, where something goes in and something comes out, it has an input and an output. The task of this box is to transform the input into output.
Transformation of
Input into
Output
# But... how does it do it?
Suppose we have to do a calculation mentally... "2 + 3"
First we must remember the two numbers to add, 2 and 3, we memorize them. Now we look for a way to add them... as children we were taught that we can add by counting, we are going to use sticks:
- - 2 (two sticks) = | |
- - 3 (three sticks) = | | |
- - 2 + 3 = | | + | | | = | | | | | = 5 sticks
Gathering... first we memorize the numbers, we had to remember both, and then we perform the operation through a process, which consisted of counting the sticks... the addition process.
And the computer does this: it memorizes what enters, processes it, and returns the result.
So we
say that
the computer is a box that memorizes and processes to transform an input into an
output.
What enters, or the input, is called data and the result, or output, is called information.
Data is something we can measure, that represents nothing to us. The output is something that allows us to make decisions, that data is processed.
There are devices to enter data called input devices and others called output devices to show the results. There are also input/output devices, they do both.
So as programmers, that's it, memorize and process, and our programs are the ones that are going to tell how to do this transformation of input into output.
# And how do we give it orders?
For the machine to understand us we have to speak the same language, but the computer is made up of electronic circuits, it doesn't speak! it can only determine whether or not energy passes through each of its circuits.
ELECTRONIC CIRCUIT (ON/OFF)
BINARY SYSTEM (0/1)
If many of these circuits are put together, codes are formed, this is how 8-bit codes called bytes are created, like the ASCII code.
Equivalence
between
binary and character
But this is not just for data, processors also have codes to represent instructions. This is the first step in talking to the computer: machine language.
# The operating system
The operating system is the one that handles all the Hardware, handles the threads, and also allows interaction with the user. Basically, it makes everything work, hardware and software.
# Compiler and Interpreter
A language is high-level the closer it gets to humans and low-level the closer it gets to machine language.
Compiler
Generates an executable file before running the program. It detects errors in the compilation process.
Interpreter
Reads the code line by line and executes it. It finds errors as it executes.
Execution flow
difference
The case of Java is special: it's a compiled language but the compiler doesn't go towards the machine language that the operating system handles, but towards a virtual machine (JVM), which is the one that interacts with the operating system. That virtual machine is the one that ends up executing our code.
All these languages have similar things, however, there are different ways of writing code, according to the paradigms. Paradigms are: structured, object-oriented, and functional (some authors consider that there are more). Structured is the basis, the others add restrictions, as Robert Martin says in his book Clean Architecture, that's why structured is the first thing usually learned, the basic logic, the algorithms.
This is as far as we get with the basics to start programming. What we'll see next are algorithms in the next article, the writing of programming logic.