Name of the class of programming languages ​​that execute native code

What do you call a programming language that can execute its own code (passed as a string literal)? I have something similar in my head (forgetting to enter the code, results, etc. for a moment):

string eight = "5+3" int result = run(eight) 

Where run is the keyword. Is this a reflective programming language?

+6
programming-languages nomenclature
source share
7 answers

I think you are talking meta-circular appraisers . Your run eval command in eval- apply the loop described in the section "Structure and implementation of computer programs".

+1
source share

The best you can come up with is exactly what you ask for, it "has an eval function" (as Javier mentioned in his comment on your question).

Self-hosting is not needed, and it does not necessarily do what you want. Two examples: C is a self-service language that cannot execute native code in a string, but Tcl is not a stand-alone language that can execute native code specified in a string.

  • As a side note, half the time C runs in environments where there is no API to run external processes. Therefore, while in some environments you can configure your system to force C to execute its own compiler and then execute its own code as a whole, this is actually not what you are asking for.

  • Side note. If we can trick and use the “execute external compiler” route to do this, you don’t need your own hosting to do what you want. It just needs the exec function to call its own compiler (which is often written in C).

The same thing with Reflection / Introspection, which has the ability to do independently on its own, does not mean that you can execute code in a line. Two examples of languages ​​that have Reflection but don't have built-in eval are C # and Java.

  • As a side note, once you have the eval function, you can usually do Reflection / Introspection, albeit in an awkward way.

Self-presentation has the same problem with its definition as self-presentation. Tcl is a language where its eval function is not written by itself - it simply provides a Tcl code evaluator implemented in C.

At first glance, meta-circular appraisers look the way you want. It is defined as self-interpretation, where the eval function is built, and not implemented in the language itself. But looking further, you will notice that it is determined by the mechanism used to achieve this function, and not the function itself. Tcl is again an exception where it does not meet all the definitions that meta-circular appraisers, but has an eval function, however (not applicable, not necessary). Therefore, it seems to me that the meta-circular appraiser is a concrete implementation of the "has an eval function" function.

So, I would just say that any language that "has an eval function" can do what you ask for.

+3
source share

The class of languages ​​you are asking for is equivalent to self-hosting . A self-hosting language is one for which there is an implementation of a compiler or interpreter in one language.

Here is the proof.

Each language of self-hosting is able to run its own programs. If you pass, for example, C code to C, this program may include a compiler (written in C) that compiles and runs the code. Thus, program C executes arbitrary code C.

Suppose you have an X language with the property that it is capable of running arbitrary code in that language, and the code is passed as a string. Then you can create a program that simply takes the string as input and executes the code inside it. This will be the interpreter for the X language implemented in X. And this is the definition of a self-hosting language.

Here is what this interpreter would look like:

 execute ARGV[0] 

So, we have proved that every language with the desired property is self-service, and each language of self-service has this property. This means that the class you requested is equal to the self-service language class.

+2
source share

Self-hosting . I know that Lisp is such a language, and Wikipedia called it a compiler for self-hosting.

+1
source share

Homoiconicity is a related concept, but I do not think that this is exactly what you are looking for.

In computer programming, homoiconicity is a property of some programming languages ​​in which the primary representation of programs is also a data structure in the primitive type of the language itself, from homo meaning the same representation of the icon icon. This simplifies metaprogramming than in a language without this property.

+1
source share
0
source share

Yes, I always thought it was included Reflection .

0
source share

All Articles