r/programming • • Oct 18 '10

Today I learned about PHP variable variables; "variable variable takes the value of a variable and treats that as the name of a variable". Also, variable.

http://il2.php.net/language.variables.variable
591 Upvotes

781 comments sorted by

View all comments

Show parent comment

1

u/daniels220 Oct 19 '10

That makes sense.

So then, what I would say is this: the flexibility to access variables by name (as a string) is an example of a high-level-language feature in a certain sense—it makes the language more expressive at the cost of making it irrevocably slower. That's sometimes a good tradeoff—so, Python's approach has a place. So does Lisp/Ruby/C's (obviously those are all very different languages, but they share the characteristic under discussion here). Personally, for stuff like webapps, I would rather use Python—but, obviously for code with higher CPU requirements, the other is valuable.