Questions tagged [compilation]

Compilation is the transformation of source text into some other form or representation. The most common usage of this tag is for questions concerning transformation of a programming language into machine code. This tag is normally used with another tag indicating the type of the source text such as a programming language tag (C, C++, Go, etc.) and a tag indicating the tool or compiler being used for the transformation (gcc, Visual Studio, etc.).

Compilation is the transformation of source text into some other form or representation. The software tool used is called a compiler. Most compilers process the source text to generate some sort of machine code for a target hardware machine. Some compilers generate the "machine code" for a target virtual machine (e.g. bytecode for a Java Virtual Machine).

In all of these cases the compiler creates new files of the transformed source text and these new files are used in some other processing step up to and including executing directly on hardware or virtual hardware.

Interpretation is the processing of source text by a software tool called an interpreter. Interpreters immediately execute the sense of the source text without generating a new, externally visible form of the source text. Compilers generate a new, externally visible form of the source text which is then executed by some other device whether actual hardware or virtual machine.

The lines between interpreters and compilers have blurred somewhat with the introduction of languages whose tools generate an intermediate language which is then executed on an internal virtual machine. The traditional compiler generates machine code files which are then further processed into an application to execute. The traditional interpreter parses the source text line by line performing some action indicated by the line of source text at the time the line of source is read.

A C or C++ compiler generates object files containing binary code which are then processed by a linker into an application and executed. A Java compiler generates class files containing Java Virtual Machine byte code which are then combined into a Java application and executed.

Engines for scripting languages such as Php and JavaScript may use an internal compiler to generate an intermediate form of the source text which is then executed by an internal virtual machine. For some types of applications the intermediate form is temporarily stored or cached so that if the same script is being used by multiple threads or multiple repetions in a short time span, the overhead of rescaning the source text is reduced to improve efficiency. However these are not considered to be compilers.

Compilation usually involves the following steps:

  • Scanning - The scanner is responsible of tokenizing the source code into the smallest chunks of information (keywords, operators, brackets, variables, literals etc.).
  • Parsing - The parser is responsible with creating the Abstract Syntax Tree (AST) which is a tree representation of the code according to the source language definition.
  • Optimization - The AST representing the code is sent through various optimizers in order to optimize for speed or space (this part is optional).
  • Code generation - The code generator creates a linear translated document from the AST and the output language definition.

In many languages and compilers there are additional steps added to the process (like pre-processing), but these are language and compiler specific.

In most cases, where compilation is a part of the build/make/publish process, the output of the compiler will be sent to the linker which will produce the ready-to-use files.

Questions using this tag should be about the compilation process, not about how to write compilers for example (use the compiler tag for that).

15850 questions
143
votes
5 answers

Why use make over a shell script?

Make seems to me simply a shell script with slightly easier handling of command line arguments. Why is it standard to run make instead of ./make.sh
HoboBen
  • 2,362
  • 3
  • 19
  • 26
137
votes
10 answers

Is it feasible to compile Python to machine code?

How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code? Presumably it would need to link to a Python runtime library, and any parts of the Python standard library which were Python themselves…
Andy Balaam
  • 5,583
  • 5
  • 31
  • 34
133
votes
2 answers

What's the dSYM and how to use it? (iOS SDK)

Sometimes the compiler produces .dSYM files. I guess this is a debugging related file, but I don't know what it is, and how to use it. What is a .dSYM? How do I use it?
eonil
  • 75,400
  • 74
  • 294
  • 482
132
votes
34 answers

Very slow compile times on Visual Studio 2005

We are getting very slow compile times, which can take upwards of 20+ minutes on dual core 2GHz, 2G Ram machines. A lot of this is due to the size of our solution which has grown to 70+ projects, as well as VSS which is a bottle neck in itself…
johnc
  • 36,657
  • 37
  • 96
  • 137
132
votes
5 answers

Compiling dynamic HTML strings from database

The Situation Nested within our Angular app is a directive called Page, backed by a controller, which contains a div with an ng-bind-html-unsafe attribute. This is assigned to a $scope var called 'pageContent'. This var gets assigned dynamically…
giraffe_sense
  • 1,323
  • 2
  • 9
  • 4
128
votes
8 answers

Just-in-Time (JiT) vs Ahead-of-Time (AoT) compilation in Angular

I was referring this documentation and came across the compilation concept. One can use either JIT or AOT compilation. However, I found it very brief and need to know following points in details, Differences between those two…
Gaurang Patel
  • 3,531
  • 6
  • 23
  • 30
127
votes
4 answers

Mismatch Detected for 'RuntimeLibrary'

I downloaded and extracted Crypto++ in C:\cryptopp. I used Visual Studio Express 2012 to build all the projects inside (as instructed in readme), and everything was built successfully. Then I made a test project in some other folder and added…
Momonga
  • 1,525
  • 2
  • 12
  • 13
124
votes
4 answers

How to compile python script to binary executable

I need to convert a Python script to a Windows executable. I have Python 2.6 installed to python26. I have created one script and kept it in C:\pythonscript. Inside this folder there are two files Setup.py and oldlogs.py (this file need…
Dewal Tewari
  • 1,249
  • 2
  • 9
  • 3
123
votes
7 answers

Compiling a java program into an executable

Possible Duplicate: How do I create an .exe for a Java program? I've just made a simple program with Eclipse and I want to compile it into an executable, but simply can't seem to find out how to do it.
Meir
  • 10,735
  • 19
  • 56
  • 70
122
votes
2 answers

What does go build build? (go build vs. go install)

New Go programmers often don't know or get confused what the fundamental go build command does. What do exactly the go build and go install commands build and where do they put the result/output?
icza
  • 289,344
  • 42
  • 658
  • 630
122
votes
3 answers

Difference between CC, gcc and g++?

What are the difference between the 3 compilers CC, gcc, g++ when compiling C and C++ code in terms of assembly code generation, available libraries, language features, etc.?
vehomzzz
  • 37,854
  • 69
  • 173
  • 207
121
votes
11 answers

javac : command not found

I have installed java in my CentOS release 5.5 machine using the command yum install java. But I am unable to compile a class using javac. Do I need to install any other package? I have tried to locate the javac executable but i am unable to locate…
Bikash Barman
  • 1,229
  • 2
  • 9
  • 4
120
votes
8 answers

C++, variable declaration in 'if' expression

What's going on here? if(int a = Func1()) { // Works. } if((int a = Func1())) { // Fails to compile. } if((int a = Func1()) && (int b = Func2())) ) { // Do stuff with a and b. // This is what I'd really like to be able to…
Neutrino
  • 6,048
  • 4
  • 37
  • 64
119
votes
6 answers

What is the difference between compile code and executable code?

I always use the terms compile and build interchangeably. What exactly do these terms stand for?
Lazer
  • 79,569
  • 109
  • 264
  • 349
114
votes
5 answers

Why doesn't the JVM cache JIT compiled code?

The canonical JVM implementation from Sun applies some pretty sophisticated optimization to bytecode to obtain near-native execution speeds after the code has been run a few times. The question is, why isn't this compiled code cached to disk for…
Chinmay Kanchi
  • 54,755
  • 21
  • 79
  • 110