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

learn more… | top users | synonyms

0
votes
0answers
39 views

Java platform vs Source/Binary format settings in Netbeans

I've just wanted to get to know what these particular settings really do: Project Properties -> Libraries -> Java Platform Project Properties -> Sources -> Source/Binary Format After a little bit ...
4
votes
1answer
111 views

Do java .class files have a lexer/parser?

I've been learning ANTLR, by writing my own (extremely simple!) programming language It made me curious about how the lexer/parser/AST is implemented for java. Obviously there is a grammar for .java ...
1
vote
4answers
136 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 ...
2
votes
3answers
210 views

How can I implement an 'if' statement in an interpreter?

If I were writing a compiler (say for a stack-based VM), the code for an if statement: if (<some_expression>) { <some_instructions> } Would be translated to the following ...
1
vote
1answer
123 views

Compile new JVM language down to Java or JVM bytecode? [closed]

I am making a new hobbyish programing language and want to target the JVM. Do I lose any optimization opportunity if I choose to compile my language down to Java instead of the JVM bytecode?
0
votes
0answers
50 views

Single import in a large file vs. multiple imports in smaller files. [Golang]

I'm sure the folks at Google worked long and hard to ensure the programmer wouldn't have to worry about details like this, but I'm curious. In Go if I have multiple files in the same package, but ...
0
votes
0answers
58 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, ...
2
votes
2answers
185 views

When to use ANTLR and when to use a parsing library

I've always wanted to learn how to write a compiler - I've decided to use ANTLR, and am currently reading through the book (its very good by the way) I'm pretty new to this, so go easy, but the jist ...
2
votes
3answers
137 views

Will C compiler attach the whole object code of the header file?

When you compile a C source code does the compiler convert the whole header file to object code or just the functions of the header file you use? Like for example, in the header file #include ...
0
votes
2answers
131 views

How are ASCII code associations actually stored and retrieved?

So, I was reading about bootstrapping, compilers, and the classic example of writing support for escape sequence support came up, where a program is written with a short snippet referring each escape ...
2
votes
0answers
64 views

Loop Unfolding and Named Significant Bits

I've been writing a Parser Compiler for the last seven or so years, and I recently got to the point (yet again, never satisfied) of structuring the portion dealing with the portions of the language ...
1
vote
1answer
105 views

Allow user to enter DSL, rules or code?

I have a python library that allows me to define rules by chaining inputs and outputs of functions ( producer(grep(count( [print(),log() ] ))) This functions define a pipeline from left to right. ...
2
votes
3answers
151 views

Which components/phases of a JIT compiler are different from a traditional ahead of time compiler?

Besides a faster register allocation algorithm and some trade-off in control and data-flow analysis for optimization purposes, which components/phases of a JIT compiler are different from a ...
4
votes
2answers
288 views

Needs (in principle) C++ parenthesis around if statement condition?

In current C++ when body of if statements contain only one command then: Parenthesis around if condition are mandatory but block are optional. So, both examples are OK: if ( condition ) { return 0; ...
1
vote
4answers
237 views

Can every language be compiled? And can every language be interpreted? [duplicate]

I was wondering whether every interpreted language can be compiled? And can every compiled language be interpreted?
-1
votes
2answers
216 views

Does GCC optimize code to remove useless variable read operations? [closed]

I'm using GCC on ununtu 14.04. My program is written in c++ and in a case i need to check the amount of time the program needs to read a large integer array. what is the best way to do this without ...
4
votes
3answers
438 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 ...
4
votes
1answer
619 views

How do I add link-time optimization capabilities to my LLVM-based compiler?

I am designing and implementing a programming language, and I am using LLVM for native code generation. Among others, performance is a key feature of the language, and as such, I am looking to ...
1
vote
3answers
361 views

From a technical point of view, could JavaScript be compiled instead of interpreted?

The question title speaks for itself. I'm specifically thinking in terms of a Node.js server. Additionally, this question is assuming that you don't need eval(). Also, if this is not possible, why ...
5
votes
1answer
724 views

Why did GCC switch from Bison to a recursive descent parser for C++ and C?

Was there a language change that required it or some practical reason why Bison was no longer appropriate or optimal? I saw on wikipedia that they switched, referring to the GCC 3.4 and GCC 4.1 ...
7
votes
6answers
1k views

Why don't compilers inline everything? [closed]

Sometimes compilers inline function calls. That means that they move the code of the called function into the calling function. This makes things slightly faster because there's no need to push and ...
0
votes
2answers
103 views

How do we add software to a machine? [duplicate]

When we build a new machine, how do we add software to that machine? I know we have assemblers and compilers that convert the high-level code into machine code for it to understand. But having ...
0
votes
2answers
357 views

Writing a superset of a programming language as a transcompiler

My idea is to write a superset of C# (but question is not language-specific), so that it source-to-source compiles (transcompiles) to C# itself (fall-through switch clauses, default method parameters ...
1
vote
2answers
187 views

Is a book that teaches how to build compilers good for learning to implement interpreters? [closed]

I'm looking for a book to learn how to implement interpreters for programming languages. Thing is there are much more 'compiler books' than 'interpreter books'. So my question is: can I read a book ...
62
votes
11answers
8k views

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 ...
9
votes
5answers
2k views

Do compiler-writers actually need to 'understand' machine code? [closed]

Might be kind of an odd question. A guy writing a C++ compiler (or whatever non-VM language): Does he need to be able to read/write raw machine language? How does that work? EDIT: I am specifically ...
0
votes
0answers
120 views

Succinct Lazy Initialization Pattern

Background I often use the following lazy initialization pattern: public class Clazz { private Object object; private Object getObject() { Object object = this.object; if( object == ...
0
votes
4answers
317 views

What exactly is Virtual Machine Bytecode? [closed]

I want to work on a very simple compiler for a very simple language. The compiler will compile the code to some basic bytecode. Later, a virtual machine program will run the bytecode, and execute the ...
0
votes
1answer
358 views

Creating a very basic compiler using Java

I want to try and create my own very basic language, with it's very basic compiler. All using Java. For now, it will only need to enable to 'programmer' to print things to the screen. I had an idea ...
13
votes
4answers
3k views

Why can't native machine code be easily decompiled?

With bytecode-based virtual machine languages like Java, VB.NET, C#, ActionScript 3.0, etc., you hear sometimes about how easy it is to just go download some decompiler off the Internet, run the ...
1
vote
1answer
121 views

Where can I find Turbo Pascal dialect description/reference? [closed]

Where can I find Turbo Pascal dialect description/reference? Is it still availiable in some place? I'm looking for the famous Turbo Pascal dialect description/reference(yes, the one from 80s/90s time) ...
12
votes
1answer
294 views

What intermediate representations can be used to reason about concurrency?

I am trying to better understand what would be required for a compiler to be able to make intelligent choices regarding concurrency on behalf of the programmer. I realize that there are many difficult ...
1
vote
0answers
82 views

What are the tools required to build a compiler? [duplicate]

What are the various tools that are required to build a compiler for a particular programming language, say C? I want to know how each part of the compiler works. So, I am trying to use all the ...
2
votes
2answers
559 views

How to safely run random binary codes? [closed]

Okay, so I am looking for a way to safely run a randomly generated binary code. I also need to be able to decompile the code. Any ideas and all programming languages are welcome. BTW it most be ...
2
votes
3answers
412 views

What code lays behind C++ exception?

In C and C++ you can return a single variable inside a function. Now in the case that variable is returning data, and not an error code, you can use exceptions. But how is that possible? If you data ...
4
votes
2answers
516 views

Optimizing code generation for expressions in a compiler

I don't know if this question has a simple answer or not, but I just have to ask. I'm reading this tutorial (I don't know if this is a well-known series, but it's name is 'Let's build a compiler!' by ...
0
votes
2answers
1k views

Path to learning compiler design [closed]

I'm not sure if this is an acceptable question, but compiler-os-design-where-to-start was, so I figured that I'd take a shot at it. I have taken no formal Computer Science classes. I have programmed ...
4
votes
2answers
293 views

Should I commit my generated parser to source control?

I'm using a parser generator to build a compiler. Should I commit the source files produced by the parser generator? I want to commit them to avoid a dependency on the parser generator during the ...
0
votes
2answers
3k views

How would I make a compiler in C++? [closed]

This probably been asked for but I can't google "How to make a compiler in C++" because I will just get "How to compile C++" as the results. Anyway, for my question, I'd like to make a simple ...
7
votes
5answers
541 views

Is it a good idea to read compiler source code? [closed]

I'm a junior in college majoring in Computer Science. Apart from writing lots of code, I want to start reading source code written by others to improve my coding skills and learn better/different ways ...
5
votes
2answers
855 views

Implementing non-fixed length array support in a compiler

I'm thinking of building a language for PIC microcontrollers. I want to be able to use non-fixed size arrays, like this: Declare the variable as int[] Wait for input from serial connection Make the ...
5
votes
3answers
12k views

Understanding stack frame of function call in C/C++?

I am trying to understand how stack frames are built and which variables (params) are pushed to stack in what order? Some search results showed that the C/C++ compiler decides based on operations ...
3
votes
1answer
1k views

What is the Ken Thompson Hack? [duplicate]

I read some stuff like cm bell labs but i couldn't get it all. How does it work really? What is the logic in that?
4
votes
3answers
433 views

Compiling multiple languages and Javascript

I have read numerous times that programming languages when making games or large software often use multiple languages / scripts together. I'm wondering how that works. How do they compile it? How ...
8
votes
3answers
526 views

Convert an interpreter to a compiler?

First off, I know this is a question asked by MANY other programmers before me. But I couldn't find any useable resource that could help me. Well, I'm creating an programming language called "Light" ...
104
votes
10answers
28k views

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 ...
6
votes
3answers
587 views

What are the challenges related to typing in writing a compiler for a dynamically typed language?

In this talk, Guido van Rossum is talking (27:30) about attempts to write a compiler for Python code, commenting on it saying: turns out it's not so easy to write a compiler that maintains all the ...
0
votes
0answers
468 views

Steps in converting a grammar to LL(1) Grammar

I have the following question: Convert the following grammar into an LL(1) grammar which recognises the same language (you may assume that the grammar is unambiguous). A -> int A -> int + A A ...
4
votes
4answers
2k views

Can someone provide a short code example of compiler bootstrapping?

This Turing award lecture by Ken Thompson on topic "Reflections on Trusting Trust" gives good insight about how C compiler was made in C itself. Though I understand the crux, it still hasn't sunk in. ...
34
votes
6answers
18k views

Why does Facebook convert PHP code to C++? [closed]

I read that Facebook started out in PHP, and then to gain speed, they now compile PHP as C++ code. If that's the case why don't they: Just program in c++? Surely there must be SOME errors/bugs when ...