This is the first in a series of posts I plan on doing in an attempt to decrypt the mystical jargon that is well understood to anyone in a software profession. The idea came from a non-technical friend who was curiously asking me questions about what I do. If you’ve got any suggestions on concepts or words you’d like me to explain, please feel free to reach out.
The topic of this post is Code, what is code? How does one write code? How many concepts or phrases need covering as a pre-cursor to this?
Code is defined by the dictionary.cambridge.org as
a language used to program (= give instructions to) computers. And that’s a great brief explanation. But what does that mean?
All computers run on a series of instructions, in high level things like
Delete PictureOfDogNumber1234 and
Send Email. But under the hood those actions could take thousands of smaller instructions, all of which are written in code.
Imagine you’re making a hot beverage, in this case a cup of tea, you would:
- Fill kettle
- Turn kettle on
- Get empty mug
- Put teabag in mug
- Pour boiling water into mug
- Wait for desired period of time
- Add milk
- Add sugar if Required
- Take teabag out
Disclaimer: This is a basic cup of tea recipe, other Brits might make theirs differently!
That 10 step algorithm, is a list of physical instructions for making tea. Code is exactly that but telling a computer how to function.
In the above example the programming language is a numbered list of english statements, when writing software, a programming language is just like a spoken language such as English or French, there are words, numbers, symbols, syntax and so on. I’ll do another post in the future about programming languages but for now a programming language is the written language that computers can understand. If you were writing a letter, the programming language would be the language you write in (English) and the code would be the words that you write.
Printing “Hello World” to a console tends to be the making a cup of tea aspiring developers first attempt when learning a programming language. I’ll cover what the famous “Console” is in a later post, but for now we’re going to treat the console as the program that runs the code we write. In order to print “Hello World” to the console, we need to write the instructions for writing text to a console window. An example of a programming language is C#, and to “Hello World” in C# we write the following:
Let’s quickly analyse what this is doing.
Console is the collection of instructions which relate to the console we’re trying to write to.
.WriteLine() is the method(instruction) which is going to put whatever text we want onto the console window, there are other methods in the Console collection such as
.ReadLine() which reads text the user types in.
"Hello World" is the value we’re instructing the WriteLine method to push to the console and
; at the end, in terms of C# is the equivalent to the full stop when writing a sentence.
So if I were to summarise, Code is the written instruction, written in a language a computer can understand, that tells a computer how to function and what to do.
Did you find that helpful? I’d love to hear if you did. If I lost you at any point please also let me know, I’d like to help you understand and make any needed edits to this post!