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

learn more… | top users | synonyms (1)

2
votes
6answers
331 views

“Write an Assembler in C.” Why writing a machine code translator for a low level language in a higher level language?

My Microprocessor class instructor gave us an assignment and said: "Write an Assembler in C." - My beloved Professor So it seemed a little bit illogical to me. If I'm not wrong Assembly ...
2
votes
0answers
50 views

Origin of the native compiler [duplicate]

I have been using GCC in a nix environment for as long as I remember. Given the wide range of processors, such as those from Atmel, ARM, Intel, and possibly a custom-made soft-core on an FPGA, and ...
22
votes
2answers
641 views

What semantic features of Python (and other dynamic languages) contribute to its slowness?

I don't know very well Python. I'm trying to understand more precisely what exact features of dynamic languages (à la Python, Lua, Scheme, Perl, Ruby, ....) are forcing their implementations to be ...
5
votes
1answer
99 views

How to resolve generic typenames in compiler?

Let's say I have such code (and its meaning is like in C#): class Foo<T> { public T my_field; } and later in code I have: var foo = new Foo<int>(); foo.my_field = 5; My problem ...
2
votes
4answers
204 views

Is C is a portable language for new architecture or it is specific for ISA?

How C language is portable to any instruction set (I mean for new architecture). Do we have to write again C compiler for new architecture?
5
votes
1answer
94 views

Do I need to declare a delay timer variable as volatile even if I access it from another module

This is a question more about using volatile to prevent optimization than about caching write/read of a variable. Particularly timer delay variables since I don't want to declare everything volatile ...
6
votes
2answers
151 views

Do compilers utilize multithreading for faster compile times?

If I remember my compilers course correctly, the typical compiler has the following simplified outline: A lexical analyzer scans (or calls some scanning function) the source code character-by-...
6
votes
2answers
186 views

How do JIT interpreters handle variable names?

Let's say I am to design a JIT interpreter that translates IL or bytecode to executable instructions at runtime. Every time a variable name is encountered in the code, the JIT interpreter has to ...
0
votes
1answer
39 views

Security error on asp.net system after deployment of bug fix dll

I (recently inherited) a asp.net web application in production. After fixing a generic bug in the area of making a table selection - we have a problem regarding security policies not allowing access ...
1
vote
0answers
77 views

How to get verification that you've implemented all your API in a static library?

I just learned that static library building skips the linking stage, which explains why my build process succeeds all the time when it's possible I actually haven't implemented a function in my header....
4
votes
4answers
226 views

Why isn't the overloading with return types allowed? (at least in usually used languages)

I don't know about all programming languages, but it's clear that usually the possibility of overloading a method taking into consideration its return type (assuming its arguments are the same number ...
-1
votes
3answers
190 views

Are browser console errors 'compiler errors', 'runtime errors', or neither?

I was trying to communicate with a coworker about a JavaScript error I was being notified about in my browser's console window when I realized that I wasn't sure if I should refer to this as a ...
3
votes
1answer
68 views

Self-compilation in Forth

What is Self-compilation (a.k.a. Meta-compilation) in Forth? How it works and why is it useful? Does it have any practical usage and is it still used in modern systems?
2
votes
4answers
545 views

Why isn't there a primitive “complex number” type in Java?

Does anyone know why something like http://www.ipd.uka.de/JavaParty/cj/#Down was never completed and integrated into mainline java? This seems like a no-brainer... I realize the java gawds dont want ...
23
votes
3answers
2k views

In which process does syntax error occur? (tokenizing or parsing)

I'm trying to understand compilation and interpretation, step by step figuring out a total image. So I came up to a question while reading http://www.cs.man.ac.uk/~pjj/farrell/comp3.html this article ...
1
vote
0answers
60 views

How to report multiple errors as a result of validation?

I have a class that transforms a complex model, for example an abstract syntax tree or intermediate model. The model can be either valid, invalid or partially invalid, i.e. it contains errors but some ...
0
votes
2answers
208 views

Do some built-in functions loop behind the scenes?

I mostly code in C# & VB, but I think this question is pretty universal. I try to limit loops to increase performance. For instance, string functions that split the string into an array, or do a ...
0
votes
2answers
260 views

Trust .net compiler after Microsoft updates

Microsoft releases upgrades and changes to .net, msbuild and Visual Studio quite frequently. How can I be sure the MSIL code created by msbuild or the Roslyn compiler in VS 2015 will be the same or ...
4
votes
2answers
78 views

Testing strategies for interpreter language parser

For a recent personal project, I started working on an interpreter for my own programming language. One of the ground rules I set for myself on this project is that I need to properly test as much of ...
1
vote
2answers
414 views

How to reduce size of jar file?

I dont know how to reduce the size of jar file. When we normally code in Java Swing the jar file is created, is there any way to reduce the size of jar file? I can't remove the images and other stuff ...
1
vote
1answer
103 views

Compiler design prevent register override

I'm trying to write a compiler for a self-designed CPU with accompanying instruction set. The CPU has 3 registers, 2 input registers (B and C) and one output register (D). When for example an ADD ...
0
votes
1answer
140 views

Are there compilers which optimize the use of mathematical functions?

Today while programming I stumbled upon the following question - are there any compilers which optimize based on mathematical assumptions? For instance in cases like unsigned int i,b; (i,b not ...
23
votes
1answer
2k views

Why does the documentation on some languages say “equivalent to” rather than “is”?

Why does the documentation on some languages say "equivalent to" rather than "is"? For example, the Python Docs say itertools.chain(*iterables) ... Equivalent to: def chain(*iterables):...
2
votes
2answers
76 views

JIT based on precompiled code templates

This is a crazy idea that I just came up with, and I'm interested in knowing if it would be workable, or if someone already wrote about or implemented it. Imagine you are on a platform (a game ...
10
votes
4answers
375 views

Is there a standard way or standard alternative to packing a struct in c?

When programming in C I have found it invaluable to pack structs using GCCs __attribute__((__packed__)) attribute so I can easily convert a structured chunk of volatile memory to an array of bytes to ...
1
vote
1answer
130 views

Is an AST enough to build any translator? [closed]

Note: In my ignorance of the difference between Programmers vs StackOverflow sites (which I know now), I had posted this question on StackOverflow earlier. What I'm looking for is some elaboration, ...
18
votes
3answers
987 views

What is benefit that a compiler is implemented in the same language it compiles? [duplicate]

I've seen it's very common for a compiler to be made in the language it's compiling. What is the benefit of this? Seems like it makes the process for outsiders (and the developers for a while) more ...
56
votes
8answers
7k views

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 ...
-2
votes
1answer
204 views

How do I create my own Objective-C to Swift converter? [closed]

I'm really interested in writing my own converter. I know C++/Python/Objective-C/Swift and a little Haskell. There are website like objectivec2swift and iswift.org, which can convert OC to Swift ...
3
votes
0answers
379 views

Writing a Compiler - .reloc section of the COFF

I'm looking for a little bit of direction in writing a compiler. I've written in Common Intermediate Language, C#, and various other .NET languages; I've written my own Metadata Parser and now I'm ...
5
votes
1answer
127 views

Strategies to increasing the maintainability of assertions in code [closed]

Background I am writing a compiler for a custom language for a school project and it is going really well for me. If I where to start all over from scratch I would have done many software ...
0
votes
5answers
115 views

Confusion about data types, compilers, hardware data representation and static vs dynamic typing [closed]

I am trying to understand static vs dynamic typing, but am really struggling to see how everything fits together. It all starts with data types. As far as I understand, data types are quite abstract ...
1
vote
4answers
154 views

How are individual lines of code and functions stored in a Concrete Syntax Tree?

I'm trying to write a simple compiler for learning purposes. I've been reading the Dragon Book and Modern Compiler Design and one part I don't understand is how the Concrete Syntax Tree is actually ...
3
votes
1answer
210 views

Why is a frame pointer set as an offset from the stack pointer? [duplicate]

I'm trying to understand how stack frames are constructed and have run into this description on wikipedia: The locations of all other fields in the frame can be defined relative either to the ...
1
vote
2answers
267 views

How do Symbol Tables, Lexers and Parsers work together in a modern design? [closed]

I'm working on creating my own scripting language for learning purposes. I've been reading through the Dragon Book and some things are a little unclear to me regarding the Symbol Table as well as ...
-1
votes
2answers
78 views

Abstract Syntax Tree with parent or not? [closed]

My question is as simple as the title says -- should I implement AST with parent or not? Currently I implemented it with parent -- the benefit of that approach is, that whatever I use, I can go up or ...
2
votes
1answer
127 views

Questions about compiler/interpreter design [closed]

I am implementing a programming language, for fun, in C. I have most of the parsing code done and also the AST ready. I once did write a runtime for this language some time ago, but I had some trouble ...
39
votes
6answers
5k views

Does an interpreter produce machine code?

I study the topics of compilers and interpreters intensively. I want to check if my base understanding is right, so let's assume the following: I have a language called "Foobish" and its keywords are ...
5
votes
2answers
495 views

How are scripting languages compiled?

I know the term "scripting languages" is just a subset of programming languages, but I want to refer to programming languages such as Python and Ruby among others. First of all, why don't we need a ...
3
votes
2answers
74 views

Implementing incremental builds [closed]

I'm working on a toy language. Until now, multiple files have been compiled by merging the ASTs of each file and then running the semantic analysis and code generation phase on the merged AST. Now I'...
1
vote
1answer
101 views

Why some compilers do not synthesize the move operations at all per this paragraph in C++ Primer 5th?

In particular, if a class defines its own copy constructor, copy-assignment operator, or destructor, the move constructor and move-assignment operator are not synthesized. —— quote from "13.6.2. ...
2
votes
1answer
307 views

Dependency ordering algorithm of a compiler

Let's say, hypothetically, I'm writing a Java compiler. And we assume that in my case a class can't be fully compiled until all signatures of dependencies (imports and other used classes) are known. ...
0
votes
2answers
106 views

How does the LLVM compiler treat arithmetic operations in parentheses?

When it sees the parentheses, does it have the machine do the operations in the parentheses first, or does it distribute out the parentheses? Like, if I have the following line of code: int i = 2 * (...
4
votes
2answers
165 views

Mutable AST vs. different immutable ASTs

I am writing a toy compiler. During the semantic passes, I want to add information to the AST. Which of the following is the best approach? Define 1 mutable AST type whose fields are updated with ...
5
votes
3answers
3k views

How does Chrome V8 work? And why was JavaScript not JIT-Compiled in the first place?

I have been researching Interpreters/Compilers, then I stumbled across JIT-Compilation - specifically Google Chrome's V8 Javascript Engine. My questions are - How can it be faster than standard ...
2
votes
4answers
147 views

Clean Abstract Syntax Tree

I'm writing a toy compiler for fun. Basically, my problem is that I don't want to clutter the AST with stuff like debug information (symbol tokens, locations of tokens, etc) as well as data that the ...
0
votes
0answers
77 views

Why are datatypes different in terms of bit size based on complier, and OS used

I was reading a tutorial on C++ as I am new to programming, and I was wondering why the sizeof operator gives different output depending on what you're programming with.
5
votes
3answers
1k views

Why does Python need both a compiler and an interpreter?

I can understand the fact that Java needs both a compiler and an interpreter. It compiles source code to bytecode and then a virtual machine (on Windows, on Linux, on Android, etc.) translates that ...
0
votes
3answers
173 views

Would it be possible to create a language similar to Ruby/Python with static typing that had the speed/memory usage of a compiled C program? [closed]

One of the main drawbacks of Ruby/Python is performance. I understand that they are interpreted and C is compiled. (And there are things like JRuby which do JIT compilation with Ruby). But they never ...
39
votes
13answers
6k 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 (...