Syntax is the specific way we have to write code for a given language. A set of rules. A structure. We have to adhere to this structure in order for the compiler to accept our code. If we don’t, our code will be rejected and we’ll receive a build error.
It’s really important to understand the syntax of a language because it allows you to read the code, which is a different skill from being able to write code. Learning the syntax of a language for me is always the first aha! moment, that’s how that works! Well that makes perfect sense. A good approach to take is to actually read some code, and look for the specific use of symbols. A lot of syntax is symbol based as opposed to word based. But the more code you read, the more you’ll start to spot common words, and it’s highly likely they’ll be part of the syntax. They are sometimes referred to as ‘Reserved Words’ or ‘Keywords’.
The majority of IDEs by default will have Syntax Highlighting turned on. This is where the IDE will colour your code based on syntax. For example in Java, ‘public, void, private’ are all keywords, so if you write those in IntelliJ, they’ll be a different colour than other code. Syntax highlighting can really improve code readability by drawing your attention to the syntax being used.
You will, at some point in your programming journey, forget to close a bracket or end a line of code. These are probably the most common syntax errors people run into. The good thing about using an IDE is they will tell you when you need brackets and where. Some will even automatically add the end bracket for you. But you have to fail with brackets at some point; it’s an essential part of the journey!