What is programming?
Before we can introduce you to some key concepts, we need to make sure we understand what programming really is. A computer is a hardware machine that can store and process information. The language of a computer is Binary, a complex set of ones and zeroes. Programming is essentially the larger-scale process of developing a complex machine program that acts according to our wishes. Programming is the basic communication between human input and machine output. It is the way that a computer knows how and when to process data. We have put together some information to guide any beginner to coding success
So, what is coding, then?
Think of coding as a translator between English (or a different human language) and the computer’s binary. Coding involves the actual syntax and structure by which we write commands. A computer can then take those commands, translate it into binary, and do what is written. Coding involves writing commands in a language that a computer can understand. A programming language is a formal set of notations and rules. They generate instructions and implement algorithms based on the predetermined rules of that language. A computer can then produce an output from that text.
Coding has exploded in recent years, changing from something used in computer games and the occasional electronic device. To something which shapes the way that we live in the modern world. This means that now is an excellent time for a beginner to learn how to code.
Pretty much every device, electronic item, and modern piece of machinery contains at least a little bit of code. As the number of use cases for coding grows, the number of coding jobs available will also continue to grow.
Work Out Why You Want To Learn How To Code
The first thing that you need to do. Before you even think about enrolling in courses or starting to watch YouTube videos about coding. Is to ask yourself why you want to learn to code.
Sit down and think carefully about what you hope to get out of it. Why coding is a skill that you want to learn. And how much time and money you have to commit to it.
Things to Consider:
What sort of skills you want to end up with. Do you want to become a website developer? Or perhaps you would prefer to be able to build mobile apps or work in software engineering? You will need to think carefully about this because it will largely dictate the languages that you are going to learn. And how much resources you will need to put into it to become proficient enough.
Why do you want to learn to code? Is learning how to code simply something which interests you that you are going to be doing in your spare time? Or is programming something that you would like to pursue a career in further down the track?
How much time and money you can commit. If you are only going to have a couple of hours per week to commit to learning how to code. There probably isn’t a whole lot of point enrolling in an intensive course. If you want to join an intensive course with support, you will have to be prepared to pay for it. Identify and write down your coding goals and store them somewhere safe. These will quickly become the basis of your journey from novice to master coder.
Another thing to consider what hardware you want to use. Will you be using your every day tech which you may not want to start installing the numerous software models on. Or will you be looking into some dedicated hardware
Choose The Right Languages
Likewise, mobile app development requires Java (for Android) or Swift (for iOS).
Choose The Right Resources To Help You Learn
Now that we’ve looked at what you want to learn. It’s time to look at the best ways to learn them.
Some of these include:
Online coding courses: Online coding courses are one of the best ways to get a feel for a new programming language. When done right, they will teach you some of the essential syntaxes of a language and how it is used.
Textbooks: Code reference books are a great resource that every single beginner should make use of. They contain all of the syntax and conventions of a language. Allowing you to look things up when you’re confused or unsure about how to proceed with your code.
YouTube videos: Online videos and video tutorials are great resources that can help you get your head around complex concepts. You should use them alongside an online course or another method of learning how to code for beginners.
Download A Code Editor
Although there are a lot of different conventions on how you should code and where to start. Good practice is to start with an editor that is compatible with the language you want to start with and get used to what code editors do, and how they work.
Most programming languages have their code editors that you can download. They usually come complete with interactive development environments (IDEs) that will help you build clear, error-free code. Simple languages like HTML and CSS can be written straight into a simple text document if you find that easier.
Similarly if you do not wish to spend the time to learn the technologies involved with using an editor. Most languages provide you with a way to code in a simple text editor and run/test your code in a terminal.
Practice Writing Your Programs
Once you have a basic working knowledge of your chosen language. You will need to start creating your programs and projects. At the end of the day practice is key. Most coders have already learnt the hard way that programming is a skill that you need to use or you will lose it.
Join An Online Community
Navigating the intricacies of learning how to code for beginners on their own can be extremely difficult. There will be times when you need support.
For example, let’s say that you’re learning a language, and you’ve come across a piece of syntax that you can’t get your head around. Joining an online chat board or coding forum will give you access to people who will be able to answer your questions and help you get past any problems you’re having.
Hack Someone Else’s Code
Once you have a pretty good idea of how to code in a particular language, it’s time to delve deeper. One of the best ways to keep learning and to reinforce your knowledge of a programming language is to unpack someone else’s code.
Find a program or code file somewhere. GitHub is a great place to start. And open it in your code editor. Work through the code and make sure that you understand every line and what its function is.
In a way, programming languages are like any other language. They require regular practice if you want to become fluent in them. You will forget things if you don’t practice using them. It is, therefore, essential to make sure that you keep learning new things every day.
Don’t fall into the habit of using the same coding patterns and syntax for everything. Instead, keep striving to learn new ways to do things and to improve your method. I try to make a habit of learning one thing every single day. This could be a new piece of syntax. A new way to write a line of code. r simply a better way of debugging a program.
Now that we have looked at what programming is, what coding actually is, we can dive deeper into some of the most widely used terms you will encounter in your journey.
What is hardware? What is software?
In order for a computer to work, it requires both hardware and software. Software is a collection of instructions and programs that are downloaded to a computer. The apps on an iPad or Microsoft Word are examples of software. Hardware, on the other hand, is the physical device that stores, delivers, and executes that software. The physical iPad or monitor would be an example of hardware.
What is front-end? What is back-end?
Within the world of software development, there are two common camps that programmers fall into that utilize different tools, skills, and end-goals: front-end and back-end development.
Front-end development focuses on what the user will actually see on their screen. This involves the design, application debugging, and coding for user experience. This job is all about the feel, look, and design of a program or website. Also known as the UI or GUI (pronounced gooey)
Back-end development focuses on everything that makes the front-end possible. This job is all about how a site or application works. How quickly it functions, and how it communicates with databases (where data is stored).
Many programmers are more generalists on both sides. They are called full-stack developers.
What is a programming language?
Now that you have your bearings on the world of programming, let’s discuss what you will actually need to learn to become a programmer. We will start with the fundamentals of programming on the whole: programming languages.
Just as we use different human languages to communicate, we also use programming languages to communicate with a computer.
A programming language is a formal set of notations and rules. They generate instructions and implement algorithms based on the predetermined rules of that language. A computer can then produce an output from that text.
There are tons of programming languages, and they each serve different purposes, styles, and specializations.
Imperative vs. Declarative Paradigms
As we mentioned, programming languages have different styles. In fact, every programming language operates according to a paradigm. A paradigm is basically the way that a computer will logically approach a problem. It is the style of that language.
There are many different paradigms out there, and they all fall under two branches: imperative and declarative.
For imperative programming, you tell the compiler what you want to happen to your code. You give it all the steps, and it “listens” to your imperative commands. You give the instructions, not the desired outcome.
For declarative programming, you will write code that describes what you want to happen, but you don’t explain how to get that result. You give the outcome you want, not the instructions to get there.
As a beginner, there are really only two paradigms that you need to know about: Object-Oriented and Functional.
- Object-Oriented programming is an imperative paradigm that largely dominates the field. In this paradigm, everything is treated like an object. An object is a thing you can interact with or alter.
- Functional programming is a declarative paradigm that thinks about data through sets of tasks, which we call functions.
Compiled vs. Interpreted Languages
A programming language isn’t the only tool necessary for communicating with a computer. After all, the computer “thinks” in binary. Compilers and interpreters take human-readable code and translate it to computer-readable code.
A compiled language means that the machine directly translates the program that you input. These tend to be faster and more efficient but require an extra “build” step.
An interpreted language, however, requires another program to read and execute the code, sort of like a middle-man.
Let’s take a deeper look at how you write in a programming language. We will go over the key concepts and vocab terms to get you familiar with coding syntax.
What is syntax?
Simply put, the syntax of a computer language is the set of rules that defines the structure of the language.
What is Semantics?
Semantics, on the other hand, refers to logic. Semantics deals with the meaning assigned to the symbols, characters and words.
So, syntax is structure and form. Semantics is logical meaning.
When you learn a new programming language, it is a long-standing tradition to write a program that outputs the phrase Hello World!. This is called a string.
In Python, there is a function that allows us to output a string.
A function is like a task or command. A function is a block of organized, reusable code that is used to perform a single, related action. Functions provide better modularity for your application and a high degree of code reusing. You have already seen various functions like printf() and main(). These are called built-in functions provided by the language itself. But we can write our own functions as well. These blocks of code only run when they are called. And you can set parameters into a function to return specific data. Functions must be defined using a keyword based on your programming language.
Once you define your function, you can use it to implement actions.
Just like any human language, a programming language has words with reserved meaning. That’s how any language conveys meaning! Keywords are reserved words that have pre-determined meanings and uses. Each programming language has its own set of keywords, though there is a lot of cross-over.
The keyword def, for example, defines a function (a task), and the keyword return runs that function and returns the result.
Identifiers are similar to keywords, but these are the names that the programmer would create to label different entities in their program. We use these to differentiate one entity from another. To create an identifier, you must follow the syntactic rules as outlined by the programming language of your choice. For example, in Python, identifiers must follow these rules:
- Identifiers can be a combination of lowercase letters, uppercase letters, digits (0-9), or an underscore
- Keywords cannot be used as identifiers
- Identifiers cannot include any special characters like !, @, &, $, %, etc.
- They cannot begin with a digit
Note: Python is a case-sensitive language. This means that capitals matter. Variable has a different meaning than variable. This is not the case for all languages
Variables allow you to store information that can be accessed over and over again. These are similar to variables in algebra. But in programming, we name our variables according to the syntax of that language. Naming a variable is called declaring a variable.
These are useful for any data or value that you want to use more than once. Some programming languages require you to tell them what type of data will be stored in this variable, but many don’t require this. They will simply assume the type by looking at what data has been stored.
As we have learned, programming is all about data processing, and each language has different kinds of data. Data types are like classifications that tell the compiler or interpreter how to use a piece of information. Let’s take a look at four commonly used data types to get a better sense of how they work.
- Integers are numbers without decimals, just like in algebra. In fact, they can be used to do algebra in your programs. Integers can be stored in variables so we can use them over and over again.
- Lists allow us to store multiple variables in one group. This way, we can perform actions and functions to an entire list of data.
- Boolean is basically a yes or no response. They will return either True or False. These can serve tons of different purposes, like comparing the equality of two numbers or variables.
- Strings are commonly pieces of text in programming languages, such as our Hello World! statement. They are written with quotation marks.
Operators are symbols that perform mathematical functions to your data. There are different categories of operators. The most important operators for you at this stage are the following:
- Arithmetic (for simple arithmetic)
- Assignment (to assign value)
- Relational (for comparison, returning boolean values)
- Logical (to return boolean from a boolean input)
Conditionals allow us to perform certain actions depending on a condition. We use booleans to determine if data meets certain requirements, and then define what the program should do if that requirement is or is not met. In other words, we want to tell the computer, “if this thing is true, do this other thing”.
With a loop, you can run the same block of code over and over again, for example, with a list to check the values. In Python, the most common loop is the for loop. The for loop basically states “for every item in the list, do this thing”. The loop will end once it completes its predetermined length if one is specified.
In microcontrollers, the majority of your code is placed inside an endless loop. Basically your controller will just keep repeating the same steps over and over again. For any other environment, we can mimic this, by using an endless while loop.
Let’s move away from the nitty-gritty of programming and think a bit more broadly about the lingo you need to know to be a successful programmer. Here are the top 10 coding terms you’ll encounter in the field.
A bug generally describes an unexpected error or mistake in your software or hardware. These can be malfunctions, defects, glitches, and the like. Bugs can cause an entire computer system to crash if they aren’t addressed properly. A lot of programming involves testing for and solving bugs. That process is called debugging.
Text editors are where you write your code. They are like notepads on your computer where you can type a program and create files. There are many different types of text editors, as some are better for certain languages.
An IDE (integrated development environment) is a more robust text editor that includes many other features on top of a text editor “notepad”. These applications include a compiler, runtime environment, and debugger, so they are far larger than a text editor.
Source code is your program’s code. It is the human-readable instructions that you write as a programmer. This is the data that is then compiled and turned into binary machine code.
The world of programming is filled with open-source content. This is basically software with a license stating that the source code can be used, modified, or changed by any coder. Open-source content and code are freely available and can be freely distributed.
Refactoring is the process of changing a software system in a way that doesn’t change the actual behavior or output of the code. This is done to improve or optimize internal structure, for example, by simplifying certain blocks of code or adding a feature.
Runtime, as the name implies, is the amount of time it takes a program to run on a computer. It is when the computer is executing the machine code. If something occurs “at runtime” (a phrase you will likely hear), it occurs as soon as the program begins. This is often where bugs will be discovered or abnormalities will become apparent.
Libraries are open-source collections of prewritten code that a programmer can add to their program for certain functionalities. Different languages have different libraries, and these are sometimes huge factors for choosing certain languages for a project.
If a library is something you add to your code, a framework is something you put your code into. Think of this as a preset way to organize code. It is a reusable architecture that defines how certain entities will interact. Some programmers use these terms differently.
Programming includes a lot of different tools. A tech stack is the specific combination of tools used to create web and mobile applications. Various companies use different tech stacks depending on their needs and goals. A common tech stack is called LAMP, which stands for:
Now that you have a sense of some foundational coding vocabulary and syntax, let’s go one step deeper to learn about another important aspect of programming.
Data structures and algorithms
Data structures and algorithms are a key part of programming. Let’s briefly introduce these concepts and explain why they’re important to your programming journey.
As we know, computers store and process large amounts of data, so the way we organize that data makes it easier to use and access information. Data structures are the way that we arrange data in a computer’s memory.
Data structures use logic to organize information according to two concerns: firstly, how should we store data, and secondly, what actions will we perform on that data?
Broadly speaking, data structures fall into two categories: linear and hierarchical structures.
- Linear structures organize data in a linked fashion, where each element is attached to the one before and after it.
- Hierarchical structures organize data like a multi-level pyramid or tree. As you can imagine, these data structures have very different uses.
Think of algorithms as a step-by-step process to solve a problem. They are sets of rules that are followed by your program to complete certain operations or calculations. Think of this as a recipe.
An algorithm outlines a set of rules (the recipe) to get an expected output (the dish). Inputs are fed into the algorithm, and it implements various functions (tasks) to obtain that expected output. You can either use pre-existing algorithms or write your own.
Algorithms and data structures work together to serve different purposes for your programs. For example, since algorithms can be used to search or sort data, the way you organize your data will impact how quickly your algorithm can work.
Finally we have reached the part where we will start to look at some actual code.
As I mentioned before, I will be focusing on Python, Micropython (and Circuit Python), C++ and Java. This is, for me, the basics required for most makers.
Where do we use what?
Python: Raspberry Pi
Micropython (and Circuit Python): Pico, Micro:bit, ESP and Raspberry Pi
C++: Arduino, can also be used with all of the above
Java: Any other Desktop environment
What is Micropython and why is it different from Python?
Python is one of the most widely used, simple and easy-to-learn programming languages around. So, the emergence of MicroPython makes it extremely easy and simple to program digital electronics. If you’ve never programmed digital electronics before, MicroPython is a good starting point. MicroPython is a re-implementation of Python 3 targeted for microcontrollers and embedded systems. MicroPython is very similar to regular Python. It runs “bare-metal” directly on the hardware: there is no underlying operating system like Windows, macOS, or Linux. All the operations and services usually provided by an operating system are handled directly by MicroPython. It has complete and direct control of the hardware, so, in effect, MicroPython is the operating system.
High-level vs Low-Level programming
Most programming languages that you will have heard of are high-level languages. Python and C# are examples of high-level languages that are widely used in education and in the workplace. A high-level language is one that is user-oriented in that it has been designed to make it straightforward for a programmer to convert an algorithm into program code.
A low-level language is machine-oriented. Low-level programs are expressed in terms of the machine operations that must be performed to carry out a task. This makes writing programs more difficult, as the algorithm must be specified in terms of the capabilities and specifications of the processor. Low-level languages are named for the processor (or processor family) that they are designed for, and are often referred to as assembly language or machine code. C++ is an example of a low-level language.
We note that Python and Micropython are high level languages because the syntax for code is so very human readable. To print a line out, you simply tell the computer using the word (or function) to “print”. Whereas for C++ we had to tell the computer where to send the command. Before telling the computer what the command is: “Serial.println” (which stands for print line).
It is easy to find out how to write the function in your chosen language, as long as you know what function it is that you need to use.
We will start diving deeper into this topics once we have branched off into each use case in our getting started range. Starting with Raspberry Pi, and moving over to your various Microcontrollers like Raspberry Pi Pico, ESP, Micro:bit and Arduino. This is where your knowledge on a particular language can start to grow.
We will also be looking into Circuit python, which allows you to use the same block of code on almost anything. From a host of single board computers, all the way down to almost any microcontroller.