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

Why is Java AOT compilation (using graalvm native-image) so much slower than golang compilation?

I followed the guide here https://quarkus.io/guides/building-native-image to set up a minimal quarkus webservice graalvm native image. Ran command 'time quarkus build --native' to compile the example. ...
user avatar
0 votes
1 answer
69 views

Can we reliably use unaligned scalars on contemporary hardware?

Processors have come a long way in their handling of unaligned data - from crashing at the very notion of it, through suffering severe penalties, all the way to having almost no impact. I suppose it ...
user avatar
  • 623
0 votes
1 answer
305 views

Java: Is there a performance difference between variable assignment vs. inline usage?

Is there any performance detriment to assigning variables vs using them inline. I'm guessing this WOULD be worse if a method was returning primitive and I was 'boxing' it (e.g. method returning int, ...
user avatar
  • 287
-3 votes
3 answers
61 views

How to Validate Output Binary During/After Compilation on Platform without ECC Memory [closed]

On a platform with ECC memory, you can assure the compiled binary is 100% legit with EDAC daemon. (single-bit error will be corrected automatically, and multi-bit error will be logged so you can just ...
user avatar
0 votes
1 answer
81 views

How to manage concurrent build & test toolchains in (embedded) software development?

TL;DR: How do you manage the complex development toolchain in different (embedded) projects? In our company we are discussing the toolchain setups in different development teams and how to work ...
user avatar
  • 109
0 votes
1 answer
72 views

Parsing complex data type names

How do compilers parse complex data types names like function pointers. The type has to be somehow put into the AST or it has to be processed during parsing. What are the pros and cons of different ...
user avatar
-3 votes
1 answer
149 views

When making a compiler, what's the best way for compiling to machine code in the backend? [closed]

I know that a lot of compilers use an assembler to compile to machine code, to make an executable (compiled program). Some people even made their own assemblers, or they just use an existing assembler,...
user avatar
-2 votes
2 answers
226 views

Isn't OS dependent on machines, can anyone briefly explain how it is achieved? [closed]

Certain OS in it's system requirement doesn't specify anything peculiar like in case of ubuntu it asks only for "2 GHz dual core processor or better". If yes, how does it compares with ...
user avatar
0 votes
3 answers
176 views

How to deal with forward references in a compiler?

I'm creating a very simple compiler PoC that only has Procedures Calls to procedures. The syntax of the language is really simple: Main { Call("Proc1"); } Proc1 { // Empty } I ...
user avatar
  • 383
0 votes
0 answers
45 views

Why not using .hpp files containing forward declaration AND implementation over separating to .h and .cpp [duplicate]

I am not very experienced as a c++ programmer so I may not have understood all the subtlties of what i'm doing : yet, for a few months now, I always write my modules with .h files that are only #...
user avatar
  • 109
1 vote
2 answers
157 views

Is there a simple algorithm for generating unit tests given a function's code? [closed]

Given the abstract syntax tree (AST) of each line of a function's code, I am asked to generate code for that function's corresponding unit tests, similar to what Microsoft's IntelliTest tool does here:...
user avatar
0 votes
3 answers
331 views

Is it possible to make a compiler for any dynamic/script/interpreter language

Logically, not based on how cost we will spend or how much we will hire programmers to do it. Can we (Is it possible to) make a compiler for any dynamic/script/interpreter language, like Lua, Python, ...
user avatar
-4 votes
2 answers
101 views

Archival-quality future-proof pseudo-CPU architecture

Suppose we maintain a massive electronic library of texts/photos/videos etc., and want to ensure that these files are readable indefinitely long in the future. So we: Keep snapshots of versions of ...
user avatar
1 vote
0 answers
67 views

How to practically implement a symbol table during compiler design?

I was trying compiler design with flex and bison. This is my first attempt in that sense. For my compiler, I wanted to build a symbol table which would help in building a proper compile-time type-...
user avatar
-2 votes
3 answers
307 views

Why `struct` unconstrained method fails to accept `null` as `T?` parameter

Considering example below, one observe that for reference type argument is successfully understood as nullable parameter. For value type conversion to T?/Nullable<T> fails. T Method<T> ( T?...
user avatar
  • 268
5 votes
5 answers
2k views

How does code work without getting compiled or interpreted?

I recently started researching about coding, but there are a few things that made me confused. I chose Visual Studio Code to start coding in C and Python (I was using IDLE for Python before), but ...
user avatar
3 votes
1 answer
610 views

In C++, If a member function can be made static with no change to functionality, are there any performance or memory benefits from doing so?

A very straightforward question. When I think about many of the member functions I create for my classes, many of them can be made static without affecting any functionality whatsoever. If I do so; ...
user avatar
  • 3,319
0 votes
1 answer
125 views

Benefits of using a tokenizer/lexer before parsing for recusive descent parser

I am trying to build a static program analyzer for a proprietary progamming language for a school project, and am currently trying to implement the parser from scratch. I was wondering, what are the ...
user avatar
  • 101
0 votes
2 answers
96 views

Small confusion about time complexity

Suppose we have a code: for(int i=0;i<n;i++) sum+=i; We say the time function here is: f(n) = n+1+n = 2n+1. The order of the time function is 1. So, our time complexity becomes O(n). But, for the ...
user avatar
2 votes
3 answers
219 views

Where is the boundary between things which can be statically typechecked, and those which must be typechecked dynamically?

I am brain storming on how to create a type system for a programming language, and what the compiler will do with the typing information. Here is what I have found, followed by the main question, ...
user avatar
  • 2,406
2 votes
1 answer
407 views

Do C++ compilers optimize/pack small data types (e.g. boolean values)?

This occurred to me when looking at stencil computations in numpy. This python library compiles compute-intensive components, so I believe that it's a valid example. Here making selections on an array ...
user avatar
-3 votes
1 answer
178 views

Which non-standard C features can I use? [closed]

C and C++ have standards, but support isn't perfect, the only available copies on the internet are drafts, and there are immensely useful things that aren't standard, such as __attribute__((cleanup)). ...
user avatar
  • 113
-2 votes
3 answers
157 views

What happens in terms of call stacks when 10000 setTimeouts are called?

Say we call 10000 setTimeouts, each with a random time, each with a few nested timeouts too. What happens in terms of the 1 call stack, or are there multiple call stacks? How does that work? So for ...
user avatar
  • 2,406
1 vote
4 answers
289 views

Why Java, C# and the like needs to be managed code

As far as I know the big argument for C#, Java and other high level languages having to be memory managed by a runtime environment is that the programmer does not take care of garbage collection or ...
user avatar
  • 215
0 votes
2 answers
256 views

Template argument type exclusion: Would this make for a useful C++ feature?

When using templates we can have T be any type upon class instantiation. If T is a specific type that needs to be handled differently or in a special way we can specialize or partial specialize that ...
user avatar
26 votes
4 answers
5k views

Do compilers optimise in concurrency?

Presuming that I have written some sequential code where it can be broken down into multiple isolated tasks, it seems it might be efficient for concurrency to be introduced. For example print(...
user avatar
  • 369
1 vote
3 answers
476 views

How do binary numbers interact with the CPU and cause some action to take place? [duplicate]

EDIT: Perhaps what I am misunderstanding is that when it is said that the code we type gets turned into machine code of 0s and 1s. If these 0s and 1s are the abstracted representation of their ...
user avatar
  • 31
1 vote
1 answer
64 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 ...
user avatar
  • 163
-2 votes
1 answer
688 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 ...
user avatar
  • 145
1 vote
3 answers
351 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,...
user avatar
1 vote
0 answers
63 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 ...
user avatar
  • 197
6 votes
2 answers
2k 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 ...
user avatar
  • 197
0 votes
1 answer
65 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 ...
user avatar
1 vote
1 answer
309 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 ...
user avatar
0 votes
3 answers
158 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 ...
user avatar
  • 5,261
-2 votes
5 answers
549 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 ...
user avatar
  • 21
0 votes
2 answers
943 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-...
user avatar
  • 129
1 vote
4 answers
665 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 ...
user avatar
  • 129
2 votes
4 answers
212 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 ...
user avatar
  • 29
2 votes
1 answer
316 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 ...
user avatar
  • 680
2 votes
3 answers
170 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 ...
user avatar
  • 147
-1 votes
4 answers
123 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 ...
user avatar
  • 153
3 votes
3 answers
575 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 ...
user avatar
0 votes
2 answers
2k 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 ...
user avatar
0 votes
3 answers
504 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, ...
user avatar
  • 1
1 vote
3 answers
449 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 ...
user avatar
  • 153
3 votes
2 answers
194 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 ...
user avatar
  • 435
7 votes
2 answers
327 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 ...
user avatar
  • 435
-3 votes
1 answer
243 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?
user avatar
  • 95
23 votes
8 answers
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 ...
user avatar
  • 2,093

1
2 3 4 5
10