3 ms·
It's not just the danger. In sufficiently dynamic languages, it wreaks havoc on optimization unless you're prepared to essentially re-jit the entire code. Ruby
by vidarh 12y ago
It's not just the danger. In sufficiently dynamic languages, it wreaks havoc on optimization unless you're prepared to essentially re-jit the entire code.
Ruby for example - if you enter eval() with a string, you may exit it to find that even basic stuff like adding two integers together has changed (and may suddenly have side effects), so any work you've done to inline (or cache) fast paths may suddenly have been undone. It's not likely that the worst changes will have happened, but they may, and so unless the string is constant and you can analyse it upfront, you need to be prepared for them unless you want to restrict yourself to a subset of the language.