A compiler is a computer program that transforms source code written in one programming language into another computer language.
4
votes
2answers
247 views
How does a compiler know the machine language of targeted processor to which the source code has to be converted?
For ex: Two machines have the same compiler and the same operating system. But the two machines have different processors (different assembly instructions).As the compiler was downloaded with respect ...
3
votes
1answer
59 views
How can CLS compliant methods have non-compliant local variables?
The .NET CLS (Common Language Specification) allows a programmer to write code in one .NET language and confidently know that all other .NET languages can safely interact with and even utilize data ...
56
votes
14answers
11k views
Can we make general statements about the performance of interpreted code vs compiled code?
I'm comparing two technologies in order to reach a recommendation for which one should be used by a company. Technology A's code is interpreted while technology B's code is compiled to machine code. ...
3
votes
4answers
472 views
How does Java improve over C++ in the area of portability?
I was reading through a Java book by author Herbert Schildt and he writes how the advantage of Java over C++ in portabilaty is that while C++ can be run anywhere, it still requires each program to be ...
0
votes
2answers
134 views
Where to start when creating a programming language? [closed]
I'm actually a programmer on a few languages, but I realized I really didn't know much how the computer works on a deeper level.
So I thought a good idea to discover and learn how does it work was to ...
1
vote
1answer
91 views
Is there a name for infered strong typing?
In JavaScript, you can have a loosely typed language. So doing the following is acceptable:
var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
var matchType;
var found = ...
3
votes
3answers
143 views
What is the general term for [function] names of which the value is fully known at compile time?
In certain programming languages, the meaning of certain names may be fully determined at compile-time (i.e. without running the program).
Example:
A function in C has global scope; when the name of ...
3
votes
3answers
77 views
How are namespaces used in the stack during scope lookups?
I'm taking a comparative programming languages course and have learned the bare basics of variable scopes with respect to stack frames -- e.g. static and dynamic links, offsets, etc. as in the image ...
4
votes
3answers
153 views
Is SSA form worth it if code generating to a high level language?
I'm writing a compiler that compiles to C. This means that most of the time I piggyback on top of C for optimisations and generating code for multiple platforms.
Right now I can think of a few ...
2
votes
3answers
294 views
Which programming languages support type inference from variable names? [closed]
Which programming languages support type inference from variable names?
By 'type inference', I mean, for example, in Swift, how if you let x = 39 then the compiler knows x is an Integer, because 39 ...
2
votes
1answer
128 views
Understanding abstract syntax trees in compilers
I have attached the problem below with the answer. My problem is that I can't understand it. Can you provide an overall explanation in detail about parse trees and ETF grammar by deriving the first ...
0
votes
0answers
96 views
Comparing MSVC to Mingw
I may need to switch from Netbeans over to Visual Studios, I am using MinGW currently with a c++ project.
Is a binary made from Visual Studios significantly different from one produced on MinGW? If ...
0
votes
2answers
114 views
Is there such a thing as a 'pseudo-compiler' for proprietary software?
I'm interested in whether there is such a thing as a pseudo-compiler that can create a kind of binary or bytecode version of a plaintext script file, which can only be accessed by a proprietary piece ...
7
votes
2answers
464 views
How are generics implemented in a modern compiler?
What I mean here is how do we go from some template T add(T a, T b) ... into the generated code? I've thought of a few ways to achieve this, we store the generic function in an AST as Function_Node ...
3
votes
2answers
628 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
69 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 ...
4
votes
3answers
184 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 ...
3
votes
1answer
119 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 ...
4
votes
6answers
425 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 ...
3
votes
1answer
81 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
163 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
101 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
91 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
503 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
135 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
36 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."...
0
votes
2answers
137 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 ...
5
votes
6answers
2k 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
55 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 ...
23
votes
2answers
912 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
148 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
242 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
160 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
205 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
222 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
67 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
84 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
266 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
218 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
97 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
709 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
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
...
0
votes
2answers
216 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
283 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
97 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
1k 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
113 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
145 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
83 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 ...