Category: Programming Syntax
Hits: 734

There are a huge number of different types of syntax depending on which programming language you're using. From Java to Golang, PHP to Perl and even the dreaded Visual Basic, every language has it's own specific type of coding syntax and standards. Even once you get past the syntax issues, many individual developers and teams will have their own forms of standardisation which define the specifics of the syntax you're encouraged to use while working on a given project...and this is before we even get anywhere vaguely near the whole "tabs vs spaces" debate. Fortunately though, there are some standard aspects of syntax which are generally abstract-able and continuous throughout most programming languages.

Understanding these different syntax aspects can give you a quick and rapid foothold into understanding any programming language and syntax - a tool well worth having in your mental toolkit! Doing this will mean you are able to quickly get behind any programming language you try to learn which will give you a significant leg-up in understanding the specifics of each language. Since every one has various quirks and unique attributes, this is an absolutely vital part of becoming an experienced developer.


The most fundamental aspect of any language is the function. In essence, a function is a self-contained block of code which can be referenced by anywhere else in your programming codebase. Functions can, obviously, reference other functions, which means that you can design your code in a modular way and avoid repetition of code.

This is an essential aspect of coding and forms the basis for "DRY" coding - Don't Repeat Yourself.

Effectively, you should always ensure that any time you are repeating code, in general, this is instead split out into modular and function based design scope. This means that rather than having repeated code blocks of logic, you create functions which are then referenced by your code so rather than repeating the logic, you have it in one place, and then make function calls to execute it.

Since functions can take an arbitrary number of arguments, this also means that you can easily repeat any aspect of logic in a function - not just simple consecutive logic. In essence, functions are almost like their own small programs which take input data and output data (typically).

You should always aim to leverage functions throughout your program code if you are doing anything remotely complex, and using a modular design pattern means that you should also try to group similar functions together into modules. For example, if you are creating a program which is used to create some interesting mathematical patterns and then display them, you could have one set of functions in a module called mathFunctions which performs the mathematical functions on inputted data, and another called displayPatterns which handles the rendering of the mathematical patterns into graphs etc.

Another consideration to make is that functions do not always have to return data, nor do they have to return all the data changed by the function. Passing variables by reference (the default in some programming languages anyway) means that it's entirely possible for a function to operate on data in-memory passed as a reference and then return either nothing (in the case of a function with void type) or something more specifically useful to determining logic flow in the original program (such as a success or failure code).