¿Qué es programar?
Si nunca escribiste una línea de código, este es tu punto de partida. No hay nada que instalar y no necesitas saber nada previo.
What is programming?
If you have never written a line of code, this is your starting point. Nothing to install and no prior knowledge needed.
Programar es escribir instrucciones que un computador va a seguir al pie de la letra. Igual que una receta de cocina, pero para una máquina que no entiende nada por su cuenta.
Esa es la parte importante: el computador no piensa. Si le dices "revuelve", pregunta "¿qué revuelvo, con qué, cuántas veces?". Hay que decírselo todo, en orden y sin ambigüedades.
Una receta escrita para un humano dice:
Agrega tres huevos y revuelve hasta que quede suave.
Para un computador habría que decir: toma un huevo, rómpelo, échalo al bol; repite esto tres veces; ahora revuelve; mide qué tan suave está; si todavía no está suave, revuelve otra vez; repite hasta que lo esté.
Eso ya es un programa. Tiene repetición, tiene una condición, tiene pasos en orden. Solo falta escribirlo en un idioma que la máquina entienda.
Programming is writing instructions a computer will follow to the letter. Like a cooking recipe, but for a machine that understands nothing on its own.
That is the important part: the computer does not think. If you say "stir", it asks "stir what, with what, how many times?". You have to say everything, in order, with no ambiguity.
A recipe written for a human says:
Add three eggs and stir until smooth.
For a computer you would have to say: take one egg, crack it, put it in the bowl; repeat that three times; now stir; measure how smooth it is; if it is not smooth yet, stir again; repeat until it is.
That is already a program. It has repetition, it has a condition, it has ordered steps. All that is missing is writing it in a language the machine understands.
Vamos a escribir la instrucción más simple que existe: mostrar un mensaje.
Se hace con console.log(). Léelo como "muestra esto". Lo que pongas
entre paréntesis es lo que aparece.
El recuadro de abajo es real y está corriendo. Escribe tu nombre entre las comillas y míralo cambiar solo.
We are going to write the simplest instruction there is: show a message.
You do it with console.log(). Read it as "print this". Whatever you
put between the brackets is what shows up.
The box below is real and running. Type your name between the quotes and watch it change by itself.
Listo. Eso es programar. El resto son más instrucciones y formas de combinarlas.
Done. That is programming. Everything else is more instructions and ways of combining them.
Fíjate en algo. Estas dos líneas parecen casi iguales pero significan cosas distintas:
Notice something. These two lines look almost identical but mean different things:
Con comillas le dices "esto es un texto, muéstralo tal cual". Sin comillas le dices "esto es una operación, resuélvela".
Esa distinción entre texto y número te va a acompañar siempre, y es la fuente de la mitad de los errores de los principiantes.
Y lo que va después de // es un comentario: una nota para ti,
que el computador ignora por completo.
With quotes you say "this is text, show it as is". Without quotes you say "this is a calculation, work it out".
That distinction between text and number will follow you forever, and it causes half of all beginner mistakes.
And whatever comes after // is a comment: a note for you that
the computer ignores completely.
Esto es lo más importante de todo el tutorial, y casi nadie lo dice al principio: vas a equivocarte todo el tiempo, y está bien.
Programar no es escribir todo perfecto a la primera. Es escribir algo, ver que falla, entender por qué y arreglarlo. Los que llevan veinte años haciéndolo también se equivocan constantemente; solo aprendieron a leer los errores más rápido.
Mira qué pasa cuando algo está mal escrito:
This is the most important thing in the whole tutorial, and almost nobody says it up front: you will make mistakes constantly, and that is fine.
Programming is not writing everything perfectly first try. It is writing something, seeing it fail, understanding why and fixing it. People who have done this for twenty years also make mistakes constantly; they just learned to read the errors faster.
Look what happens when something is written wrong:
El mensaje rojo no es un reto ni un castigo: es el computador diciéndote dónde se perdió. Arréglalo: agrega la comilla que falta antes del paréntesis y mira cómo vuelve a funcionar.
The red message is not a scolding: it is the computer telling you where it got lost. Fix it: add the missing quote before the bracket and watch it work again.
Que programar es dar instrucciones exactas. Que console.log() muestra cosas.
Que las comillas separan el texto de los números. Que // escribe notas. Y que
los errores son parte del trabajo, no una señal de que no sirves para esto.
En el siguiente vemos qué lenguaje es este que acabas de escribir, y por qué elegimos ese y no Python.
That programming is giving exact instructions. That console.log() shows
things. That quotes separate text from numbers. That // writes notes. And that
errors are part of the job, not a sign that you are not cut out for this.
Next up: what language is this you just wrote, and why we picked it instead of Python.