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).

learn more… | top users | synonyms

3
votes
1answer
176 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 ...
-1
votes
1answer
90 views

Writing a compiler, which targets a custom Virtual Machine [closed]

I've been stuck on a concept for a while. I've been writing toy-languages that are interpreted recently. I've decided I want to move on and to try and create a compiler. I don't really want to use ...
8
votes
5answers
533 views

Are C static libraries frowned upon? [closed]

There are 2 arguments for having shared libraries: It helps reduce disk space. When a shared library is updated, all the binaries depending on it get the update. There is mainly one drawback for ...
1
vote
2answers
82 views

Microchip XC8: How to pack code against an upper limit?

I have a project for a PIC16F1454 that needs some custom linking. Basically, I've separated my code into two parts that can be downloaded separately in the field and thus update (almost) all of the ...
2
votes
2answers
108 views

In which stage of compilation is “typedef” resolved by the compiler?

There are different stages of compilation Such as Preprocessing stage Syntax analysis Semantic analysis Intermediate Code generation Machine Code generation Optimization Linking My question here ...
4
votes
4answers
601 views

How does Python compile some its code in C?

I read that some constructs of Python are more efficient because they are compiled in C. https://wiki.python.org/moin/PythonSpeed/PerformanceTips Some of the examples used were map() and filter(). I ...
2
votes
3answers
111 views

How exactly is an Abstract Syntax Tree created?

I think I understand the goal of an AST, and I've built a couple of tree structures before, but never an AST. I'm mostly confused because the nodes are text and not number, so I can't think of a nice ...
5
votes
2answers
381 views

C++ Without Source Files

Bjarne Stroustrup mentions in his book "The C++ Programming Language, 4th Edition" that not all C++ implementations use files to store and compile code: There are systems that do not store, ...
-2
votes
2answers
93 views

Does a custom scripting language require it's own compiler/assembler? [closed]

Or is the script generally converted to a known language such as C++ first? And how generally to you integrate a scripting language with the say a game engine?
31
votes
5answers
2k views

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 ...
0
votes
2answers
173 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 ...
47
votes
9answers
7k views

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 ...
0
votes
1answer
116 views

Coding shortcuts for type conversions or similar [closed]

bool? example = null; is actually Nullable<System.Boolean> example = null; Now for the bool to System.Boolean conversion or actually compile-time replacement: We ususally hardly care, as it ...
3
votes
1answer
161 views

Compiler warnings and errors [duplicate]

I come from a C# background before my existing role. I am developing a VB.NET app. The code I inherited had option strict set to off and all other directives set to 'None'. I have recently switched ...
-1
votes
1answer
46 views

How to keep AST for feature access?

Consider such code (let's say it is C++) Foo::Bar.get().X How one should keep the AST for this -- as "tree" with root at left Foo(Bar(get(X)), or with root at right (((Foo)Bar)get)X? Or maybe as a ...
1
vote
1answer
423 views

Why isn't there a python compiler to native machine code?

As I understand, the cause of the speed difference between compiled languages and python is, that the first compiles code all way to the native machine's code, whereas python compiles to python ...
1
vote
1answer
184 views

How does an optimizing compiler react to a program with nested loops?

Say you have a bunch of nested loops. public void testMethod() { for(int i = 0; i<1203; i++){ //some computation for(int k=2; k<123; k++){ ...
1
vote
2answers
127 views

How do I simplify a compiler/interpreter?

Recently I wrote an interpreter for operations on sparse matrices (a "sparse matrix calculator") in lex/yacc. The language is still very bare bones and doesn't even include control structures or ...
-1
votes
2answers
159 views

Is it possible to implement a native compiler for a 'managed language' such as Java?

In most cases, it is possible to create both a native compiler and an interpreter for a programming language. The compiler would simply convert the source code to machine code, and the interpreter ...
0
votes
2answers
73 views

Storing tokens during lexing stage

I am currently implementing a lexer that breaks XML files up into tokens, I'm considering ways of passing the tokens onto a parser to create a more useful data structure out of said tokens - my ...
3
votes
2answers
275 views

Are (C) object files created with different compilers binary-compatible?

I understand that C++ compilers are not compatible with each other. However, I was unable to find anything on this topic for C in particular. I know that the C standard leaves a lot of room for ...
1
vote
1answer
143 views

LLVM case: is the success due to the algorithms? [closed]

I'm not sure if this is a subjective question, I hope not but I'm not proficient with LLVM so I'm just wondering: how come it's become so popular and so widespread used in the industry? Were the ...
-1
votes
1answer
303 views

Is the microsoft C compiler (cl.exe) a compiler driver or a compiler?

gccand clang are both known to be compiler drivers. As such, the gcc executable does not compile anything itself. Rather, it calls the compiler (cc1), assembler (as) and linker (ld) with the right ...
-3
votes
3answers
183 views

Why can't we program without compiling (using an IDE/debugger)? [closed]

I find it very interesting that even people who design a particular framework still have to rely on compiling to ensure the code is correct. I don't mean for 100s of lines of code, but 2-10 lines. I ...
4
votes
1answer
247 views

Why do some embedded projects shun cross-compiling?

As I've been getting into embedded systems I've noticed that some projects (Arch Arm and OpenBSD for example) frown upon cross compiling. What is the reasoning for this? Is a cross-compiled binary ...
0
votes
4answers
533 views

How does assembly relate to machine/binary code

How does assembly relate to machine/binary code. For example here is how to print to the screen in mikeOS(a small pure assembly OS), mikeOS it uses NASM to assemble. BITS 16 ORG 32768 ...
1
vote
2answers
348 views

How do we go from assembly to machine code(code generation) [closed]

I know this is abstract as it's all about signals and switch - (electronics) - underneath, but is there a easy way to visualize the step between assembling code to machine code. For example if you ...
2
votes
4answers
175 views

Does boostrapping limit the achievable speed of the new compiler?

I have a good grasp on how the C compiler was boostrapped from itself and how that must have been very efficient, since the first pre-bootstrapping version was written in assembler, which is as low ...
4
votes
4answers
602 views

Why don't compilers support non-English keywords? [closed]

When you read C, C#, Java, Python, PHP and many other programming languages all the syntax is written in English. Simple code like this if (X+1 > 4) { } while (A == true) { } Is written in ...
4
votes
3answers
374 views

Why do some compilers generate direct machine code?

I was taking this course - CMU 18-447, Computer Architecture at Carnegie Mellon to brush my knowledge and concepts. They say that most of the machine level details and implementations is taken care ...
16
votes
4answers
860 views

Why is it so hard to recruit for compiler[-related] jobs? [closed]

Last week, a few colleauges and I were participating in career fairs at three major universities (two here in the US and one in England), where we were trying (without much success) to recruit for ...
1
vote
5answers
271 views

How to alter the code at runtime in an interpreter?

While reading the difference between Compiler and interpreter , I found the following differences fromt he internet. Advantages of using compiler: Since compiler converts the program to native code ...
1
vote
4answers
625 views

Why languages that compile to C/C++ generate unreadable, cryptic code?

I'm willing to compile certain language to C or C++ for some speedups. My idea was, though, to generate readable code and use structures such std::vector and similar wherever I can, expecting CLANG to ...
0
votes
3answers
453 views

Are VB.NET to C# converters actually compilers?

Whenever I see programs or scripts that convert between high-level programming languages they are always labelled as converters. "VB.NET to C# converter" on Google results in expected, useful hits. ...
1
vote
3answers
193 views

Requiring a specific order of compilaiton

When designing a compiled programming language, is it a bad idea to require a specific order of compilation of separate units, according to their dependencies? To illustrate what I mean, consider C. ...
0
votes
1answer
232 views

How small is the footprint of a small C compiler?

This week I could optimize using a reduced C library that allowed a drastic shrinkage in code size - from about 60 K to about 6 K and then we could load the code in the 8 K on-chip memory of an FPGA ...
0
votes
3answers
198 views

What process do typical (the majority) of high level language compilers use when changing a source-code's variable name to a machine code name?

Do long (very long) variable names slow down the compilation of source code? I'm aware that the length of variables has 0% impact on interpretation as the compiler changes them to machine code which ...
6
votes
1answer
174 views

.NET BCL Change Analysis - Uses Beyond Sating Curiosity

This is part of a series of questions which focuses on the Abstraction Project, which aims to abstract the concepts used in language design in the form of a framework. There is a sister project to ...
1
vote
2answers
146 views

Will a binary include methods that are not called in the source code?

[Potentially misleading title, but I'm not sure how best to word it.] Theoretical question on compilers and language design. Say I'm re-implementing a method in a code base. Instead of removing or ...
3
votes
1answer
453 views

Does setting a function public affect the C# compiler's ability to inline the function as an optimization?

This could be either for the .NET or Mono compilers. I know that under certain conditions the compiler can inline functions (e.g. small, single call site, etc.) as an optimization. However, if the ...
7
votes
1answer
286 views

How to use BDD to unit test a compiler?

My team is writing a compiler for a domain-specific language (DSL) which will be integrated into an IDE. Right now, we are focused on the analysis phase of the compiler. We are not using any existing ...
15
votes
5answers
886 views

Does Scrum make sense when implementing a new compiler backend?

I have an existing language that I need to port to a new platform. I'll probably attempt this by changing the backend of the existing compiler. It is a significant amount of work to re-write the ...
1
vote
1answer
164 views

Compiler design decision for dynamic method invocation

I asked about Compiler interpretation of overriding vs overloading on StackOverflow, and got good answers, but this led me to another question that I'm not sure is appropriate for SO, but I think is ...
4
votes
2answers
498 views

Learning YACC nowadays, does it make sense? [closed]

I have a huge project that is using YACC and I would need to fix a bug in it. I might ask someone else who wrote that to fix it but I'm interested in how compilers work. Does it make sense to learn ...
0
votes
2answers
175 views

Building a tool to fix compiler errors automagically

When a program doesn't compile, error messages are sometimes esoteric. Often a simple Google search leading to a site like stack exchange solves the problem. Now why can't we automate this? How ...
26
votes
10answers
3k views

Can compilers and interpreters have bugs, and what can we (as users) do to deal with them? [closed]

If a compiler's work is essentially translating source code into machine level code, can there be any glitch in a compiler, i.e. a faulty "translation?" The same goes for an interpreter: can it fail ...
11
votes
2answers
560 views

Can and do compilers convert recursive logic to equivalent non-recursive logic?

I've been learning F# and it's starting to influence how I think when I'm programming C#. To that end, I have been using recursion when I feel the result improves readability and I can't envision it ...
12
votes
2answers
820 views

What does scannerless parsing have to do with the “Dangling Else Problem”?

I do not understand this sentence from the Wikipedia article on the Dangling Else problem: [The Dangling Else problem] is a problem that often comes up in compiler construction, especially ...
0
votes
2answers
531 views

embedding programming languages into other languages [duplicate]

In C/C++, there is a keyword that allows you to enter assembly language directly into a method. Example int Main() { __asm // notify the compiler that this block is assembly language. { ...
-1
votes
1answer
207 views

Recompiling a java project while it is running

I have a Java program that takes about an hour to run. While it is running, if I change the source code and recompile it, will this affect the above run?