Welcome back to Easily Understood, where I try and debunk some technical jargon from the software industry. In my last post I spoke about code in general, and mentioned that code is written in a programming language. So this week I plan on explaining what a Programming Language is! And I plan to not include any controversial British drink analogies this time…
If English is a language that a humans can understand, then programming languages are languages that a computer can understand. At the lowest level computers understand a programming language called machine code, this is usually written in binary (0’s and 1’s). Computers understand binary because they’re made up of little “on”/”off” switches called transistors, and with enough of these transistors (modern day computers have millions) you can create some pretty complex logic.
“But Ry, I never see my software developer friends writing in 0’s and 1’s?” you might say and you’d be completely right. Some developers are required to write in low level languages such as Assembly or Machine Code, these are languages that directly manipulate hardware. Most however, do not. In order to make programming more accessible there have been “high level languages” created. The key difference between high and low level languages is that high level languages promote human readability, it’s far easier to understand words and symbols (much like algebra in maths) than it is to understand a series of 0’s and 1’s!
You can compare the make up of a programming language to that of any written or spoken language. Each has a dictionary (words), grammar (symbols) and a syntax (language rules, such as word order). For example take the following sentence:
I read a book, usually fiction, every morning at breakfast.
It makes sense right? That’s because it abides by a set of syntactical rules, uses words from the english dictionary and houses correct grammar. Change it up slightly:
Book a read fiction, I usually, breakfast morning at every.
And it’s just jumbled nonsense. What humans are doing when they’re reading is compiling each sentence mentally to understand it. Fortunately with humans, we’re great at automatically fixing grammatically errors. There’s a theory that as long as the frsit and lsat letters are in the same place, the letters in the middle can be jumbled and you’d still read it correctly. With computers however the situation is a little bit different.
In order for a computer to understand a high level language it has to translate the code to machine code. The code is usually passed through a compiler, which handles this translation. Imagine translating a sentence from English to French, the compiler takes the English input, checks it against a vast set of grammar and syntax rules to make sure it makes sense, then translates it into grammatically correct French. If it fails the syntax check, it fails and usually gives the developer a reason why and a pointer to fix it.
And in comparison this is it in Python:
Both languages are executing the same commands and producing the same result, but with their own syntax. The same as our previously mentioned English to French translation, the sentences mean the same thing, but with a completely different syntax.
Wait a minute Ry, how to developers know what programming language to use? Well that’s down to the context of the problem the developer is trying to solve and the preference of that developer in programming languages. C# is a good language for general software development, whereas Python excels in speed when it comes to some branches of artificial intelligence. Part of being a software developer is picking the right tool and approach for the job. It’s like deciding whether to use screws and a screw driver versus a hammer and nails!
Well that was a bit of a longer article, what did you think? Do you have any further questions? I’d love any and all feedback, if it was helpful or if I could have explained things a bit better please do let me know!