Reading code

2/13
Recursos
Transcripción

Como programadores o programadoras nos enfrentamos a distintas maneras de escribir código fuente dependiendo el lenguaje de preferencia. Cada uno tiene sus particularidades y su propia sintaxis. Veamos todo lo relacionado con el código fuente en inglés.

Descripción del código

En el mundo de la programación existen muchos símbolos o caracteres especiales que se utilizan a la hora de escribir código fuente. Es muy importante conocer sus nombres en Inglés para leer el código correctamente.

Caracteres especiales

Cada carácter especial significa algo distinto en un lenguaje u otro. Aprender sus nombres en inglés.

  • Spaces or Tabs: Indent/Indentation
  • ( ) Parentheses
  • { } Curly Brackets, curly braces
  • [ ] Square Brackets
  • ‘ ’ Single quotes
  • “ ” Double quotes, typographic or curly quotes in text
  • ` ` Backquotes, Backtick
  • . Point (numbers, versions). Dot (domain names, object notation), Period (finishing paragraph)
  • , Comma
  • : Colon
  • ; Semicolon
  • + Plus
  • - Minus
  • * Asterisk, times
  • / Division, slash
  • \ Backslash
  • = Equal
  • == Doble equal
  • | Pipe
  • - Hyphen dash
  • N Dash
  • M Dash
  • _ Underscore
  • ~ Tilde
  • ! Bang, exclamation sign
  • @ At sign
  • # Hash
  • ^ Caret
  • $ Dollar sign
  • % Percent
  • & Ampersand

Estilos de escritura

Existen diferentes formas de escribir el nombre de una variable o función. Cada lenguaje suele tener estandarizado cómo hacerlo.

  • foobar, foo, bar, baz: Frecuentemente empleadas estas palabras cuando no se sabe qué nombre ponerle a una variable. Se utilizan como nombres genéricos.
  • flatcase: myvariable
  • camelCase: myVariable
  • snake_case: my_variable
  • kebab-case: my-variable

Lectura de código

Veamos dos maneras de leer código fuente:

if (a >= b) {
  console.log("A es mayor o igual que B");
} else {
  console.log("A es menor que B");
}

Comencemos por la lectura lógica del código fuente:

If A is greater than or equal to B then log inside will be “A es mayor o igual que B”. Otherwise, the log inside will be “A es menor que B”.

Puede ocurrir que tengas que ayudar a alguien a escribir el código, en ese caso deberás hacer una descripción de la sintaxis del mismo:

If, open parentheses, A greater equal B, close parentheses, open bracket, console dot log, open parentheses, open double quotes, text, close double quotes, close parentheses, semicolon, close bracket, else, open bracket, console dot log, open parentheses, open double quotes, text, close double quotes, close parentheses, semicolon, close bracket.

Se vuelve bastante exhaustiva la descripción del código. Puedes obviar el cierre de los paréntesis o brackets para simplificar la explicación. De ahí la importancia de conocer el nombre de los símbolos y caracteres especiales en inglés.

Practicar la lectura de código fuente va a ser muy importante para prepararte en el trabajo con equipos cuyo idioma principal sea el inglés.


Contribución creada por Kevin Fiorentino, con aportes de Leví Arista Sánchez.

Aportes 82

Preguntas 3

Ordenar por:

¿Quieres ver más aportes, preguntas y respuestas de la comunidad?

Reading Code

Element Description
spaces or tabs Indentation
( ) Parentheses
{ } Curly Brackets, curly braces
[ ] Square Brackets
’ ’ Single quotes
" " Double quotes, typographic or curly quotes in text
`` Backquotes, Backtick
. point(numbers, versions), dot (domain names, object notation), period (finishing paragraph)
, comma
: colon
; semicolon
+ plus
- minus
* asterisk, times
/ division
- hyphendash (normal, n-dash, m, dash; also for spaces)
_ underscore
~ tilde
! bang, exclamation sign
@ at sign
# hash
^ caret
$ dollar sign (useful for PHP)
% percent (useful for module operation)
\ backslash (useful for paths in Windows)
& ampersand ((and, per se))
foo, bar, baz placeholders
flatcase myvariable
camelCase myVariable
snake_case my_variable
kebab-case my-variable

( ) 👉🏼 Parentheses
{ } 👉🏼 Curly Brackets
[ ] 👉🏼 Square Brackets

Here are my recordings:

for i in range(1, num+1):
            if num % i == 0:
                divisors.append(i)
        return divisors

Reading the logic
Reading the syntax

2. Reading Code

You can read this piece of code in two different ways:

Reading the logic:
In this case, use mostly English words, ignore most of the symbols. You can even swap the order of terms. For example: If the X coordinate is less than the width of the box, then log inside. Otherwise, put an alert saying “error”.

Reading the syntax, indentation, and symbols (if you’re helping somebody write this code):
In that case, be careful and include every single symbol. For instance: If, open parenthesis, coordinate dot x, less or equal than, box dot width, close parenthesis, open curly bracket. Indent, console dot log, open parenthesis, open quote, inside, end quote, end parenthesis, end curly bracket. Else, open curly bracket, alert open parenthesis, open quote, error, end quote, end parenthesis, end curly bracket.
With practice you can skip some of these words. You don’t need to say all the open bracket, open parenthesis, and open and end quote. You can say: console dot log, string inside alert, string error.
But be very careful with which words you use to descript those specific terms.

Symbols:
Space 👉🏼 Indent/indentation
People like code that´s clean and easy to read, because it has been well indented to show the blocks of code.
People don’t agree as to whether to use tabs or spaces or how many tabs to use.
Some people use two spaces, tabs or four spaces.

( ) 👉🏼 Parentheses
{ } 👉🏼 Curly Brackets / braces
[ ] 👉🏼 Square Brackets
‘ ’ 👉🏼 Single quote
“ “ 👉🏼 double or vertical quote
👉🏼 back quote
“ ” 👉🏼 typographic or curly quotes. Used to make your text look nicer, but normally vertical quotes are used when programming.
If you work in front end you may have a designer that asks you to please use curly quotes in the text. Not in the code but in the text.

, 👉🏼 comma
👉🏼 colon
; 👉🏼 semicolon
0 👉🏼 zero / oh!
1.75 = when using numbers: point
console.log 👉🏼when it comes to electronic things: dot
The text. 👉🏼 when it comes to texts: period
  • 👉🏼 plus
  • 👉🏼 minus
  • 👉🏼 asterisk / denotes multiplication / often called times
    / 👉🏼slash / denotes division
  • 👉🏼 dash
    _ 👉🏼 underscore
    Again, if you work in front end, your designer friends will point out that those are not the only two options.

Regular dash, en dash, and em dash.
There’s also en space and em space.
~ 👉🏼 tilde
! 👉🏼 exclamation point or mark
@ 👉🏼 at sign

👉🏼 hash or pound

^ 👉🏼 caret /ˈkærət/, which denotes special logical operations like “or”. Or to know the control keys in a keyboard. Yep! It´s pronounced like carrot /ˈkærət/
& 👉🏼ampersand

Names of things in your code:
Variables, functions, methods.

Foobar, foo, bar, baz: English words that make no sense, programmers have been using these words to denote variables that have no particular name. They’re used for temporary variables, example names or things like that. So, if you see them don’t try to make any sense of them, they’re just made-up words.

Variables that describe a term that has two words:
flatcase 👉🏼 together and keep them lower case
camelCase 👉🏼 together and the 2nd word has initial upper case. Javascript uses it.
snake_case 👉🏼 together with an underscore in between them. Ruby and file names (in UNIX and many other places) tend to use it.
kebab-case 👉🏼 together with a hyphen in between them. They look like a skewer or stick in a Shish Kebab.

~ tilde
! bang
@ at sign
# hash
^ caret

En Python se usa mucho rodear una palabra de doble underscore. Se pronuncia ‘Dunder’

__x__ == Dunder 'x’
Ejemplo __init__ == Dunder Init

Ways to write a variable or function:
flatcase: myvariable
camelCase: myVariable
snake_case: my_variable
kebad-case: my-variable
I would add the PascalCase: MyVariable.

^ This symbol is called caret (When I heard the teacher I thought he said carrot 🥕)

👉🏼 indent 

. 👉🏼 period
, 👉🏼 comma
: 👉🏼 colon
; 👉🏼 semicolom
platzi . com 👉🏼 platziDotCom

  • 👉🏼 dash
  • 👉🏼 underscore

A few thoughts about the indentation

Python uses 4 spaces for indent


There is a lot of controversy around whether to use tabs or spaces. I think it depends a lot on the standards of the specific language you are using if there are any. In python, there is the PEP-8 which is meant to be a style guide to writing uniform and easy to read Python code and there it says that 4 spaces must be used for indentation:

https://peps.python.org/pep-0008/#indentation

This doesn’t mean that 4 spaces must always be used everywhere for any language. For example (from the same PEP-8) “Hanging indents may be indented to other than 4 spaces.”

Other languages will have a different standard or no standard at all. But if you come from Python and put effort into following the PEP-8 it is likely that by default you will use 4 spaces, and that’s okay, it is like the pronunciation problems that we have with English; it’s just that we learned by reading and writing.

What is really important


What is really important is

  1. That your code works. In Python, it won’t work if you indent nothing.
  2. That your code is legible. Even if languages like JavaScript and C++ do not need indent, it helps a lot in reading the code (for humans) and will add a lot of value to your code.
  3. To be consistent. If you enter a team that uses spaces, then you will need to use spaces, if the whole team uses tabs, then you will need to use tabs, if you start a project using an indent of 2 spaces you should do it for the whole project.

> greater than
< smaller than
>= greater or equal than
<= smaller or equal than

| pipe symbol
$ dollar sign (useful for PHP)
% percent (useful for module operation)
\ backslash (useful for paths in Windows)

(Para los {}, usar braces y para [] se usa brackets) : pero siempre es mejor usar el curlybrackets o squarebrackets .

  • Otherwise: else: (de otra manera)
  • dot: punto
  • bracket: corchetes (Open brackets / close brackets)
  • Indent / indentation: Identación / espacio(s) -> (spaces or tabs)
  • blocks of code: Bloques de código
  • (): Parenthesis / Parens -> (open parens/ end parens / close parents)
  • {}: Curly braces / curly brackets -> (Corchetes)
  • []: Square brackets: (Corchetes cuadrados)
  • ': quote (single quote) -> (comilla sencilla)
  • ": double quotes: (comillas dobles)
  • ´: back quote: _(comilla inversa): -> (usado para escapar caracteres)
  • “": courly quotes: (cuando las comillas son diferentes de open y de close) -> (usado en front para frases cool)
  • .: period / dot / point(numbers): (punto) -> (cuando hay .0, se usa decir (point o, NO: point zero))
  • ,: comma: (coma)
  • :: colon: (dos puntos)
  • ;: semicolon: (punto y coma)
  • +: plus
  • -: minus(number) / dash(regular das / n dash / m dash) (mainus)
  • *: asteriscs / times -> (multiplicación)
  • /: slash -> (Division)
  • __ _ __: underscore: Guión al piso.
  • ~: tilde
  • !: bang / exclamation sign
  • @: at sign -> (arroba)
  • #: hash (NO hastag)
  • ^: pound (nombre original: Octothorpe)
<h5>Variables raras y sin uso especifico:</h5>
  • foobar
  • foo
  • bar
  • baz

formas de escritura en el código:

  • flatcase
  • camelCase
  • snake_case
  • kebab-case

I prefer to be wrong and use 4 spaces as indentation 😛

Indent
Is the space you leave the start of a line of code. You can use space or tab.
Some languages like Python are very sensitive to this.
🔥
Parenthesis ( ), or sometimes parents
You always just say “open parents and end parents”
🔥
Curly braces or Curly brackets { }
🔥
Square brackets [ ]
🔥
Quotes
Single quote: ’ '
Double quotes: " "
Back quote:
Typographic quote or curly quotes: “ ”
🔥
Common characters
(.)
Period: at the end of a sentence.
Dot: use it in object notation
Point: in decimal numbers or version numbers
🔥
(+) Plus
(-) Minus
(*) Asterisk: which denotes multiplication. Often called “times”
(/) Slash: denotes division
(-) Dash or hyphen (when is used between two words)
(_) Underscore
(-) Regular dash
(–) n dash
(—) m dash
(~) Tilde
(!) Exclamation sign, also called “bang”
(@) At sign
(#) Hash, also called “pound”
(^) Caret
(&) Ampersand
🔥
Ways to write a variable
flatcase
camelCase: JavaScript uses "Camel Case"
snake_case: Ruby uses “Snake Case” often
kebab-case: often doesn’t work as a variable.

those people that use 4 spaces are wrong 😂

OK, I just put this in the .vimrc so as not to be wrong

set tabstop=2

` Is also called backtick

I’m loving this course, I needed a lot!

Wow, very interesting class, I never have taken an English class in PEA, at least this one, I think is so important for everyone is in software development. Thank you so much to the teacher

El video y el sonido de la voz no van sincronizados !

uuff, excellent! ❤️

Hi! I am very grateful with your explanation teacher and here I leave the work I did for this lesson (this is a piece of code made in C++ language).

	if(Valor>=0.0 && Valor<=5.0){
		suma = suma + Valor;
		Nnotas++;
		}
		else{
			cout<<"Error::::Nota fuera de rango, digite nuevamente"<<endl;
		}

Reading logic
Reading the syntax

Reading Code

Indent → The space between the start of line and the code. You can use tab or spaces.

if age >= 18:
	print("Old enough!")
else:
	print("Too young!")

  • Parenthesis → ()
  • Curly braces or curly brackets → {}
  • Square brackets → []

Quotes

  • Single → ‘’
  • Double → “”
  • Back quote → ``
  • Typography Quotes (maybe same as double)

Periods and semicolons

  • Period or Dot → .
  • Comma → ,
  • Colon → :
  • Semicolon → ;

Symbols

  • Plus → +
  • Minus → -
  • Times or Asterisk → *
  • Slash or note division → /
  • Dash → -
  • Underscore → _
  • Tilde → ~
  • Exclamation sign or bang → !
  • At sign → @
  • Hash or pound → #
  • Caret → ^
  • Ampersand → &

Ways to name variables:

  • flatcase
  • camelCase (used in JavaScript)
  • snake_case (used in Ruby, Python and unix)
  • kebab-case (used in node modules)

hahaha, here comes the wrong people: “four spaces are better because this and that…!”

No subtitles 👀👀👀👀👀

Notes:

  • Indent: the space at the start in a line of code

  • We use two spaces or the tab key

-there are differences between:

( ) 👉🏼 Parentheses
{ } 👉🏼 Curly Brackets
[ ] 👉🏼 Square Brackets

Curly: Ondulado

Quotes:
’ ’ 👉🏼 single quotes
" " 👉🏼 double quotes
👉🏼 back quote
" "👉🏼 curly quotes 👉🏼 to make the text cool 😎

putuation:
. 👉🏼 period
,👉🏼 coma
:👉🏼 column
;👉🏼 semi-column

period ways:
decimals: POINT
1.0 it’s like one POINT zero or O 😎

Notation: DOT
console DOT log
platzi DOT com

end sentence -> period

  • _ dash , underscored

~ tilde
! exclamation sign
@ ad sign

hash

^ caret

& ampersand

flatcase
camelCase
snake_case
kebab-case javaScript node modules 👀

También está:

  • “>” : Greater / Greater than
  • “<” : Smaller / Smaller than

Hi Sebastián, I think you forgot to mention PascalCase

Siii exacto! pero el IDE al poner tab para proceguir te adelanta como 4 espacios y uno por esa mala practica de apretar TAB para no corregir los espacios lo deja asi como esta. EL IDE tendria que corregir eso. de seguro ya habra algunos que lo hacen pero en mi caso con VSC no me sucede

Hey, here is my recording, lemme know any feedback that you have
My recording

Class Summary Number 2

So:

  • Weird people: use tabs.
  • Normal people: use spaces.

in short:
1.) If I put them together and just keep them lower case, is called “flatcase”
2.) If I put them together and take the first letter of the second Word an make it uppercase, is called: “camelCase” because there is a bum in the variable name.
3.) If I put them together whith an undesrcore it is called “snake case”
4.) If I put them together and use a dash in between them o a hyphen it is calle “kebab-case”

Number zero could sound like ‘ou’ because native speakers say the vowel ‘O’ instead zero

"What normal people should do"

It would be great if the classes had reactions with emotions, that way I could express how grateful I am with this class.

void uart_printf(char *string)
{
    while(*string != 0x00)
    {
        uart_send(*string);
        string++;
    }
} 

lectura lógica
escritura de código

Wow, It was hard for me to remember the names of some symbols in English. From today every code I write I will read it out loud in English😅

https://voca.ro/1gPVxnMaJkMV

def getTotalDebts():
    totalTotalDeb = 0
    monthly = 0
    for i in range (0, len(debts)):
        if debts[i].active:
            totalTotalDeb += debts[i].totalAmount.amount
            monthly += debts[i].monthlyPayment.amount
            print(debts[i])
    return totalTotalDeb, monthly
**symbols and their names**: * **Spaces**: Indentation (spaces or tabs) makes code more readable. Some languages like Python require precise indentation. * The debate: Some people use **two spaces**, others use **tabs and four spaces**. While two spaces is generally preferred, it's up to personal choice. * **Parentheses and brackets**: * **Parentheses**: *open parenthesis* and *close parenthesis*. * **Curly brackets/braces**: Use "curly brackets" for { } and "square brackets" for \[ ]. * **Quotes**: * **Single quotes (' ')**, **double quotes (" ")**, and **back quotes ( )** are common in code. * **Curly quotes**: These are mainly used for better text appearance in design, not in programming. ### **Punctuation in code** * **Period/dot (.)**: * Used for decimal points (*1.75*) or version numbers (*1.0*). * In object notation, it’s called a **dot** (e.g., *console dot log*). * For domain names, say *dot com* (*Platzi dot com*), not *point* or *period*. * **Plus (+), minus (-), asterisk (\*), slash (/)**: * These represent common arithmetic operations: addition, subtraction, multiplication, and division. * **Dash and underscore**: * **Dash (-)** and **underscore (\_)** are used differently depending on the context. Designers may also use an **en dash** or **em dash**, which vary in length. ### **Special characters on the keyboard** * **Tilde (~)**: Used in various programming contexts. * **Exclamation mark (!)**: Also called *bang*. * **At sign (@)**: Used in email addresses. * **Hash (#)**: Called *hash*, not *hashtag* (unless it's part of a social media tag). * **Caret (^)**: Used for logical operations or control keys. * **Ampersand (&)**: Combines *and* with its Latin origin, *per se*. ### **Naming conventions in code** 1. **Foobar**: Frequently used as placeholder names for variables that don’t have a specific name. For example: *foo*, *bar*, and *baz*. 2. **Variable naming conventions**: * **Flat case**: all lowercase letters (e.g., *username*). * **Camel case**: the first letter of the second word is capitalized (e.g., *userName*). This is common in JavaScript. * **Snake case**: words are separated by underscores (e.g., *user\_name*). Used in Ruby and Unix. * **Kebab case**: words are separated by hyphens (e.g., *user-name*). Common in file names and JavaScript modules. ### **Practice and challenge** Reading code aloud helps you become more familiar with both logic and syntax. Here's a challenge: * Find a piece of code you’ve written. * Record yourself reading it aloud in two ways: 1. **Reading for logic**: Focus on explaining what the code does. 2. **Reading for syntax**: Mention every symbol and detail. * Share your recording in the comments to discuss with others.
"Whatever you want. You're free to be wrong"
Nice
Normal people?? LOL
en i dont speak english, but im understand
Good night: I have created this set of puzzles for learning non usual business English terms: <https://inglesavanzado.s3.us-east-2.amazonaws.com/index.html> I took the courses on Javascript, Html, Gamification and others before developing these puzzles, of course I took these courses in Platzi. Take a look at them.
~ Tilde
! Exclamation sign
@ At sign
# Hash (only hash) or Octothorpe
^ Caret

This an awesome class and the cuorse just started, I can’t wait to see everything

en todas estas que significa ese codigo :V
USA . = Stop period United Kingdom . = full stop
<function llenarVariables(){
  var operador;
  var num1;
  var num2;
  num1 = prompt('Ingrese el primer numero a operar:','');
  num1 = Number(num1);
  num2 = prompt('Ingrese el segundo numero a operar:','');
  num2 = Number(num2);
  operador = prompt('¿Que operacion desea realizar?','');
  operar(operador,num1,num2);
}

function operar(operador,num1,num2){
  var resultado;
switch(operador){
  case 'suma':
    resultado=num1+num2;
    break;
  case 'resta':
    resultado=num1-num2;
    break;
  case 'multiplicacion':
    resultado=num1*num2;
    break;
  case 'division':
    resultado=num1/num2;
    break;
  default:
   console.log('lo sentimos, no has escogido una opcion valida') ;
}
  console.log('El resultado de su ',operador,' es: ',resultado)
}
llenarVariables();> 

https://voca.ro/1fz99tp8tZcq

I very happy whit this course, very important !!!

I prefer to be wrong and use tab as indentation 😛

https://voca.ro/1iOHtPm25VNK

If you want, you can give me a feedback please


    def render_food(state)
      @food.remove if @food
      extend Ruby2D::DSL
      food = state.food
      @food = Square.new(
        x: food.col * @pixel_size,
        y: food.row * @pixel_size,
        color: 'yellow'
      )
    end

I learned so much Indent using the preprocessor .pug

Here my reading

function agregarNuevaIniciativa(iniciativa, modo){
     
        var arrayIniciativas = self.getIniciativas();
      
        arrayIniciativas.push(iniciativa);
     
        crearTablaIniciativas(arrayIniciativas, '#divListarIniciativas', modo);
 }

[The logic] (https://voca.ro/1l0bLCP2KR7j)
THe Sintax

flatcase posicionarlas en minusculas
camelCase juntas con la primera letra de la segunda palabra en mayuscula
snake_case separar por un guion
Kebab-case

I would like to add
SCREAMING_SNAKE_CASE
Used for constants in Java 😎
It’s like snake case but all in uppercase

mi hermana si me pegaba unas regañadas por el point y el Dot, ajajjjaja ahora entiendo que yo estaba equivocado. lo peor es que al momento de deletrearlo, lo termine escribiendo “date”, ajajajajajaj, bueno nunca es tarde para aprender ajajajajaj.

foobar, foo y baz no las había mirado nunca

Two main ideas to remember:
Reading code - mention every single symbol of the code when reading it.
Indent - 2 spaces (avoid using tab)

Names of the special character are in the class description.

I liked it, it is really important to learn Reading (understanding) code.

point, dot, period

For Web Devs:

  • < or > 👉🏼 Angle Brackets / Braces
  • _ 👉🏼 Underscore, but also Low Dash, hence the famous library name: Lodash 🧐

"…people who uses tabs… …those people are wrong…"
LOL!
And he said it without smiling even a little!!!

Tabs are the way to go, just one tap and you’re ready. Two spaces is okay too (if you wanna spend half an hour looking for the correct times of spaces). Four spaces are not. Why would you do four taps every single new line. Sorry python, that doesn’t make sense.

Thrilled to know # means Pound (as a weight measure) in English! In Spanish @ means Pound (arroba), and it´s used as a weight, and a surface measure as well (Usually because an @ of land used to produce an @ of corn, for instance). Just two classes and already learning too much!👍

kebab case tambien es usado cuando se nombra recursos en terraform

I though that the snake_case was named because it looks like a walking snake being the parts that touch the floor the underscores.

Dot : en lenguaje de programacion
Period: El final de una frase

Good Course, Thanks

I didn’t know many useful words thanks teacher!

Thank you for sharing this useful information with us

I was so confused the first time I read foo and bar. I mean, is everywhere in stackoverflow.

https://drive.google.com/file/d/1Ai5KUQw1juNSJDgWGU6tRZ2_7gIMQGzL/view?usp=sharing

<
//I attached  the audio from the challenge:


        public bool EsElegible(Cliente cliente, int monto)
        {
            bool elegible = true;

            if(banco.TieneSuficienteAhorrors(cliente, monto)==false)
            {
                elegible = false;
            }
            else if (prestamo.TieneHistorialLimpio(cliente)== false)
            {
                elegible = false;
            }
            else if(credito.TieneBuenCredito(cliente)==false)
            {
                elegible = false;
            }
            return elegible;
        }
 > 

Here is the challenge 😃
Voice recoding

The teacher is like a reading screen software! He he

There is also UpperCamelCase which is commonly used to name components in react, for example (function ComponentWithLongName ())

- hyphen, dash…

& and, per se pronounced ampərsand

flatcase: theexample
cameCase: theExmple
snake_case: the_example
kebab-case: the-example