Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
0 votes
1 answer
55 views

Concatenating strings given a BNF grammar

<Definition> ::= <Name> <LeftPar> <param> <RightPar> <Name> ::= <Letter><LetterTail> <LetterTail> ::= <Letter><LetterTail> | ‘’ A ...
User's user avatar
  • 11
0 votes
0 answers
70 views

Is it possible to build a semantically unambigous grammar / language / graph?

It's been a long time that I had an idea of a semantic constraint as compiler optimizations which allows for sophisticated high level optimization allowing you to transform the AST/CFG based on a SFG (...
C5H8NNaO4's user avatar
  • 129
1 vote
0 answers
164 views

Implementing a memory efficient Abstract Syntax Tree

I am writing a compiler in C++ 20. I am looking for ways to improve heap memory performance. For example, I can compile a 36.8 MB source file that is just many repeating lines of: let x0: string = &...
Wesley Jones's user avatar
1 vote
1 answer
202 views

Is there any logical reason to "store" just one object file (.o) into archival file (.a)?

As far as I understand (not much), the archival .a file is just, roughly speaking, the collection/batch of object .o files. It's like a library of compiled code that can be cached and which can be ...
LeaBit's user avatar
  • 151
1 vote
1 answer
104 views

How to approach converting to and from kafka messages?

I would like to have a series of small stand-alone services that would either consume a Kafka topic and output the data into a different system or the reverse: receive data from a system and produce ...
mparada's user avatar
  • 11
15 votes
6 answers
6k views

Why is it necessary to mark classes as not inherited from? Can't an optimizer automatically detect that virtual calls are unnecessary?

In C# and C++, an apparent trend is in place to reduce / avoid inheritance: C#: "Sealing types can improve performance." https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/...
user avatar
0 votes
1 answer
236 views

How do function inlining and Tail Call Optimization affect call stack?

I've just accidentally came across this answer about inlined functions and I'd like to know how this affects call stack. But I can't add comments because I don't have enough rep so I decided to ask ...
b3rry's user avatar
  • 3
1 vote
0 answers
89 views

How can I represent a transformed AST between compilation stages?

I'm writing a compiler in Rust. I've reached the point where I have an AST and am ready to do symbol resolution, type-checking, etc. But, I'm unsure of how to represent an AST as containing "...
gmdev's user avatar
  • 119
0 votes
1 answer
146 views

What lessons can be learned from the architecture/combination of ESLint and Prettier for linting and code formatting?

I was looking through the prettier docs and the prettier source code. It essentially has those defined helper functions to layout the text, given an AST. It operates on the level of the whole file, on ...
Lance's user avatar
  • 2,611
0 votes
1 answer
327 views

Implementing heap-allocated closures in LLVM

I'm writing my own F#-esque language and I'm using LLVM for code generation. I want my language to support continuation passing style and I think I've got TCO figured out but I cannot figure out how ...
Gabriel's user avatar
  • 11
0 votes
2 answers
180 views

Modular Design affects compilation time

Does modular design decrease compilation time in cpp? My professor said so, but I don't understand how, because the build and compilation time depend on the amount of code, right? Also, wouldn't ...
happy's user avatar
  • 11
-3 votes
3 answers
255 views

why do we need instructions set for processor or controller?

Why is it necessary to have an instruction set for processors and controllers? Can't we simply convert high-level language programs, like those written in C, directly into binaries without the need ...
Harshith Gowda's user avatar
-1 votes
1 answer
99 views

Debugging miscompile [closed]

Recently I encountered an issue at work where a unit test written in C++ would crash only when being compiled with MSVC 2017 (MSVC 2019 and up are fine). I tried to debug this issue and it seems like ...
yijiem's user avatar
  • 107
0 votes
1 answer
215 views

Is it true that variable type before name makes compiler work easier? [closed]

I have seen information that at least one of reasons why type placed before variable name is that it allows compiler easier evaluate size and type of variable. If so then how (what way) it eases this ...
Ya Y's user avatar
  • 29
-1 votes
2 answers
185 views

When writing a tokenizer, what is the standard practice for handling aliased language keywords?

When writing a tokenizer, what is the standard practice for handling aliased language keywords? For example, notethat signed short int is a language keyword in C++ and several aliases might be allowed....
Samuel Muldoon's user avatar
0 votes
1 answer
476 views

Custom #pragma directives

I'm creating a language parser on a microprocessor in C++. For the tables of keywords and commands, rather than maintaining a single curated file (alphabetically sorted, etc), I'd prefer to declare ...
SteveG's user avatar
  • 33
0 votes
1 answer
129 views

Are indirect implicit type declerations dangerous?

In the case of kotlin, rust and many other programming languages... There are variables with direct implicit type declarations... Where you can see the type of a variable at the same line where it's ...
user avatar
-1 votes
1 answer
195 views

Better way to represent grammar symbols in C

I'm trying to build a simple compiler for a subset of the C language in C. To achieve this, I needed to figure out a way to represent the grammar symbols. Basically, each symbol can either be a "...
Mehdi Charife's user avatar
-1 votes
3 answers
156 views

How to propagate lexical scope in a compiler, specifically around step-by-step functions?

I am working on a compiler in TypeScript, and currently am focused on how to pass around the "lexical scope" to the relevant objects. Essentially every time there is a conceptual major ...
Lance's user avatar
  • 2,611
13 votes
8 answers
6k views

How do compilers work in a language that doesn't allow recursion?

I'm recently learning the programming language, and I wonder how compilers work when the language itself does not allow recursion, like how the compiler or the runtime checkers makes sure that there ...
csxyyyyy's user avatar
  • 151
6 votes
3 answers
946 views

How does a JIT compiler actually emit and then call the emitted native code?

Assuming that a VM runs a JIT compiler on otherwise "interpreted" code, such as a line by line interpreter or some form of bytecode/IL code and determines that it can create optimised native ...
AIWalker's user avatar
  • 1,307
0 votes
1 answer
1k 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. ...
vancan1ty's user avatar
  • 119
1 vote
1 answer
95 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 ...
dtech's user avatar
  • 723
0 votes
1 answer
1k 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, ...
nanotek's user avatar
  • 301
-3 votes
3 answers
73 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 ...
hurryman2212's user avatar
0 votes
1 answer
139 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 ...
ThePMO's user avatar
  • 109
0 votes
1 answer
140 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 ...
Wojak2121's user avatar
-3 votes
1 answer
370 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,...
Jack Murrow's user avatar
-2 votes
2 answers
306 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 ...
D J's user avatar
  • 107
0 votes
3 answers
360 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 ...
SuperJMN's user avatar
  • 443
1 vote
2 answers
585 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:...
David Johnson's user avatar
0 votes
3 answers
821 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, ...
Zaher Dirkey's user avatar
-5 votes
2 answers
148 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. [Update] one of the major problems with ...
Ilya Zakharevich's user avatar
1 vote
0 answers
313 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-...
Sourav Kannantha B's user avatar
-2 votes
3 answers
427 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?...
Yarl's user avatar
  • 288
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 ...
Burcu Avcu's user avatar
4 votes
1 answer
3k 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; ...
Anon's user avatar
  • 3,613
0 votes
1 answer
318 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 ...
Meowmi's user avatar
  • 101
0 votes
2 answers
97 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 ...
Md Mosleh Uddin's user avatar
2 votes
3 answers
249 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, ...
Lance's user avatar
  • 2,611
2 votes
1 answer
1k 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 ...
Daniel Krajnik's user avatar
-2 votes
1 answer
411 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)). ...
Dan's user avatar
  • 123
-1 votes
3 answers
634 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 ...
Lance's user avatar
  • 2,611
1 vote
4 answers
343 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 ...
stevie's user avatar
  • 225
0 votes
2 answers
931 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 ...
Francis Cugler's user avatar
26 votes
4 answers
6k 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(...
Ben's user avatar
  • 369
1 vote
3 answers
2k 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 ...
steez's user avatar
  • 31
1 vote
1 answer
117 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 ...
qwerty_99's user avatar
  • 163
0 votes
1 answer
2k 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 ...
T.Todua's user avatar
  • 165
2 votes
4 answers
711 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
2 3 4 5
10