Reflective programming

Effective use of reflection almost always requires a plan: A design framework, encoding description, object library, a map of a database or entity relations.

For example, it assists languages such as Java to operate well in networks by enabling libraries for serialization, bundling and varying data formats.

Languages without reflection such as C are required to use auxiliary compilers for tasks like Abstract Syntax Notation to produce code for serialization and bundling.

In some object-oriented programming languages such as C# and Java, reflection can be used to bypass member accessibility rules.

Compiled languages rely on their runtime system to provide information about the source code.

Reflection may allow a user to create unexpected control flow paths through an application, potentially bypassing security measures.

The following is an example in Common Lisp using the Common Lisp Object System: The following is an example in C#: This Delphi and Object Pascal example assumes that a TFoo class has been declared in a unit called Unit1: The following is an example in eC: The following is an example in Go: The following is an example in Java: The following is an example in JavaScript: The following is an example in Julia: The following is an example in Objective-C, implying either the OpenStep or Foundation Kit framework is used: The following is an example in Perl: The following is an example in PHP:[6] The following is an example in Python: The following is an example in R: The following is an example in Ruby: The following is an example using Xojo: