Are languages โ€‹โ€‹with a metalinguistic abstraction different than those that use the reflection API?

Say, if I have a Lisp program that uses (eval 'sym)and searches for it in its symbol table, does it really work better than something like aClass.getField("sym", anInstance)in โ€œstaticโ€ languages?

+3
source share
3 answers

In general (problems with modular implementation, such as bytecode and native code or quality of code generation), languages โ€‹โ€‹with metalanguage abstraction provide more opportunities for creating programs that are superior to programs that can be created in comparable time with a language in which there are no such abstractions. The fact is that when you write an implementation for your own language, you have more information to make much more powerful optimizations than the compiler for the base language can do. In practice, there are many examples of this.

, , , ( " " ) . , ( " " ) .

(, , - ), (eval 'sym), , . , 'sum , . . eval :

  • ( - ) (, )
  • ( )

Java :

  • . , , hashtable
  • ( , )
  • ( )

, -.

+2

.

, , , aClass.getField( "sym", anInstance) , eval.

, . . .Net ( 100 ). , , . ? ? ?

+2

, , .

, Common Lisp EVAL.

Common Lisp , , , () , , , . ( ANSI-) CLOS- , .

Of course, the problem of comparing the performance of languages instead of implementations remains. Naturally, the common Lisp that was compiled for native code will work very differently from the common Lisp that is interpreted, and most CL implementations let you mix compiled and interpreted code (although some of them are provided only by compilers).

+2
source

Source: https://habr.com/ru/post/1719977/


All Articles