Since Javascript is an interpreted language, entire functions can be changed dur
ID: 646880 • Letter: S
Question
Since Javascript is an interpreted language, entire functions can be changed during runtime. I have recently been contemplating a framework that would allow for dynamic code changes (such as UI plugins) to take effect without having to reload the page, while still providing enough information to undo the change if desired.
I have begun to test this concept with small examples with success, but have not had the chance to test the idea for anything useful.
Is there any common adverse side effects to changing code during runtime or is it considered bad practice?
Explanation / Answer
Self-modifying code has been almost universally viewed as an invention of the devil almost since the beginning of computing time.
The fundamental issue is this: When the code can modify itself at runtime, you no longer have any idea what code is really running. Is it the code in the listing, or is it something that was beamed down from an extraterrestrial hacker on the smaller moon of Rigel 7?
Plugins are useful, but you want to be very careful what you do and what you allow plugins to do.