Questions tagged [compiler]

A compiler is a computer program that transforms source code written in one programming language into another computer language.

A compiler is a computer program that transforms source code written in one programming language into another computer language. The most common reason for wanting to transform source code is to create an executable program.

490 questions
282
votes
7 answers

How to write a very basic compiler

Advanced compilers like gcc compile code into machine readable files according to the language in which the code has been written (e.g. C, C++, etc). In fact, they interpret the meaning of the code according to library and functions of the…
Googlebot
  • 3,173
  • 5
  • 19
  • 14
173
votes
11 answers

Is Ken Thompson's compiler hack still a threat?

Ken Thompson Hack (1984) Ken Thompson outlined a method for corrupting a compiler binary (and other compiled software, like a login script on a *nix system) in 1984. I was curious to know if modern compilation has addressed this security flaw or…
Andrew
104
votes
5 answers

Why doesn't Java have optimization for tail-recursion at all?

From what I have read: The reason is because it is not easy to determine which method will actually be called as we have inheritance. However, why doesn't Java at least have tail-recursion optimization for static methods and enforce proper way to…
InformedA
  • 2,991
  • 2
  • 19
  • 28
102
votes
12 answers

Should I use a parser generator or should I roll my own custom lexer and parser code?

What specific advantages and disadvantages of each way to working on a programming language grammar? Why/When should I roll my own? Why/When should I use a generator?
Maniero
  • 10,826
  • 14
  • 80
  • 133
87
votes
6 answers

How does garbage collection work in languages which are natively compiled?

After browsing several answers an Stack Overflow, it is clear that some natively compiled languages have garbage collection. But it is unclear to me how exactly this would work. I understand how garbage collection could work with an interpreted…
Christian Dean
  • 2,790
  • 1
  • 22
  • 38
85
votes
11 answers

Why is software OS specific?

I'm trying to determine the technical details of why software produced using programming languages for certain operating systems only work with them. It is my understanding that binaries are specific to certain processors due to the processor…
user139929
  • 896
  • 1
  • 8
  • 8
82
votes
5 answers

Is Python Interpreted or Compiled?

This is just a wondering I had while reading about interpreted and compiled languages. Ruby is no doubt an interpreted language since the source code is processed by an interpreter at the point of execution. On the contrary C is a compiled…
crodjer
  • 1,039
  • 1
  • 9
  • 10
75
votes
10 answers

Why was the first compiler written before the first interpreter?

The first compiler was written by Grace Hopper in 1952 while the Lisp interpreter was written in 1958 by John McCarthy's student Steve Russell. Writing a compiler seems like a much harder problem than an interpreter. If that is so, why was the first…
anguyen
  • 861
  • 2
  • 7
  • 10
74
votes
19 answers

How come compilers are so reliable?

We use compilers on a daily basis as if their correctness is a given, but compilers are programs too, and can potentially contain bugs. I always wondered about this infallible robustness. Have you ever encountered a bug in the compiler itself? What…
EpsilonVector
  • 10,763
  • 10
  • 56
  • 103
74
votes
5 answers

Why are there so few C compilers?

C is one of the most widely-used languages in the world. It accounts for a huge proportion of existing code and continues to be used for a vast amount of new code. It's beloved by its users, it's so widely ported that being able to run C is to many…
anon
62
votes
10 answers

Is it bad practice to use a C++ compiler just for function overloading?

So I am working on a software design using C for a certain processor. The tool-kit includes the ability to compile C as well as C++. For what I am doing, there is no dynamic memory allocation available in this environment and the program is overall…
Snoop
  • 2,718
  • 5
  • 24
  • 52
61
votes
14 answers

Can we make general statements about the performance of interpreted code vs compiled code?

I'm comparing two technologies in order to reach a recommendation for which one should be used by a company. Technology A's code is interpreted while technology B's code is compiled to machine code. In my comparison I state that tech B in general…
EpicSam
  • 870
  • 1
  • 6
  • 10
58
votes
8 answers

How can we be certain that the lower components of computer programming like compilers, assemblers, machine instructions, etc. are flawless?

Since we are becoming more and more reliant on computing, including very critical tasks of day-to-day life, I was just wondering how those vital components are tested. More technically, how are the compilers and assemblers tested? (I suppose this…
Sudip Bhandari
  • 1,137
  • 1
  • 9
  • 14
58
votes
10 answers

Why was the Itanium processor difficult to write a compiler for?

It's commonly stated that Intel's Itanium 64-bit processor architecture failed because the revolutionary EPIC instruction set was very difficult to write a good compiler for, which meant a lack of good developer tools for IA64, which meant a lack of…
Mason Wheeler
  • 82,151
  • 24
  • 234
  • 309
58
votes
5 answers

What does "context-free" mean in the term "context-free grammar"?

Given the amount of material that tries to explain what a context-free grammar (CFG) is, I found it surprising that very few (in my sample, less than 1 in 20) give an explanation on why such grammars are called "context-free". And, to my mind, none…
rick
  • 1,945
  • 2
  • 19
  • 16
1
2 3
32 33