Ilyes Abdellatif
Ilyes Abdellatif

Reputation: 21

Difference between compiling, debugging, executing and running

I am new to programming. Additionally, I am super confused about compiling, debugging, executing, running. What does each of them mean and what starts first? Thanks.

Upvotes: 1

Views: 4299

Answers (2)

mazine hamza
mazine hamza

Reputation: 1

Compiling, debugging, executing, and running are all fundamental concepts in software development, particularly in the context of programming languages and software programs. Here's an explanation of each term:

- Compiling:

Compiling is the process of translating human-readable source code written in a programming language (such as C, C++, Java) into machine-readable code, typically in the form of binary executable files. The compiler checks the source code for syntax errors, resolves references between different parts of the code, and generates the corresponding machine code. This step results in a compiled program that can be executed by the computer's processor.

- Debugging:

Debugging is the process of identifying and fixing errors or bugs in a program. Bugs can manifest as unexpected behavior, crashes, or incorrect output. Debugging involves various techniques and tools to locate the source of the problem, such as using breakpoints, stepping through code, inspecting variables, and analyzing error messages. Debugging aids in making the program function correctly and as intended.

- Executing:

Executing refers to the act of running a compiled program or script on a computer's processor. When a program is executed, the processor interprets and carries out the instructions present in the program's machine code. The program's logic is executed, producing the expected output based on the input and the algorithm defined in the source code.

- Running:

Running is a more general term that encompasses the entire process of preparing, executing, and interacting with a software program. It includes compiling (if necessary), executing, and dealing with any runtime issues that might arise. When a program is running, it's actively processing data, performing calculations, and responding to user interactions.

In summary:

Compiling involves translating source code into machine code.
Debugging focuses on finding and fixing errors in the code.
Executing involves running the compiled machine code on the computer's processor.
Running encompasses the entire process of preparing, executing, and interacting with a software program.

Upvotes: -1

Alberto Zanovello
Alberto Zanovello

Reputation: 158

without make it complicated

  • compile: make your code executable, creating a file that can be executed
  • debug: is the action of check your code for execution instruction by instruction
  • execute/run: make your code produce the result that you coded for

C basic example

requisite

  • gcc (compiler)
  • shell (ex: bash)
  • terminal emulator

getting started

the main folder:

PROJECT
│ 
├─ README.md
│ 
└─ main.c

  • main.c: this file contain the code

 #include<stdio.h>
 int main(void)
 {
    char ch = 'd';
    printf("hello worl%c",ch);
    return 0;
 }

  • README.md: contain the explanation of the project

Compile

open the terminal in this folder and enter:

gcc -o build/out main.c
  • gcc: the compiler executable
  • -o build/out: the name of the output
  • main.c: the name of the file to compile

than this is what we should see

PROJECT
│ 
├─ README.md
│ 
├─ build
│  └─ out
│ 
└─ main.c

<!-- build is just the name of the 
folder were the executable is placed -->

Execute/Run

open the terminal in this folder and enter:

./build/out

# result:
# > ./a.out
# hello world 

Upvotes: 2

Related Questions