views:

1791

answers:

5

What is the origin of the term reflection? It seems more like introspection. Why isn't it called that?

Introspection: A looking inward; specifically, the act or process of self-examination.

Reflection:

  1. the act of reflecting or the state of being reflected.
  2. an image; representation; counterpart
  3. a fixing of the thoughts on something; careful consideration
  4. a thought occurring in consideration or meditation.
+4  A: 

There is another concept called type introspection that refers to the ability to determine the type of an object at runtime.

edit: I realize your question was intended to be language-agnostic, but in Java, reflection is used to identify what members an object has, whereas introspection allows you to identify which JavaBeans properties an object has, which is why the introspection class is in the java.beans package. I'm not sure what the exact difference between the terms would be in other languages, though,

dancavallaro
+15  A: 

Reflection comes from the idea of "self-examination, self-modification, and self-replication", reflecting on one's self for the purpose of change. In programming you use reflection to examine the structure of the program itself in the context of using it instead of just examining it. What you get back is a representation of the program that you can use to modify it, rather than the data on which it operates.

More information can be found at the wikipedia article..

tvanfosson
You didn't answer his question at all. Introspection: A looking inward; specifically, the act or process of self-examination.
Simucal
@Simucal, sorry I wasn't more clear. I've edited the answer to specify that it is examination with the intent of action.
tvanfosson
He did. He's stating that the term reflection is used according to the program's ability to reflect upon changes by modifying itself.
kRON
@kRON, my initial answer wasn't as specific.
tvanfosson
+19  A: 

There is an interesting answer on the french wikipedia article for Reflection (here)

Reflection can be decomposed in two parts:

  • introspection: a program can examinate itself.
  • intercession: a program can modify it state/meaning.

So reflection is a 'stronger' property than introspection. And that why you say type introspection for the ability to know types at runtime (and changing them is another action: conversion/casting).

EDIT: actually I just realized the first answer was saying exactly that ^^. Time to unplug myself...

Piotr Lesnicki
+1: I think yours is clearer
Roger Lipscombe
+1: I think yours is stronger!
Ziggy
+1  A: 

In .Net I think the term Reflection is very appropriate because it is not the type itself that is examined, it is the manifest of the code, which is only a description.

Guge
+1  A: 

Reflection, in the sense of definitions 3 and 4, can be introspective. That is, introspection is reflection on one's self. I think that introspection is the better word to use for the act of code analyzing itself because the word is more specific, but I don't think reflection is entirely inappropriate.

Greg Graham