Programming - What's that? Can I do it?
What's a programming language?
A programming language is the language the developer uses to communicate with the computer.
There are a lot of programming languages :)
What happens to that language ?
Compiler VS Editor
The compiler converts your code into binary code allowing your computer to understand it.
The editor, like any editor allows you to write your code out of any development environment and compile it using, of course a compiler.
You might have heard about IDE, which means Integrated Development Environment, some good examples of that are Visual Studio and Eclipse.
Compiler VS Editor
I know the difference between a compiler and an editor
Can I be a programmer?
Sure you can!
There are kids as young as 6 yrs old programming :)
Programming is easier than you think, and you've been doing that all your life, just in a different way.
And you are a programmed as well!
What do I need to know?
- Why am I programmed?
- How do I've been programming all my life?
What's a program?
Before you start programming you need to know what a program is.
And a program isn't more than a set of logical instructions in the right order, written in a certain language.
You are programmed!
Imagine that your mom is a developer and you are the program she is creating.
She gives you a set of instructions in a logical way, right? If she is sane I think so!
Let me explain!
If I ask you to clean your room, my words are the code to program your brain, so as "computer", you understand what you have to do, which is get the room clean, and I get my "program" done, a clean room.
Got it? I hope so.
That's why you are programmed and have been programming all your life, because even teaching a new trick to your dog follows the same process of building an application, because you both "speak" different languages, but are working for the same goal, if your dog is smart and if your "code" is good.
So where do I start?
Well, when somebody wants to start programming, he needs to learn something called "Programming Logics", that's common to all the programming languages and you really need to get good at it before you chose any language to program.
But I'll help you with that, so you can teach your dog :)
Programming logic parts
- The Algorithm -- A set of instructions in the right order to accomplish a goal
- The conditional statements -- The instructions that allow you to follow a logical order of instructions
- The numeric operators -- These ones are pretty simple and you've learned them a long time ago, they are the ones from Maths as its name suggests
- The comparison operators -- These operators are used to compare one thing (value) to another
- Boolean operators -- They are just two, TRUE or FALSE, basically you use them to confirm of deny something
- Boolean statements -- These little words, or, and, not combined with the boolean operator help you checking if something is true, or false, or both things, well, that's confusing but we will get into that later.
What's a program?
A program, to the developer, is a problem that he has to solve to reach a certain goal, simple as that.
To the user, is a solution for his problem.
I think that's why in Visual Studio, a new project is called a Solution.
Programming Logics -- The Algorithm
- What's an Algorithm?
The Algorithm is a set of instructions in the right order to accomplish a goal, for example, the steps you take, to drink water, are an algorithm, take a look:
- Go to the kitchen
- Look for a glass
- Hold it under the tap
- Open the tap
- Close the tap
- Hold the glass to your mouth
- Drink it
Simple, isn't it? But I had to speak your language and give you the instructions in the right and logical way right?
What if I didn't? You wouldn't probably drink the water, so I had another problem instead of a solution.
When the algorithm goes wrong, it creates failed or buggy software.
If you want to learn how to program, you are almost there!
We are getting close.
So you need to know where to start and where to go to reach your goals
Programming Logics -- The conditional statements
Well, we've seen before that we need instructions to reach a goal, but we can do the same thing in many different ways right?
That's why there are logical conditions in the programming world, take a look:
- If -- If this happens, If this is the same
- Then -- If this happens Then do this
- Else -- If this and that doesn't work Then do this but if that fails Then do something Else
If the water is closed
then open it
else drink juice
Programming logics -- Comparison operators
The numeric operators are very useful, and I don't need to say that because you use them every day in your daily life, but I guess that you use the comparison ones much more, since you have to take decisions and compare values and situations, so let's take a look at it:
- >= Equal or greater than
- <= -- Equal or minor
- != -- different than
- == -- Equal to
>= Equal or greater than
Imagine that you have to feed 100 people, but you just have food for 20, in your mind what happens is this:
number of people >= food
if the number of people is == (equal) to the amount of food that's ok, we are done, but if it's > (greater), then we need to combine the numeric operators and the comparison ones to solve the problem, for example, we need to divide(/) the food in smaller parts.
Notice that the name of this operator is "Equal or Greater than", this "or" is very important, because you will use this operator just to know if your variable (we will come into that later) is one thing or another, never both (for that we have something else)
Equal or minor than
Ok, let's think about another situation, get yourself in the car, and let's travel.
So, you are on the highway and the speed limit for your vehicle is 190km/h, if you're exactly at that speed, what's wrong? nothing, but if you slow down, your speed is minor compared to the limit, so an equal or minor speed is more secure than an equal or greater one.
Well, that's confusing, let's take a look at what happens in your mind:
- my speed == speed limit -- if so, no problem
- my speed < speed limit -- that's ok, that's how it should be
- my speed > speed limit -- well, that's not a very good idea
See, even if you aren't that good at maths, you use it all the time
When you want to know if two or more things are equal, use the operator: == (equal to), represented by two equal signs without space.
my age == your age?
If my age != (different) your age then...
That's how it works, simple as that.
!= Different than
We use this operator when we want to know if two or more values are different and do something else if they are, or if they aren't, for example:
- if my age != your age then...
- if my age not != your age then...
and, or and not are boolean statements, they are used to check if something is true or false, as well as the boolean operators that we will discuss later.
Did you get the difference between the comparison operators ?
What the TRUE operator does is simply making a variable became true or check if it's true, take a look:
if your_dog == "lazy" then bad_owner = TRUE...
Well, you shouldn't really assign the value TRUE but we can talk about that later.
if not bad_owner then lazy_dog = FALSE
Did you get it?
Before we get to our first Algorithm
I want to tell you about something called variables.
Think of variables as boxes where you store objects, photos... like boxes, there are different types of variables, take a look:
- integers: the integer variables are exclusively integer numbers.
- boolean: this kind of variables holds just one of two values, True or False.
- characters: any character, numeric or not is ok, but just 1 character per variable
- floating-point numbers: like the name says, floating-point numbers
- alphanumeric strings: groups of numbers, letters and symbols
Learn how to solve your first algorithm!
- Programming - Let's do it!
Programming is an amazing art and will help you other than making money, solving many daily life issues, because programming is the art of solving problems, that's what we do!