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
1
vote
1answer
42 views

is the relocatable machine code essentially the text segment of the virtual address?

Sorry if this is a basic question, I'm studying for my operating systems class and compiler theory class at the same time and this is confusing me. From what I do understand, virtual memory is larger ...
-5
votes
0answers
33 views

How have they coded the first operating system without an operating system? [closed]

am really curious about the computer topic in general,and am still wondering how do they made an operating system. without an operating system in the first place? how do they compile a compiler. ...
-3
votes
1answer
207 views

How to write a very basic compiler (with modern approaches) [closed]

For sure, there is a well-known topic here on SE, however, it is almost 10 years old, and answers that were excellent by then, might be obsolete now and there could be modern easier ways (but I don't ...
1
vote
3answers
230 views

C++ - Is it bad practice to use compiler specific functions?

My requirement is simple, I want to be able to count the number of bits in a number. With a little bit of research, I found that MSVC has __popcnt, GCC has __builtin_popcount and so on. At this stage,...
1
vote
0answers
51 views

Is there a easy and useful error handling algorithm for bottom-up based parser?

My English skill is poor because I'm not a native English speaker. Please understand. I wonder that there is a error handling algorithm easy and useful in LR parser. LR Parser is bottom up based so it ...
2
votes
2answers
313 views

What are the 'practical' advantages of LR parser over LL parser 'in today'?

My English skill is poor because I'm not a native English speaker. Please understand. I write this article because want to discuss about this topic. I think LR parser has no 'practical' advantages ...
0
votes
1answer
57 views

Structuring a Compiler in a Dynamic Language (JavaScript)

For learning purposes, I'm trying to build a compiler in JavaScript for a tiny custom language and turn it into WASM. So far, I've got a lexer and parser, that turn my code into an AST, my question is ...
2
votes
1answer
140 views

Is it possible to translate binaries from one instruction set to another?

I need to run software compiled for ARM on my x86 machine. Usually, to do that, you use an emulator like QEMU. I'd like to know why we can't just process the binary for one ISA and compile it to a ...
0
votes
3answers
116 views

Does the assembler perform the same tasks as the translator from C to assembly?

When compiling C programs to assembly programs and then to machine programs, does the assembler (e.g. the one used in GCC or other popular C compilers) perform the same tasks as the translator from C ...
-2
votes
5answers
347 views

Is an OS compiled every time it boots?

Is an OS compiled every time it boots, or is it compiled once and the result used every time the OS is (re)booted? When users change settings, is the compiled kernel modified at all? If I am the one ...
0
votes
2answers
307 views

Why are some languages called platform dependent if I can always share the source code?

I was reading about erlang when I read that it is platform-independent, using BEAM as the VM, now I understand that a VM compiles the byte code to machine code and this makes that language machine-...
1
vote
4answers
646 views

Can writing Object-Orientated Code in a Functional style improve performance?

Given a scenario where you have consecutive setters or a series of events where an object is modified, can it be more performant to instead write code in a way where a new state is returned rather ...
2
votes
4answers
183 views

A language design with variable qualifier

I am planning to design a programming language. One challenge I face with is whether it is a good idea to have const as a variable qualifier instead of a type qualifier. For example in C++: const int ...
1
vote
1answer
178 views

Can syntactic `await` always be elided?

(This question isn't a duplicate of Why do we need the async keyword? - it's more of the opposite: I'm not questioning the async keyword - I'm asking if compilers could elide the use of await ...
2
votes
3answers
133 views

Changing control name property during runtime — Why doesn't anything break and why shouldn't I do it?

To make a long story short, I needed a property of a button to act as a "secondary text property" and retain the original .Text value of a button, and the only String property that wasn't ...
-1
votes
4answers
86 views

runtime performance for binaries compiled on a different OS than target OS

Given 2 programs that are exactly the same where one is compiled directly on the host machine and the other is compiled using cross compilation (eg: say macOS to Linux). Can there be a difference in ...
1
vote
3answers
235 views

Can a function returning void be called a procedure? [duplicate]

I have read about function vs procedure function and procedure both are subroutines but function returns a value and procedure doesn't. Can a function returning void be called a procedure? Give ...
-1
votes
2answers
377 views

Will compiled python code be as fast as compiled C++ code?

I know that Python is an interpreted language and that c++ is a compiled one, or at least I like to think that I've understood some of their differences. Although C++ is apparently faster than ...
0
votes
3answers
219 views

Does compiler AST include functions and classes?

In most of the examples for Abstract Syntax Trees (AST), I see no function or classes. I am wondering, if the functions and classes are represented in the AST? If no, where should the functions, ...
1
vote
3answers
252 views

Why do we oppose AOT and JIT compilation. Can they be complementary?

I'm just not sure as to why JIT (Just-in-time) and AOT (Ahead-of-time) are often presented in contradiction to another. If we do not care about about portability, it feels to me that a program could ...
3
votes
2answers
169 views

Does removing unused features from libraries through compiler flags increase or reduce security risks?

Software libraries targetting resource constrained environments like embedded systems use conditional compilation to allow consumers to shave space and thus increase performance by removing unused ...
7
votes
2answers
188 views

How does conditional compilation impact product quality, security and code complexity? [closed]

Software libraries targetting resource constrained environments like embedded systems use conditional compilation to allow consumers to shave space by removing unused features from the final binaries ...
-3
votes
1answer
183 views

What programming languages besides Apple Swift & Objective-C use the Llvm compile-time Automatic Reference Counting exclusively for memory management?

Are there other general purpose programming languages besides Objective-C +ARC and Swift which target the llvm and use static compile time Automatic Reference Counting for memory management?
23
votes
8answers
5k views

Detect manual changes to an autogenerated C header [closed]

I have a C header that is generated from a CSV file and a python script. The C header mainly contains a list of #define constants. I want to be able to detect manual changes to this header during ...
0
votes
0answers
42 views

Optimizing Phi Instruction Placement after changes in CFG

I am unable to find an algorithm for optimizing or eliminating Phi instructions after some Control Flow Graph modifications. I have found algorithms for destructing and constructing the SSA form, and ...
7
votes
3answers
601 views

code generation - would C be a good compiler backend?

In this and this stack overflow questions, the answers state that C as a compiler backend is a bad idea. But why? C has many compilers that can heavily optimize it. Every platform has a compiler ...
-3
votes
3answers
223 views

Convince a manager to use newer compiler version [closed]

I'm working in some environment where an older version of g++ is used to compile some production code: g++ 4.3.x . This might sound outrageous to you, but in various organizational settings ...
2
votes
3answers
297 views

How to compile to multiple target languages

Sidenote, just learned about Haxe which may offer some insight into this question. The basis of my question is what sorts of tradeoffs (if any) need to or must be made if you wanted to compile one ...
9
votes
3answers
1k views

How can we avoid showing the literal path in the exception's stack trace?

When our in-house developed application (C#, ASP.NET) is throwing an exception, it displays a stack trace that contains path information like C:\users\DEVELOPER_FULL_NAME\path\some-module.cs. So it ...
2
votes
4answers
390 views

Ahead-of-time compilation to native machine code of dynamically typed languages

It is my understanding that: It's particularly difficult to compile ahead of time, to efficient native machine code, a dynamically typed language like Python. Largely as a result of the above, the ...
-1
votes
1answer
2k views

Difference between direct and indirect function() calls

I am curious about the Difference between direct and indirect function() calls Could anyone help in the diff analysis ? The c source code could be found at subroutine_direct.c and ...
-3
votes
3answers
1k views

Is it really always easier to write an interpreter than a compiler?

I've read that generally it's easier to write an interpreter than a compiler. If that's true, what's the reason? Writing an interpreter seems to me equivalent in the level of difficulty as writing a ...
0
votes
1answer
134 views

Are parser generators useful for parsing a shell language?

From my understanding, parser generators accept as input some form of context-free grammar description. The context-sensitive features are handled during semantic rather than syntactic analysis (...
0
votes
1answer
245 views

Do C# compilers optimize away the facade pattern?

In C#, if I hide away implementation behind a facade, or the "pimpl" pattern, does the compiler optimize away the intermediate function call if all it's doing is calling an equivalent method from ...
2
votes
0answers
85 views

Windows: Have a dedicated MS Visual C/C++ toolchain

For a CI system and the developers in our team, I'd like to be able to use a specific version of a MSVC toolchain for native Windows builds. The goal is to have a well-defined consistent build-...
2
votes
0answers
126 views

Is it dangerous to link together -mno-red-zone and regular code?

I know that in x86_64, there exists a 128 byte red zone above (or below, address-wise) the stack pointer that functions can use without subtracting from rsp. This sounds to me like the only things ...
2
votes
3answers
345 views

Is a literal out of range a syntax error or a semantic error?

I am reading more about the differences between syntax and semantics, but I am still wondering about this one. Let's assume that we have a language that only allows integers to be in the range of 0-...
0
votes
1answer
128 views

How to design a system that can operate and replay its functions call stack?

I am writing a processor for the Citation Style Language (CSL) in JavaScript. Before I explain what my problem is, I must give some context first: CSL is an XML specification for describing how to ...
1
vote
1answer
140 views

Switching out implementation source files in C project

For simplicity, let's say I have the following C project structure: src/ utils/ logger.c logger.h main.c secondary_component.c main.c starts with: #include "utils/logger.h" I would ...
0
votes
1answer
248 views

Why do new language versions typically use an early compiler version for the bootstrap compiler?

Wikipedia describes a bootstrap compiler to have these properties: An initial core version of the compiler A minimal subset of the language to be used by successive compiler versions Everything I've ...
0
votes
1answer
78 views

How is a function in execute only space compiled?

I don't quite understand, how the following typedef is parsed by a compiler to call code at a specific address. I guess I understand that a function is just a pointer and we're typedefing such a ...
2
votes
1answer
204 views

C++ design pattern for template instantiation based on run time information?

Say I want to be able to create objects for a range of template parameter template<int a> class Myclass : public MyclassSuper{...}; And I want to create objects like Myclass<...
3
votes
2answers
745 views

What are the bottlenecks for the Java build speed?

Which underlying system parameters have most influence on how fast a typical Java project (say dozens of classes and dependencies) builds? There is a lot information on JIT (bytecode to CPU ...
3
votes
2answers
2k views

What is the difference between a static library and an archive library?

In the comments of a recent answer, I equated a static library with an archive of compiled object files. The response was that they are not the same, so what is the difference? To clarify - gcc ...
1
vote
1answer
200 views

How function parameters are compiled in JavaScript

I am trying to understand how functions -- which could have dozens of parameters that could themselves be functions or complex objects (I'm thinking JavaScript) -- get passed the arguments when ...
0
votes
3answers
154 views

Resolving function calls as function arguments using a stack

After doing a bit of reading, I have a vague understanding of the use of a stack in calling functions when one function calls another, where the arguments are placed on the stack for the called ...
-1
votes
2answers
248 views

Relationship between the C standard libraries and Java standard libraries

Which is the relationship between the standard libraries of C language and the standard libraries of other software platforms, e.g. Java, .NET, Python? Do the Java (.NET and Python) standard libraries ...
5
votes
2answers
600 views

How can one interpret an Abstract Syntax Tree without recursion?

I am busy building an interpreter for a Rebol-like language. I have previously built a Lisp interpreter where I used recursion, but now I just want to use a stack and not rely on the recursion ...
3
votes
3answers
2k views

How does a compiler work when it's not directly compiling to machine code

I know the compilation process goes with this flow: source -> parse -> AST -> intermediate code -> assembly -> machine code and in the case of Java you will have bytecode which is ...
-1
votes
1answer
400 views

What happens when loops are compiled or interpreted?

I have came across a concept in recursion which says that when loops are compiled or interpreted then they get converted to recursive functions. If it is true how it takes place ?

1
2 3 4 5
10