📚 Learning to code is like learning a human language
Learning to code is a lot like learning a human language.
Just like every language has rules for how to put words together, every programming language has its own rules, which we call "syntax".
For example, a sensible English sentence might be "The cat sat on the mat," where each word follows a specific order. In Python, each word in a phrase like "print('Hello, World!')" follows a specific order too.
When we write a command in programming, it's like writing a sentence, which we call a 'statement'.
Just as "The dog barked loudly" is a sentence in English, "print('Hello World')" is a statement in Python that tells the computer to display "Hello".
Programming languages have fewer words than human languages, but sometimes these words are very complex. It's like comparing the word "tree" in English to a long, descriptive German word. In programming, a single command can do a lot, like "print()" in Python, which sends text to the screen.
We also use special symbols in programming, like brackets and plus signs. These are like punctuation marks in English. Just like English sentences use periods and commas, programming uses these symbols to structure code.
Reading direction matters too. In English, we read from left to right, but in Arabic, it's right to left. In programming, we usually read from the top of the page to the bottom, then left to right. This means you look at the code starting from the top line, moving downwards, and then across each line.
Capital letters and spaces are important. In English, changing the capitalization or spacing of a word can alter its meaning, like how "apple" refers to the fruit, while "Apple" can refer to the technology company. Similarly, in programming, "myVariable" and "MyVariable" are treated as two distinct entities due to case sensitivity in many programming languages.
Programming languages have words for different purposes. In English, we have nouns and verbs. In programming, there are "keywords", like "if" or "while", which start actions, and "variables", which are like names for things. For example, in a simple program, "age" could be a variable representing a person's age.
In regular languages, words like "big" and "large" mean the same thing. This is like 'polymorphism' in programming, where you can use different commands to achieve the same result. For example, in Python, you can use both "len()" and ".count()" to find out how many items are in a list.
There are a bunch more examples like these. The main takeaway is that understanding the parallels between a human language and a programming language is a great way to make computer code less foreign-looking, more approachable, and easier to grok.
© nem035RSS