#include <stdio.h>
int main()
{
printf("Hello, world");
return 0;
}
This code returns Hello, world
as its output. And with that, welcome to computer systems!
Programs
A program is a set of instructions asking the computer to perform an action. It is written in a particular programming language by a programmer using a text editor like VSCode, Atom, etc.
For example, the following code opens your calculator [although it may be depreciated, it still works!]
import java.io.*;
public class fff
{
public static void main(String[] args)
{
try
{
Runtime.getRuntime().exec("calc");
}
catch (Exception e) {}
}
}
The actual file that contains the code of a program is called a source file. It is a sequence of bytes that represents characters from the ASCII [American Standard Code for Information Interchange] standard.
Nowadays, UNICODE [Universal Character Encoding] has replaced ASCII.
ASCII and UNICODE are 2 varieties of character encoding - a system that maps characters to binary digits so that the computer can process that easily.
Cheatsheet for character encoding in this website
High and low levels
The languages used to write these programs go into 2 camps - high-level languages and low-level languages.
High-level language is one that is so simple that even a beginner can understand it.
Whereas, a low-level language is…complicated.
Let’s compare a high-level language [such as Java] and a low-level language [such as Assembly] that print Hello, world
in the console output :
public class fff
{
public static void main(String[] args)
{
System.out.println("Hello, world");
}
}
section .data
hello: db 'Hello, World',10
helloLen: equ $-hello
section .text
global _start
_start:
mov eax,4
mov ebx,1
mov ecx,hello
mov edx,helloLen
int 80h
mov eax,1
mov ebx,0
int 80h;
Ouch! I wasn’t kidding when I said Assembly is hard. Since it’s closer to the computer’s hardware and binary, it isn’t as human-friendly as high-level languages.
This also happens because high-level languages are abstracted from the complexities of the computer system.
Abstraction?
Abstraction is one of the 4 pillars of Object-Oriented Programming. But I’ll simplify here.
It just means that the difficult-looking parts of a system are hidden away from the end-user [which is you!]. Only the features that are needed [at that moment] are shown.
For more details, check out [coming soon!].