this article was inspired by a talk from Andy Harris on IndyPy 2017
Do not think like a computer, instead, instruct the computer to think like a human.
Computer programs are essentially blocks of instructions that tells the computer what to do. Computers aren't smart, they are stupid, and need instructions from us humans to know what to do.
The way we give these instructions to computers is through code. Code is a translation of technical human language to computer language.
Technical human language is English (or any other language) with more focus on specific keywords. These keywords are what computer languages are built of. The grammar of computer languages is called syntax.
The language syntax describes how we write these keywords and these keywords describe the actions we want the computer to perform.
an example of these keywords, that you will find in any programming language are;
I'll explain one of the keywords that we are going use in this example. A Variable is like a storage box, it has an address (the variable name), it holds an item/items (the variable value), and has a description of what the box can store (a type).
Now, say we want to create a variable and store a value in it. Lets write an explanation of what we want to do in technical human language.
Create a variable with the name of
text with the type of
Set the value of the variable
Lets translate this technical human language into computer language, in Go-Lang for example.
// Create a variable with the name of text with the type of string var text string // Set the value of the variable text to "hello World" text = "Hello World"
Comments are not there to explain the code. The code is there to explain the comments to the computer ~ Andy Harris
var is a the Go language keyword for variable
text is the name of the variable
string is the type of the variable
= Tells the computer to set a value to variable
"Hello World" is a value of type
string denoted by the
" " signs
With that knowledge of what a variable is. You can easily look up the syntax of how to create a variable in any programming language and instantly understand it.
Essentially what you should learn is not languages, instead, you should learn these keywords and understand what they stand for. You should start thinking in a technical human language to describe what you are attempting to do, and from that start translating it into any computer language (code).