Eval Some dynamic languages offer an
eval function. This function takes a string or
abstract syntax tree containing code in the language and executes it. If this code stands for an expression, the resulting value is returned.
Erik Meijer and Peter Drayton distinguish the
runtime code generation offered by eval from the
dynamic loading offered by
shared libraries and warn that in many cases eval is used merely to implement
higher-order functions (by passing functions as strings) or
deserialization.
Object runtime alteration A type or object system can typically be modified during runtime in a dynamic language. This can mean generating new objects from a runtime definition or based on
mixins of existing types or objects. This can also refer to changing the
inheritance or type tree, and thus altering the way that existing types behave (especially with respect to the invocation of
methods).
Type inference As a lot of dynamic languages come with a dynamic type system, runtime inference of types based on values for internal interpretation marks a common task. As value types may change throughout interpretation, it is regularly used upon performing atomic operations.
Variable memory allocation Static programming languages (possibly indirectly) require developers to define the size of utilized memory before compilation (unless working around with pointer logic). Consistent with object runtime alteration, dynamic languages implicitly need to (re-)allocate memory based on program individual operations.
Reflection Reflective programming (reflection) is common in many dynamic languages, and typically involves
analysis of the types and metadata of generic or
polymorphic data. However, it can also include full evaluation and modification of a program's code as data, as in the features that
Lisp provides in analyzing
S-expressions.
Macros A limited number of dynamic programming languages provide features which combine
code introspection (the ability to examine classes, functions, and keywords to know what they are, what they do and what they know) and eval in a feature called
macros. Most programmers today who are aware of the term
macro have encountered them in
C or
C++, where they are a static feature which is built in a small subset of the language, and are capable only of string substitutions on the text of the program. In dynamic languages, however, they provide access to the inner workings of the compiler,
and full access to the interpreter, virtual machine, or runtime, allowing the definition of language-like constructs which can optimize code or modify the syntax or grammar of the language.
Assembly,
C,
C++, early
Java, and
Fortran do not generally fit into this category. The earliest dynamic programming language is considered to be Lisp (McCarthy, 1965) which continued to influence the design of programming languages to the present day. ==Example code==