A Quickly Guide to Programming

in #programming6 years ago

When a started my university career on Computer Science the first months a discovery something enlightening. Computers are the stupidest machines that a human has ever made. You need to put instructions inside it ,so that it does something. But not whatever instructions. You need to talk to it with zeros and ones.This is something tedious and a waste of time. So we created programming languages. And..What's a programming languages? Well, is pseudo languages half human half machine which is ruled by syntax , data structure, control flow , functions, modules and libraries.

Let's start with the syntax. A syntax is a series of rules that you need to follow inside the programming language for a good communication between you and the machine.If you violate these rules the programming languages will trow a 'Syntax Error'. That's mean you wrote a wrong syntax and you need to fix it.

In programming sometime you need to store some value that will be used later.We call this, variable. And...What's a variable?. Well, if you remember your algebra class.Something like this comes to your mind: 'If, a = 1 , and , b = 2, then , c = a+ b. What's the result?'. Variables store values( 1;'Hello World'; true) and they are called variables, because its value changes through time. So, in programming you are going to use variables to store something called 'data type'.

In programming we have different type of values.We have integers( number ), strings ( character ) , boolean ( true, false ) , arrays ( [value, value, ...] )and objects ( {key: value, key: value, ...} ). And we called this 'Data Structure' In some programming languages you can store functions like in JavaScript.These data types are slightly different across the programming languages.

So now, we know how to store values, but we need to give some logic to the computer. And for this we need to use something called 'control flow'. A control flow is a structure designed to make decision inside the instruction. And the mechanism to do that is named 'conditional'.

Assuming that we work 5 days a week and we wake up all this days at 5 o'clock.The rest of the days you don't need to wake up so early.Inside your brain is running the following code: If it's weekend I can wake up later, otherwise, I need to wake up early to go to work. This is a conditional. And we use it all the time on programming.

The following is the most used:

If, else:

    Ex. If (condition){

        ..do something  

    }else{ ..do something }
    
while:

    Ex. while(condition){

        ..do something

    }
    
for,do:

    Ex. for(i = 0 ; i > 10 ; i++){

        ..do something

    }
    
switch, case:

    Ex. switch(condition){

        case 1: ..do something
        case 2: ..do something
        ...
    }

An instruction is bit of code that the computer processes to do something. But if we want the computer open a file(or whatever you want) and write something inside it. We need to create a function and inside this function we need to write detailed instructions in such a way that the computer can execute it. And for that we use variables, data types and control flows. Also we need to know the keywords and functions of this programming languages.

A series of functions that perform related tasks are called modules and a series of modules that are related to each other, we call them libraries

So, this is a very very quick guide to programming.

I hope you have understood

If you think that this post is very useful , vote. If you think that isn't, leave a comment. I want to read your opinion.

PD:: My English level sucks.If you don't understand whatever I wrote in this post or you think it could be written better. Please Please Please....leave a comment. I need a feedback