Machine language is a sequence of binary numbers (bits), that is, zeros and ones (0s and 1s)

Each set of zeros and ones represents a single instruction that the central processing unit (CPU) can execute directly, such as adding, moving data, or jumping to another memory address

00010011

Assembly Language

Assembly is a low-level language that uses mnemonics (human-readable instructions) to represent machine language instructions.

Transformation: The process of translating Assembly into machine code is performed by a program called an Assembler.

assembly (human languaje) -> assembler (transforms/converts to) -> machine code (no human readble)

Instead of the programmer writing the binary sequence 10110000 01100001 (machine language), the programmer writes the mnemonic MOV AL, 97 (Assembly), which is much easier to remember.

There are many assembly languages, not just one

The Assembly language is specific to the processor (CPU) architecture

Each processor family (such as Intel/AMD’s x86/x64, ARM for mobile and Raspberry Pi, or MIPS) has its own unique instruction set, and therefore its own assembly language dialect.


Compiler vs. Interpreter

A compiler is a program that translates all the source code of a language into machine (binary) code before execution.

  • Advantages: The resulting program is very fast because the translation is done only once.
  • Disadvantages: The compilation process can be slow, and if there are errors, the code won’t run at all.

An interpreter is a program that reads and executes source code line by line during runtime.

  • Process: The code is translated and executed instruction by instruction, without generating a separate binary file. Languages ​​like Python and JavaScript use interpreters.
  • Advantages: Execution can begin immediately, and it is easier to debug the code (detect errors).
  • Disadvantages: The program is generally slower than compiled code, since each line must be translated each time it is executed.

Imperative vs. Declarative Language: This classification refers to the paradigm or style with which the programmer tells the computer what to do.

  • Imperative Language (The “How”)
    • An imperative language focuses on how the computer should achieve a result, specifying a sequence of steps or commands that modify the state of the program (the value of the variables)
    • Specify the algorithm step by step
    • Languages: C, C++, Java, Python (although Python is multiparadigm, much of its use is imperative)
  • Declarative Language (The “What”)
    • A declarative language focuses on what you want to achieve or the end result, without explicitly specifying the sequence of steps or control flow to achieve that result. The system (the language engine) decides the best way to execute the task.
    • Describe the desired outcome or logical relationships
    • Common Example: Querying a database to obtain a data set that meets certain conditions (without telling it how to search for the data)
      • Languages:
        • SQL: For databases.
        • HTML/CSS: For describing the structure and style of a web page.
        • Prolog: For logic programming.
        • Haskell: For functional programming.

compiler languaje:

A compiler is a program that takes source code and returns machine code.

In the C language there is an extra intermediate step and that is that it transforms source code into object language (.) and finally into machine code.

A modern C compiler (such as GCC or Clang) is designed to be portable and target-specific.

The C compiler works in several stages, and the final goal is not just the assembly language, but executable machine code.

C compiler backend: Generates code for the target architecture. This is where the correct assembly is chosen.

The secret is that large compilers like GCC and Clang have multiple “backends” (or code generators). Each backend knows how to translate the intermediate representation of the code into a specific assembly dialect.

for example:

  • If you’re compiling a program for your desktop PC (Intel/AMD), the compiler uses the x86-64 backend and generates x86-64 Assembly.
  • If you’re compiling the same C code for a Raspberry Pi or an Android phone, the compiler uses the ARM backend and generates ARM Assembly.

Your C code is unique, but the compiler can generate hundreds of different Assembly dialects from it, depending on the target platform you specify when compiling (for example, using flags like -target). The compiler selects the Assembly version that the target CPU knows how to run.

C’s strength is its portability and flexibility of destination, c is that it can convert c code to various assemblies

The great strength of the C language is its ability to convert the same source code to the Assembly dialects required by virtually any hardware architecture, making it incredibly portable and efficient.

This capability is due to the design of its compilers (such as GCC and Clang), which can generate optimized code for multiple platforms, from microcontrollers to supercomputers.

Portability (Write Once, Compile Anywhere): Unlike Assembly code, which must be rewritten for each processor type, a program written in C can be moved from an Intel CPU to an ARM CPU or a specialized chip (DSP) simply by recompiling with the appropriate compiler backend.

Abstraction without Sacrificing Efficiency: C offers a layer of abstraction over the hardware (you don’t have to worry about registers or binary code), but it is designed so closely to the hardware that the generated Assembly code is extremely efficient and fast, almost as good as if it had been written manually in Assembly.

Foundation of Modern Software: This flexibility is why C became the basis for almost all modern operating systems, databases, hardware drivers, and programming languages.


intermediate language

jvm: java virtual machine (The JVM is an Interpreter)

The Java Virtual Machine (JVM) is the runtime environment that makes Java portable. Essentially, it acts as a virtual CPU.

Just-in-Time (JIT) Compiler: To improve performance, modern JVMs use a JIT compiler. The JIT detects frequently used bytecode (“hot” code) and compiles it directly to native machine code while the program is running. This significantly speeds up performance by combining the best aspects of interpretation and compilation.

Java is a compiled language, Java executes bytecode in the JVM, the JVM is an interpreted language, which actually executes C code, which is translated into assembly and which is translated into machine code.

The JVM is written in native code (C/C++) and its instructions are converted to Assembly and finally to native machine code by the operating system.

Java -> JavaC (compiler) -> Bytecode -> JVM (interpreted language, like JavaScript) -> C -> Assembly -> Machine Code

That compiled code (the JVM program) is ultimately translated into Assembly and then into native machine code by the operating system and hardware, so that the processor can execute it.

Java is Compiled to Bytecode

Bytecode is an intermediate language designed to be machine-independent.

A Java program is compiled to Bytecode, which is interpreted and/or compiled by the JVM (written in C/C++), which ultimately interacts with the hardware like any other native program.


category of programming languages:

The classification of programming languages ​​into low-level, medium-level, and high-level refers to the degree of abstraction they offer from computer hardware. In simple terms, it describes how close the language is to the way a machine thinks (binary) and how close it is to the way a human thinks (natural language and logic).

low level ( assembly):

Speed/Efficiency: Very high, since instructions are executed directly by the processor.

Intermediate Level Language (example: c, c++)

This category often refers to languages ​​that combine features from both extremes.

C: Ideal for operating systems, hardware drivers, and firmware. It allows you to manipulate memory directly using pointers.

High Level Language (example: Java, Python)

These languages ​​are designed to be easy for humans to read and write, completely abstracted from the details of the hardware. The programmer focuses on logic and problem-solving, not on memory or register management.

They use natural language-like syntax and automatically manage memory (e.g., Garbage Collection).

Speed/Efficiency: Generally lower than C/Assembly, as they often require an interpreter or virtual machine to run.

Portability: Excellent. The code typically doesn’t require modification to run on different operating systems or architectures.

examples:

  • Python, Ruby: Focused on productivity, web development, and scripting.
  • Java, C#: Rely on a Virtual Machine (JVM or .NET) to ensure cross-platform portability.