Learn Programming Fundamentals
2 Variables Data Types
3 Conditional Structures
4 Strings
5 Arrays
6 Objects
8 Functions
Programming languages are essentially a way for humans to communicate instructions to computers. These instructions are written in a specific format, with their own grammar and rules, very similar to how we have different languages like English, French, or Spanish. This code is then translated by the computer into a machine code it can understand and execute.
Computers operate using binary code, which consists of 0s and 1s. However, humans find it challenging to understand and work with binary directly. To make it easier, programming languages were invented that humans find easier to work with. We have two main types of programming languages:
Machine-level languages, also known as low-level languages, interact directly with a computer's hardware and are specific to its architecture. This makes them very fast and efficient, and while they are easier than writing 0s and 1s, they are still quite difficult for humans to work effectively with.
Examples of machine-level languages include Assembly and Machine Code (0s and 1s).
The following is a code written in assembly language that prints the "Some message" string:
message db 'Some message', 0 ; Define a null-terminated string section .text global _start ; Entry point for the program _start: ; Write the message to stdout mov eax, 4 ; System call number for sys_write mov ebx, 1 ; File descriptor 1 (stdout) mov ecx, message ; Pointer to the message string mov edx, 12 ; Length of the message int 0x80 ; Call the kernel ; Exit the program mov eax, 1 ; System call number for sys_exit xor ebx, ebx ; Exit code 0 int 0x80 ; Call the kernel
As you can see, that is quite a lot of code just to print a simple message.
High-level languages are designed to be user-friendly. They use keywords and structures that resemble natural languages, making them easier to understand and write for humans. For instance, instead of writing complex binary instructions, you might use a statement like "if (x > 0) { print 'positive' }"
. However, these languages need to be translated by a compiler or interpreter before the computer can understand them.
Examples of high-level languages include Python, Java, JavaScript, C++, and C#.
The following is a code written in Python language that prints the "Some message" string:
print("Some message")
As you can see, compared to the machine-level language, this is much simpler to write.