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
0 votes
0 answers
69 views

What is best practice for a programming language which allows more than one syntax for class method invocations? [closed]

Consider the following code written in a syntax consistent with the programming language known as "python": ...
Samuel Muldoon's user avatar
1 vote
3 answers
206 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
203 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
5 votes
4 answers
502 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
  • 213
11 votes
2 answers
621 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
  • 670
10 votes
2 answers
1k 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?
nchistov's user avatar
  • 1,521
4 votes
3 answers
556 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
408 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,722
4 votes
5 answers
671 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 ...
nchistov's user avatar
  • 1,521
2 votes
3 answers
132 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,633
6 votes
1 answer
128 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,563
6 votes
2 answers
91 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,633
4 votes
1 answer
91 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
119 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: ...
nchistov's user avatar
  • 1,521
11 votes
2 answers
188 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,553
7 votes
3 answers
175 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
  • 16.3k
0 votes
2 answers
205 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,747
11 votes
3 answers
158 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
  • 1,582
3 votes
1 answer
95 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,747
5 votes
2 answers
185 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,747
-7 votes
3 answers
401 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