A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code).
39
votes
13answers
5k views
How safe is it to compile a piece of source code from a random stranger? [closed]
Suppose I'm reviewing code that job applicants send to prove their skills. Clearly I don't want to run executables they send. Not so clearly I'd rather not run the result of compilation of their code ...
4
votes
5answers
607 views
Compilation to bytecode vs machine code
Does compilation that produces an interim bytecode (like with Java), rather than going "all the way" to machine code, generally involve less complexity (and thus likely take less time)?
28
votes
6answers
6k views
Why do programs use call stacks, if nested function calls can be inlined?
Why not have the compiler take a program like this:
function a(b) { return b^2 };
function c(b) { return a(b) + 5 };
and convert it into a program like this:
function c(b) { return b^2 + 5 };
...
1
vote
1answer
72 views
How do Java AOT compilers work?
There are a few number of tools out there (Excelsior JET, etc.) that claim to transform Java app's into native executables (*.exe). However it is my understanding that these tools are really just ...
8
votes
8answers
1k views
What stops C from being compiled/interpreted/JIT'ed?
Java is often praised for its amazing portability, which I presume is because of the JVM. My question is what stops C from being being compiled/interpreted/JIT'ed.., if so, C can also be write once ...
0
votes
2answers
92 views
Difference between PyPy and JVM
From my understanding the default Python interpreter(CPython) compiles source code into bytecode and then interprets the bytecode into machine code. PyPy on the other hand makes use of JIT to optimize ...
2
votes
5answers
511 views
Should I use a source-to-source or a traditional compiler in order to develop my own Programming Language?
I'm really interested in writing my own general-purpose high-level programming language, but I'm somewhat confused.
I know that Python and Ruby were written in C, which makes me wonder that if I want ...
2
votes
1answer
64 views
How do hybrid interpreter-JIT compilers work?
Chrome's V8 compiler, the Java HotSpot compiler, and many more have multiple tiers of interpretation and compilation.
A function starts off as interpreted in HotSpot and then, if it is run often ...
1
vote
4answers
129 views
const reference and const pointer. How do they work?
I read a post about how const storage works.
How does const storage work? (Item 2, Scott Myers Effective C++)
This says that each segment has separate section of write protected memory and const ...
0
votes
1answer
115 views
AST processing and usefulness of visitor pattern
I know the visitor pattern is typically used to traverse a hierarchy of heterogeneous objects (inheriting a same abstract object) and dissociate the processing of these objects from the data within ...
0
votes
1answer
143 views
Is it bad to implement a language in other two languages? [closed]
Ok, so I have some understanding about parsers and compilers, at least the basics of how it works, and i've written a calculator and a really small toy language that compiles to another high-level ...
6
votes
2answers
157 views
What is the minimum practical definition for the Scheme language?
What is the smallest practical set of primitives that can be used to define the Scheme language?
For example, map can be defined as
(define (map proc lis)
(cond ((null? lis)
'())
...
0
votes
0answers
53 views
Android runtime - does ART miss optimization opportunities over Dalvik?
Is ART a strict improvement over Dalvik, or there are optimizations that an ahead-of-time compiler will miss compared to JIT, but Google decide they don't matter in practice?
For example, with JIT, ...
0
votes
0answers
37 views
Turn gfortran runtime errors into warnings
I'm attempting to debug some code which I'm writing as an extension to a much larger program. I'm pretty sure I'm corrupting memory somewhere, but for practical reasons (long run time), it's not ...
33
votes
6answers
1k views
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 ...
1
vote
1answer
262 views
How would a compiler turn an else-if cascade into a switch?
I don't like switch in C and its descendants. Maybe it's the need for a break or the clumsiness of the syntax requiring a shifting of mental gears, I don't know.
Whatever the reason, I will almost ...
4
votes
4answers
282 views
Why use an enum to determine node type in a parse tree?
The Sun Compiler Tree API uses an interface called Tree as the parent of all the different kinds of parse tree nodes (assignments, if-statements, class declarations, etc.). A part of this interface is ...
0
votes
1answer
136 views
How can frond-end developer support different encoding (UTF-8 , UTF-16,..)other than ASCII? [closed]
I'm writing simple language compiler frond-end (based on LLVM) in C++, and I wonder how could language support encoding stuff?
How can I (as compiler writer) support encoding?
I need to know the ...
-1
votes
2answers
246 views
Is functional language without runtime written in C possible?
Every functional language that compiles to native code relies on quite big runtime written in C programming language (well at least ones that I know of, for example Haskell, OCaml, Gambit/Chicken ...
1
vote
1answer
148 views
Hypothetical : What restrictions will I need to add to Java so that I can remove its GC? [closed]
This is a hypothetical, yet very technically precise question I'm trying to ask all the compiler/static analysis programmers.
I'm trying to understand the extent of prohibitive features I would need ...
1
vote
2answers
151 views
Do today's modern compilers perform run time checks?
This is regarding compilers.
Do compilers perform run time dependency checks to decide to vectorize a loop ? In other words, do compilers trace through the logic as it would in run-time to ...
55
votes
5answers
11k views
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 ...
0
votes
1answer
415 views
Why are language features more popular than compiler design? [closed]
If we had a universal interpreter for all available features of programming languages we could use a specializer to generate compilers for all languages. We could simply use any language as source (or ...
5
votes
3answers
271 views
Is prototypal inheritance inherently slower?
I see Javascript 6 will add traditional class based inheritance, and one argument I hear is that classes are inherently much faster than prototypes because they can be optimized away by the compiler ...
25
votes
4answers
5k views
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 ...
2
votes
1answer
92 views
Managing types and conversions in a compiler
I am trying to determine how to manage types and conversions between types within a compiler that I am writing. The compiler is being written in C#.
There are a number of different kinds of types.
...
1
vote
0answers
50 views
Advantages of tiling based instruction selection algorithms with tiles representing more than one machine instruction?
In Modern Compiler Implementation in C of A. Appel some instruction selection algorithms are discussed based on tiling an intermediate representation tree. Each tile (or tree pattern) expresses a ...
1
vote
2answers
73 views
Should benchmarks (to compare processors performance) be compiled with optimization CFLAGS?
I need to compare performance of 2 processors and I concluded I should benchmark then with several various tests.
I'm currently using
linpack (HPL) (because it's still well known and used for ...
3
votes
2answers
283 views
Is it always safe to shift bool values?
I stumbled about a Cppcheck warning (an inconclusive one), that I mistakenly used & instead of &&:
/// @param code identifies the command. Only the lower 16 bits of are being processed
...
0
votes
1answer
153 views
(almost) Pure C instead of C preprocessor [closed]
Why isn't (almost) pure C used instead of the C preprocessor?
Sure I understand it would be a little more verbose. For example:
#define PI 3.14159
If we had regular C as preprocessor language, the ...
27
votes
3answers
3k views
Why might it be difficult to make a 64 bit version of a program?
In my short time programming, it has been trivial to compile any of my C++, Java, etc. for either a 32 or 64 bit machine so long as I have the full source for the program.
But a lot of software is ...
26
votes
6answers
2k views
What are the caveats of implementing fundamental types (like int) as classes?
When designing and implenting an object-oriented programming language, at some point one must make a choice about implementing fundamental types (like int, float, double or equivalents) as classes or ...
0
votes
1answer
136 views
Can most compilers check for errors? [closed]
I am a beginner at programming; so far all the compilers I have used can check for errors, and can refer to the line with the error. Are there any compilers, maybe for a certain language, that do not ...
2
votes
1answer
227 views
Developing a compiler for a self made CPU Architecture
Recently ive been consumed by creating my own simple CPU architecture that at some point could be easily implemented in hardware (No FPGA, but actual Logic Gate circuits). Naturally to fulfill this ...
4
votes
2answers
622 views
Isn't there a chicken-and-egg issue since GCC is written in C++ itself?
Since 4.8 release, the C++ compiler GCC (the G++ part of it) is written not in C anymore, but in C++ itself. I have a hypothetical question on this.
I wonder how to compile the C++ code of GCC on a ...
3
votes
2answers
183 views
Do compilers attach the Garbage Collector to the final executable?
Since the Garbage Collector is part of the language implementation (not OS, etc.), does the compiler has to attach the GC to the final executable? Or is it like a dependency that has to be already ...
1
vote
2answers
92 views
Enumerated types and their interpretation by compilers
It seems to me that a lot, if not most, compilers treat enumerated types as int underneath. In C/gcc, enums are compiled to int. In C#/Visual C#, you can change the underlying data type with something ...
3
votes
5answers
833 views
Creating a sort of 'in-language compiler'
I'm not saying I want to create a whole new compiler that's completely independent. I'm using C# Windows Forms and I want users to be able to write filtering syntax in a textbox withing my managed ...
4
votes
7answers
972 views
Why are self-hosting compilers considered a rite of passage for new languages?
I've heard in a number of places now that people expect languages to use, or at least have, a self-hosting compiler in order to deserve respect.
I'm curious as to why this is. A compiler seems like a ...
0
votes
1answer
140 views
Significance of NFA in Compiler Design
While I was studying about Compiler Design it tells that we need 'finite automata' while designing a lexical analyzer like DFA or NFA. So I would like to know whether NFA is only used for conversion ...
0
votes
2answers
123 views
Optimizations in Compiler Design
While studying about Optimization in Compiler Design I went through an article that tells about 'Algebraic Simplification And Reassociation' in optimization.It tells that using this(algebraic ...
1
vote
0answers
311 views
First and Follow Algorithm in Compiler Design
While I was studying Compilers,I saw an example in first and follow that illustrated how to 'find the first and follow' non-terminals in a grammer.
But I couldn't get how FOLLOW(E')=FOLLOW(E)={ $ ,) ...
2
votes
2answers
158 views
Do we really need auto-vectorization?
I am trying to understand automatic parallelization and a special case of that is auto vectorization. As I understand it auto-vectorization is more or less:
The compiler takes parts of the code which ...
3
votes
1answer
249 views
What advantages are there to using Flex/Bison over just writing a compiler straight in a programming language?
I have written an Interpreter / Compiler simply as a programming algorithm using features such as recursive functions and concepts from finite-State machines. To me, these things are ideally suited to ...
0
votes
0answers
186 views
Best way to handle language interoperability
Background
In a language like F#, direct interoperability with most other .NET languages is possible. For example, it is possible to use classes written in C# directly in F#, and it is possible to ...
10
votes
5answers
2k views
When does it make sense to compile my own language to C code first?
When designing an own programming language, when does it make sense to write a converter that takes the source code and converts it to C or C++ code so that I can use an existing compiler like gcc to ...
-2
votes
2answers
82 views
Debug symbols change application execution [closed]
I have to set up remote debugging for a multi threaded application running on a embedded device. C++ is the language.
I've gotten so far and got the remote debugging working for a simple application, ...
17
votes
4answers
1k views
Why implement a lexer as a 2d array and a giant switch?
I'm slowly working to finish my degree, and this semester is Compilers 101. We're using the Dragon Book. Shortly into the course and we're talking about lexical analysis and how it can be implemented ...
4
votes
3answers
428 views
How do I compile my software for all platforms from Ubuntu Linux 64 bit?
I write a lot of open source software that I make available on my website. How do I get my software compiled for all relevant platforms including:
Windows
OS X
Linux 32 bit deb
Linux 64 bit deb
...
2
votes
1answer
325 views
Do compilers un-inline recurrent expressions?
Does a compiler look for recurrent expressions to convert it into 'function' to reduce binary size and improve performance?
Of course, the obvious answer might be "some do it, some don't", so I ask ...