AltSchooler Diaries: The Rules of Programming Languages

written by Ayomide Johnson Salami

Photo by Chris Ried on Unsplash

Normally, there are rules that guide our usage of certain languages either written or spoken (i.e syntax and semantics.) For instance, in English, the first letter in every sentence must be capitalized. Punctuation marks must also be used appropriately so as not to distort the intended message.

Just as it is in the English Language, similar rules also apply to programming languages. Every programming language has its own syntax and rules that must be followed. Failure to abide by these rules could lead to the compiler or interpreter throwing out a syntax error.

Anyway, it is important to note that while some general rules apply to a lot of programming languages, they all have specific rules unique to them. To understand these rules better, read up on them in the documentation for the language.

For now, let’s talk about the common rules in programming languages.

How to Write Statements

First, what is a statement?

A statement is a single, self-contained instruction that produces an effect. “Self-contained” in this context means that a statement must be specific and complete. For example, “I want you to flip the coin” is a complete statement in English. However, if I had simply said to you, “flip”, you would agree that it isn’t complete. Therefore, to write a statement in a programming language, you must specify the action (flip) and the object (coin) of said action. If you fail to do this, the compiler or the interpreter for that language would complain.

An example of a statement is:

Add one to count:-

In modern programming languages, it would be written like this: count= count+ 1

In older languages like Cobol: ADD 1 to count

In AppleScript it would be: set count to count + 1

A program in kotlin that adds one to the value of count

Also, the way a full stop signifies the end of a sentence, a lot of programming languages require us to signify the end of a statement. The most common character is a “Semicolon”; i.e

statement 1;

statement 2;

statement 3;

Without the semicolon, the compiler will complain.

A program in C adds one to count and ends each statement with a semicolon

NOTE: It is important to mention here that you do not need to memorize these. I’ll encourage you to simply read and understand.

Now, let’s move on to:


Also called Reserved words, Keywords are words that belong to a programming language, or words that come predefined with a specific function. You cannot redefine a keyword to mean something else. Each programming language also has its own set of keywords. Python has about 33 and some other languages have about 50 keywords and even higher. What you need to do is understand how to use the keywords necessary to write a valid program.

Some examples of keywords in Python are: false, true, if, is, lamdba, with etc. We usually need more than the language’s keywords to write a good program and sometimes, we might need to introduce our own keywords. But we will talk about that later.


Comments help us–and other people–understand our source code at any point in time. A comment is NOT a statement and this is why the compiler or interpreter ignores it. Again, comments are meant for us, the programmer and not the compiler.

Anyway, a well-commented source code is good practice. Comments are also used to provide remainders and disable a statement. When you wrap a statement with the commenting characters, they are disabled and they won’t run. Having said that, let’s take a look at three (3) major ways to add a comment:

- Multiline/Block Comments: In C and other C-Styled languages like Java, Kotlin etc, these types of comments start with a /* and also ends with */. Everything in between is regarded as a comment.

- Inline Comments: Starts with //, everything after this in a single line becomes a comment.

- Documentation Comments: These start with /** and end with */. They are also multiline with each line in between starting with a *.

Python and Ruby use # to signify an inline comment

Comments in the C program.

Comment in python

White spaces and Indentations

In most modern programming languages, white spaces are not important and this is why they are ignored by the compiler or interpreter. White spaces exist to make the source code readable. However, in python, indentations are important as they help signify to the interpreter that a block or a group of statements are together or are meant to run together.

*NOTE: Some languages are also case sensitive. When you select a language to learn, you can read the documentation to know if it is case sensitive or not.


Pseudocodes are human-readable statements or instructions written in human language. Coding specifically is the act of writing these instructions in a programming language of our choice.

This is a great place to take a break. Next time, we are going to be taking a look at Variables and Data Types in this article series.

Thanks for reading!

This article was written by Ayomide Johnson Salami, a Cloud Engineering student at AltSchool Africa's School of Engineering.


Interested in building a profitable career in tech? Apply to AltSchool Africa and learn a highly sought-after tech skill.

You can become a certified Data Scientist, Data Analyst or Data Engineer in just 12 months!

Ready to begin?

Apply Now!

Share this article: Link copied to clipboard!