Questions tagged [compiler]

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

Filter by
Sorted by
Tagged with
6
votes
3answers
10k views

Why can't C# implicitly convert int to string?

C# allows implicit conversions of integers to strings when used in an expression. For example, this is completely valid: int myInt = 10; string concatenatedString = "myInt is " + myInt; string ...
0
votes
1answer
82 views

Grammar design preference for recursion

I would like to know if one of the two following equivalent grammars (since they can produce the same rules) is preferred (and why). For instance the second grammar is more concise but is it a good ...
3
votes
3answers
350 views

Is loop unrolling one of the examples of “targeted” compilation and faster instruction set?

I'm taking the Computer Architecture course in my undergraduate study. I see that in loop unrolling, one of the constraints is the number of available registers. Since the number of registers ...
2
votes
1answer
324 views

Javascript / Ecmascript language grammar disambiguation

I'm working on the design of a compiler for a language in which I have to use curly brace for two different purposes. I am currently stuck in writing a non-ambiguous grammar but I realized that some ...
5
votes
7answers
1k views

How can a compiler be written for a language that allows rewriting code at runtime (such as Lisp macros)?

There are some programming languages, like the many dialects of Lisp, that allow for macro-metaprogramming: rewriting and altering sections of code before the code is run. It is relatively trivial to ...
5
votes
1answer
136 views

Implementing a construct like Rusts `match` in C?

I'm writing a compiler that compiles to C, one thing I'm attempting to do is implement a construct like Rust's match: // { some function let mut foo = 32; match foo { 3 => return "...
2
votes
1answer
711 views

Do bytecode compilers compile syntax directly or intermediate assembly language?

I am going to write a very simple VM and bytecode compiler. Is it typical for a bytecode compiler to read the syntax and attempt to create the bytecode directly or is there an intermediate stage to ...
1
vote
2answers
280 views

How can an interpreter produce output of some code, without having the computing components like ALU of a processor?

I have gone through lot of explanations about a compiler and interpreter. I think I understood the difference between compiler and interpreter clearly. I'll explain my learning through the following ...
0
votes
1answer
416 views

Difference between intrinsic functions and #pragma directives?

In the ARM C/C++ Language Implementation Guide (p 99), NOINIT is listed as a pragma directive. In the previous code that I'm working with, __no_init was defined as an intrinsic function (IAR compiler ...
4
votes
5answers
3k views

Is there something that prevents a multithreaded C# compiler implementation?

The C/C++ language family apparently has multithreaded compiler implementations that work on file level parallelism, but the Microsoft C# compiler (csc.exe) is single-threaded only. MSBuild supports ...
0
votes
1answer
261 views

Comparison of modern browsers' javascript engine JITs

I understands that most of the recent browsers use JIT compilation to execute javascript. What I do not understand is: which part of javascript is JIT'ed - the script, or the bytecode? Let me explain....
0
votes
0answers
144 views

How is the TypeScript compiler implemented in TypeScript? [duplicate]

I was reading on the TypeScript site and saw that the TypeScript compiler is itself written in TypeScript. "The TypeScript compiler is implemented in TypeScript and can be used in any JavaScript host."...
2
votes
3answers
462 views

Should compilers follow the defined language standard?

Why do some compilers violate the defined language standard? I don't understand, in ISO/IEC 10206:1990 Extended Pascal standard on 6.8.3.2 Arithmetic operators section, Page 86. It says that, A ...
13
votes
6answers
24k 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 Language ...
2
votes
0answers
98 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 ...
26
votes
2answers
1k 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 ...
7
votes
1answer
358 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 ...
4
votes
4answers
745 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?
4
votes
1answer
740 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 ...
15
votes
2answers
7k 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 on) the source code character-by-...
6
votes
2answers
506 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 ...
1
vote
1answer
79 views

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

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
146 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....
9
votes
5answers
2k 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
2k 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 ...
4
votes
1answer
324 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?
3
votes
4answers
1k views

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

Does anyone know why something like cj library for complex numbers was never completed and integrated into mainline Java? This seems like a no-brainer... I realize the Java gawds don't want to turn ...
23
votes
3answers
3k 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 ...
0
votes
2answers
238 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
300 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
237 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 ...
2
votes
3answers
13k 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
136 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
205 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
118 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 ...
13
votes
4answers
3k 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 ...
0
votes
1answer
810 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
2k 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 ...
57
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
578 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 ...
4
votes
1answer
852 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 ...
6
votes
1answer
204 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
213 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
1k 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 ...
5
votes
1answer
3k 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 top ...
4
votes
2answers
4k 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 ...
0
votes
2answers
392 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
389 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 ...
42
votes
6answers
10k 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 ...