Skip to main content

Questions tagged [interpreters]

For questions about designing and implementing interpreters, language implementations that execute source code directly, as opposed to compilers, which convert source code to executable code, which can then be executed later.

Filter by
Sorted by
Tagged with
3 votes
1 answer
195 views

How to save C struct pointers in interpreted language? [closed]

I am making an interpreter based on the lox from the book Crafting Interpretes. I have modified the language implementation heavily but the core still remains the same. Currently I am adding standard ...
Timsib Adnap's user avatar
11 votes
5 answers
3k views

Should a virtual machine stack have a limited size?

I'm writing a register- and stack-based virtual machine. My goal is to have something easy to use and general purpose, so I abstain from any form of hardware limitation in its design. Since my VM's ...
Foxy's user avatar
  • 213
8 votes
2 answers
218 views

How can I more effectively test for differences between my implementation and the official implementation of a language?

I built my own interpreter for the esolang ><>. However, over time I've been notified of various ways my version differs from the official interpreter. Each time I patch things but it's ...
mousetail's user avatar
  • 8,229
0 votes
1 answer
361 views

How would you implement a language in which the function-name could be separated from function arguments two different ways?

Suppose that there was a programming language in which there were two different syntaxes for function calls. An example of this is shown below: ...
Samuel Muldoon's user avatar
1 vote
3 answers
231 views

Are there any languages interpreted twice? [closed]

Are there any languages that are interpreted in something interpreted, like Python? If so, what are the advantages?
XenonPy's user avatar
  • 21
1 vote
1 answer
213 views

How might we convert type declarations into constructor calls? [closed]

Suppose that we have two languages, A and B. In language A, there are a lot of data-type declarations. In language B there are no data-type declarations to the left of the assignment operator, but ...
Samuel Muldoon's user avatar
6 votes
4 answers
629 views

How do interpreters avoid stack buffer overflow-related undefined behavior and exploits?

Most interpreters (including those for bytecode-based languages like Java) are assumed to be exempt of UB at the low-level. For instance, I would never expect NodeJS or the Hotspot JVM to allow ...
MrAnima's user avatar
  • 223
13 votes
2 answers
1k views

Why is it so difficult to implement the first Futamura projection?

The Futamura projections are a series of three transformations that can be performed on interpreters, compilers, and compiler-compilers respectively. These transformations rely on a specializer which ...
Corbin's user avatar
  • 851
11 votes
2 answers
2k views

What is a Global Interpreter Lock, and why would an interpreter have it?

CPython is known for having a Global Interpreter Lock (GIL), which many users consider to be detrimental. What does this mean, and why would an intepreter be designed to have this feature?
чистов_n's user avatar
4 votes
3 answers
826 views

What are some common ways to optimise an interpreter?

Optimization is getting things to work faster with less resources. What are some ways to optimize an interpreter?
Starship - On Strike's user avatar
3 votes
2 answers
687 views

What are the pros/cons of a tree-based interpreter vs a bytecode-VM-based interpreter?

Based on this closed question. Basically, why would one choose a pure interpreter for a language implementation as opposed to a virtual machine/bytecode approach like Java or Python (even if at ...
kouta-kun's user avatar
  • 1,359
4 votes
5 answers
819 views

What are the pros and cons of interpreted programming languages?

Some programming languages are implemented via a source code interpreter instead of a compiler, for example Python, PHP, Ruby and Perl, and these programming languages are very popular. So, this ...
чистов_n's user avatar
3 votes
3 answers
209 views

How can I track source spans during parsing and interpretation?

I want to implement error messages that point out where in your source code a parse error or runtime error is. However, when I convert the token stream to my AST, I lose the information about the ...
bigyihsuan's user avatar
  • 1,821
6 votes
1 answer
170 views

How do I implement branch prediction for JIT?

I have a language with a working interpreter, and I am trying to add just-in-time compilation (JIT) to it. For ease of implementation, only individual branches are compiled, while control flow ...
Bbrk24's user avatar
  • 8,937
6 votes
2 answers
99 views

Organizing a large number of built-in instructions

I am currently writing a Funge-98 interpreter in Go following the Funge-98 specification and need to handle all of its built-in instructions. However, this is proving to be unwieldy, because there's ...
bigyihsuan's user avatar
  • 1,821
5 votes
1 answer
96 views

How would I allow a variety of different syntaxes for passing arguments into MathJax or LaTeX commands? [closed]

What is LaTeX If you already know what LaTeX is, then skip down the the section labeled "sloppy syntax". There is a type-setting language known as LaTeX. LaTeX even has its very own Stack ...
Samuel Muldoon's user avatar
-4 votes
1 answer
128 views

Does CPython compile the entire code or one piece at a time? [closed]

Does it: first compile all the code into bytecode, and only then executes it, or does it compile the minimum possible piece of code and executes immediately? For example, this code: ...
чистов_n's user avatar
11 votes
2 answers
274 views

Is it possible to bootstrap an interpreted language?

Is it possible to bootstrap an interpreted language? Bootstrapping, broadly, refers to writing a programming language in that same programming language. This is obviously possible for compiled ...
FireTheLost's user avatar
  • 1,603
8 votes
3 answers
270 views

Pros and cons of reifying the stack in an interpreter

When implementing an interpreter, there is a choice between implementing function calls either by just recursively evaluating the function body in a different evaluation context ─ essentially ...
kaya3's user avatar
  • 19.1k
0 votes
2 answers
241 views

How to store variables in an interpreted language? [closed]

Say I'm making an interpreted language. What's the best way for me to store variable name/value pairs (or type/name/value triplets in the case of languages with typing)?
lyxal's user avatar
  • 1,775
11 votes
3 answers
180 views

Utilising recursion schemes when implementing compilers

I haven't personally seen much use of recursion schemes when building compilers or interpreters, and I'm honestly not quite sure why. Almost all the common ones (cata/ana/para/apo) seem quite handy ...
blueberry's user avatar
  • 2,455
2 votes
1 answer
105 views

How do I Implement User-Defined Classes? [closed]

Say I have a programming language that can support user-defined classes (all debates over whether OOP is actually good aside) - how do I store instances of these user-defined classes when executing a ...
lyxal's user avatar
  • 1,775
5 votes
2 answers
254 views

How do I Interpret a Continue/Break Statement in a Loop?

Say I have the following construct in an interpreted language that uses an AST tree walker: ...
lyxal's user avatar
  • 1,775
-7 votes
3 answers
719 views

What are the advantages of compiling/interpreting a programming language? [closed]

Interpreted languages give programs dynamic typing and smaller size. Compilied languages tend to be faster and more efficent. What other advantages and disadvantages are there of each? (Originally ...
Starship - On Strike's user avatar