We refer to syntax in computer programming as the concept of giving specific word sets in specific orders to computers so that they do what we want them to do. Every programming language uses different word sets in different orders, which means that each programming language uses their own syntax. But, no matter the programming language, computers are really exacting in how we structure our syntax. In this video, you’ll understand what syntax is in computer programming and how it’s important in getting a computer to do what you want it to do.
Once we figure out what we want the computer to do, we need a way to communicate to give it the instructions so that it can do it correctly. This is where we’re going to write the code part of coding.
What is Syntax?
Syntax refers to a concept in writing code dealing with a very specific set of words and a very specific order to those words when we give the computer instructions. This order and this strict structure is what enables us to communicate effectively with a computer. Syntax is to code, like grammar is to English or any other language. A big difference though is that computers are really exacting in how we structure that grammar or our syntax.
This syntax is why we call programming coding. Even amongst all the different languages that are out there. Each programming language uses different words in a different structure in how we give it information to get the computer to follow our instructions.
Programming Syntax More Detailed
To explain syntax further, we’re going to define syntax as essentially a set of keywords and characters that a computer can read, interpret, and convert into tasks that it know it needs to do. Programming or coding, is typing these keywords and these characters into a file in the right order and feeding it into the browser. The browser then processes our information, if it’s in the right order, it then can figure out how to execute the task that we want it to do.
Think of syntax like the drive through at a burger joint. If you can do a few simple things in the exact right order, you get what you want. You have to tell them what you want in the microphone, pay at the first window, and pick up your food at the second window. You have to do it in that order. You can’t pay the microphone or pick up your food where you’re supposed to pay. Additionally having this order in place helps you get what you want faster and with less talking.
Because we’ve already agreed how drive throughs work, you can simply pull up and say, give me number one and expect to get exactly what you want. That’s the benefit of having preset syntax.
Computers Can’t Read Typos
The flip side of syntax is that computers are going to be exact in what they expect us to code. Humans are not so precise. We can read someone else’s typo and infer what they meant, and move right along. If a computer finds a typo, it’s gonna get confused and lost, and have no idea what you meant it to do. This might get you pretty anxious about all the mistakes you can make in a computer. It’s nothing to get worked up about. If you make a mistake, your computer is not going to crash and catch on fire. It’s simply gonna say, “This doesn’t work.” You fix the error, you try again.
If you forget something, there’s a lot of online guides and references that you can look up to find the syntax that you’re missing. So don’t get worked up about it.
Let’s move on to some more exercises so that you can practice this and start getting more familiar with syntax.