High Level And Low Level Programming Languages
Tags: javascript, programming, beginners, cpp
Published: 2023-02-10 01:56:31

I recall when I first started to code. Started with HTML, CSS and then I moved on to JavaScript. One day while studying, I came across a topic named 'Memory management in JavaScript'.

Now the text talked about [garbage collectors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_management) in high-level languages, and also talked about manual memory management in low-level languages (this was before I started learning the C language). It didn't make sense to me at the time.

My curiosity was sparked, so I read about the levels of programming languages. A few months later while studying the C language, a video tutorial on data structures and algorithms(implementation of the Linked List precisely), it all came flooding back.

Now we deleted a node from the Linked list and then we used the `free()` an in-built C function to delete a pointer `temp`, which was pointing to the address of that node(recall manual memory management,the `free()` did that). With this I decided to write something about my little experience and I hope every beginner can take something from it.

## High-level Programming Languages
They are programming languages very close to the human language (not just English Language, I have seen programs written in Arabic). If we were to liken a high-level programming language to a structure, the human language would form part of the concrete used for construction.

Due to the fact that high- level programming languages are closer to the human languages, they will need to be converted by an interpreter to a machine code **1 & 0**. In a way, this reduces speed in comparison to low level languages. 

> Just like Craig Bruce said, “it’s hardware that makes a machine fast, it’s software that makes a fast machine slow”. 

On the other hand, it is portable and can run on any platform, errors can be easily debugged, it has automatic memory management like garbage collection.

Overall, these programming languages, employ the use of abstraction as one of their major pillars. In layman’s terms, abstraction means placing functions which have sub actions hidden from the user, i.e. showing essential things while hiding implementation to provide a very good user experience. Examples are JavaScript, Python and Ruby.

## Low-level Programming languages
If programming were to be juxtaposed with the family tree, the low-level programming languages would be at the top. These languages are very close to the machine language, infact most modern high-level languages were written in these lower level languages. Machines only understand bytes which are mostly written in **1s and 0s** which is binary and can be very tedious to write. The programmer must remember numerous technical details which make it error prone.

Due to the fact that low-level programming languages are closer to the machine, they need no compiler or interpreter and are directly executed on the computer hardware, so this doesn’t slow it down. Low-level languages are used in places where performance, speed and efficiency are critical elements to the success of a program. If there’s a part of the program where speed is required, one may only write that part in machine code and the rest in a high-level language of his choosing. We also have to free up memory manually.

One major point to note is the fact that these programming languages, provide little to no abstraction from the computer’s instruction set architecture. It’s also relatively hard to debug. The two examples of low-level languages are Assembly and Machine Code. We also know that Assembly language for instance is hardware dependent, because assembler instructions have to reflect the hardware instructions of the Computer they are running on. So only an assembler built for that hardware can produce a valid program from that source code. Several Assembly variations exist, examples are x86 assembly, ARM assembly e.t.c.  The two examples of low-level languages are Assembly and Machine Code. C is also sometimes referred to as a low-level programming language in some circles, because it has no automatic memory management (recall I said we had to free up memory after deleting a node) and provides a direct control over hardware.

## Medium-level Programming Languages
They are also known as intermediate or pseudo programming languages.

Now a language like C++ on the other hand is referred to as a mid-level programming language likewise C sometimes. C++ combines features of both high-level and low-level languages. Features like classes, objects and abstraction are high level qualities of C++, however it still allows low-level control and is used in systems and game engines. But you also find out that the lines are blurred. We find out that even some so called high level programming languages like Ruby, Python, C# and Java are sometimes referred to as medium-level.

Now let’s talk about Java. The Java compiler was created in C and Java has many features of C, but lacks some things like working directly with pointers. Even though Java is referred to as high-level in some circles.

Now there's something else I would like to touch on. Even though we use them interchangeably, the compiler is different from an interpreter.

## Compiler Vs Interpreter
The interpreter is actually used in the more high-level languages like JavaScript and Python. It converts statement by statement, line by line of code and runs it while the program is running. This makes it produce errors line by line, thus making it slower. Although makes debugging easier.

The compiler on the other hand converts the complete code before execution, thus making it faster, even though debugging might not be as easy as the interpreter. Languages like C and C++ use this.

## Worthy Mention
The Assembler:This converts programs written in Assembly code into Machine code.