Questions tagged [compiler-construction]

The tag compiler-construction should be applied to questions concerning the programming of compilers or for questions about the detailed inner workings of compilers. DO NOT USE for questions about *using* specific compilers or compilation errors.

A compiler is a program which translates one language into another. Compiler construction is the process of creating a compiler.

The tag should be applied to questions concerning the programming of compilers or for questions about the detailed inner workings of compilers.

One language to another? I thought they made executables!

Few compilers do exactly that:

  • They mostly translate a human readable computer programming language (like Fortran, Cobol, Algol, PL/1, Pascal, C, C++, C#, etc.) into an object-code file which has to be subsequently linked.

  • Many real world compilers translate a high level language into assembly code which is subsequently assembled by a separate program and then linked.

  • The standard Java compiler translate Java code into JVM bytecode, which must be run by a dedicated program (the JVM) which may include a Just In Time (JIT) or HotSpot compiler that translates the bytecode into native machine instructions on the fly.
  • Early versions of Unix came with a Fortran-to-C compiler.
  • The earliest versions of the language that became C++ were compiled into C by a program called cfront.
  • Many other examples of source-to-source compilers exist.
  • Some languages such as JavaScript and many other 'scripting' languages don't have compilers at all, but are executed directly from source code.

Big List of Resources:

11618 questions
784
votes
17 answers

What is an application binary interface (ABI)?

I never clearly understood what an ABI is. Please don't point me to a Wikipedia article. If I could understand it, I wouldn't be here posting such a lengthy post. This is my mindset about different interfaces: A TV remote is an interface between the…
claws
  • 52,236
  • 58
  • 146
  • 195
697
votes
38 answers

Learning to write a compiler

Preferred languages: C/C++, Java, and Ruby. I am looking for some helpful books/tutorials on how to write your own compiler simply for educational purposes. I am most familiar with C/C++, Java, and Ruby, so I prefer resources that involve one of…
Anton
  • 12,285
  • 20
  • 64
  • 84
635
votes
18 answers

What does a just-in-time (JIT) compiler do?

What does a JIT compiler specifically do as opposed to a non-JIT compiler? Can someone give a succinct and easy to understand description?
Michiel Borkent
  • 34,228
  • 15
  • 86
  • 149
516
votes
5 answers

How does the compilation/linking process work?

How does the compilation and linking process work? (Note: This is meant to be an entry to Stack Overflow's C++ FAQ. If you want to critique the idea of providing an FAQ in this form, then the posting on meta that started all this would be the place…
Tony The Lion
  • 61,704
  • 67
  • 242
  • 415
321
votes
13 answers

Compiled vs. Interpreted Languages

I'm trying to get a better understanding of the difference. I've found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython…
chimeracoder
  • 20,648
  • 21
  • 60
  • 60
299
votes
5 answers

What's the difference between __PRETTY_FUNCTION__, __FUNCTION__, __func__?

What's the difference between __PRETTY_FUNCTION__, __FUNCTION__, __func__, and where are they documented? How do I decide which one to use?
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
292
votes
7 answers

Clang vs GCC - which produces faster binaries?

I'm currently using GCC, but I discovered Clang recently and I'm pondering switching. There is one deciding factor though - quality (speed, memory footprint, reliability) of binaries it produces - if gcc -O3can produce a binary that runs 1% faster,…
SF.
  • 13,549
  • 14
  • 71
  • 107
286
votes
5 answers

Why does Java switch on contiguous ints appear to run faster with added cases?

I am working on some Java code which needs to be highly optimized as it will run in hot functions that are invoked at many points in my main program logic. Part of this code involves multiplying double variables by 10 raised to arbitrary…
269
votes
4 answers

What is the difference between LL and LR parsing?

Can anyone give me a simple example of LL parsing versus LR parsing?
251
votes
5 answers

compilation warning: no rule to process file for architecture i386

How can I resolve this warning? [WARN]warning: no rule to process file '$(PROJECT_DIR)/MyApp/MessageCell.h' of type sourcecode.objj.h for architecture i386
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
251
votes
11 answers

How does Go compile so quickly?

I've Googled and poked around the Go website, but I can't find an explanation for Go's extraordinary build times. Are they products of the language features (or lack thereof), a highly optimized compiler, or something else? I'm not trying to promote…
Evan Kroske
  • 4,506
  • 12
  • 40
  • 59
231
votes
14 answers

Writing a compiler in its own language

Intuitively, it would seems that a compiler for language Foo cannot itself be written in Foo. More specifically, the first compiler for language Foo cannot be written in Foo, but any subsequent compiler could be written for Foo. But is this actually…
Dónal
  • 185,044
  • 174
  • 569
  • 824
225
votes
9 answers

It is more efficient to use if-return-return or if-else-return?

Suppose I have an if statement with a return. From the efficiency perspective, should I use if(A > B): return A+1 return A-1 or if(A > B): return A+1 else: return A-1 Should I prefer one or another when using a compiled language (C) or…
Jorge Leitao
  • 19,085
  • 19
  • 85
  • 121
219
votes
16 answers

Where are static variables stored in C and C++?

In what segment (.BSS, .DATA, other) of an executable file are static variables stored so that they don't have name collision? For example: foo.c: bar.c: static int foo = 1; static int foo = 10; void fooTest() { …
Benoit
  • 37,894
  • 24
  • 81
  • 116
213
votes
28 answers

Could not load file or assembly ... The parameter is incorrect

Recently I met the following exception at C# solution: Error 2 Could not load file or assembly 'Newtonsoft.Json, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b9a188c8922137c6' or one of its dependencies. The parameter is incorrect.…
Liker777
  • 2,156
  • 4
  • 18
  • 25
1
2 3
99 100