DEV Community

Tushar
Tushar

Posted on

How language works inside the computer

Understanding How Your Computer Runs Applications: A Simple Guide

Have you ever wondered how your computer runs your favorite apps and stores all those memorable photos? Let's break it down in a simple and relatable way.

The Basics: RAM and SSD

First, it's important to understand two key components of your computer: RAM (Random Access Memory) and SSD (Solid State Drive).

  • SSD: Think of your SSD as a huge, fast library where all your apps, photos, and files are stored. It’s where everything lives when your computer is off.
  • RAM: Now, imagine RAM as your work desk. When you want to use an app or look at a photo, you take it out of the library (SSD) and place it on your desk (RAM). RAM is much faster than SSD, so it helps your computer run applications quickly and smoothly.

When you open an app, it moves from the SSD to the RAM, where it can be quickly accessed and used.

How Apps Run: Compiled vs. Interpreted Languages

Now that you know how your computer manages storage and memory, let's dive into how it runs the apps you love. The instructions written by developers need to be understood by your computer, which happens through a process called compiling or interpreting, depending on the programming language used.

Compiled Languages

Compiled languages, like C++ and Java, work like this:

  1. Write the Code: Developers write the app in a human-readable language.
  2. Compile: A compiler translates this code into machine language (binary code: 0s and 1s) that your computer can understand.
  3. Run: You can now run the app.

If there's an error in the code, the compiler won’t complete the translation, and you won’t be able to run the app until the error is fixed.

Here's a simple example in C++:

#include <iostream>
using namespace std;

int main() {
    cout << "Hello, world!" << endl;
    return 0;
}
Enter fullscreen mode Exit fullscreen mode

This code needs to be compiled before it can run. If there’s an error, it won’t compile, and you’ll need to fix the error first.

Interpreted Languages

Interpreted languages, like JavaScript and Python, are a bit different:

  1. Write the Code: Developers write the app in a human-readable language.
  2. Run: An interpreter translates the code line by line as it runs.

The advantage here is that even if there's an error later in the code, the parts before the error can still run. This allows for more flexibility during development.

Here's a simple example in Python:

print("Hello, world!")
Enter fullscreen mode Exit fullscreen mode

This code runs directly without needing to be compiled first.

Why Does This Matter?

Understanding the difference between compiled and interpreted languages helps you appreciate how different apps are built and run. It also highlights the importance of error handling and debugging in software development.

So, the next time you open an app or browse through your photos, you'll have a better understanding of the complex processes happening behind the scenes, all thanks to RAM, SSD, and the way code is executed!

Top comments (0)