Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
Search - "eval is evil"
A friend of mine (beginner) wrote a Python script that calculated the derivative function of an function the user typed in. He showed it to me and
I said: "You should not use eval()!"
He: "Oh, ok. May you write a parser?"
I: "Wait! It's ok. Just use eval!" 😂6
Eval is evil. I heard it often. So apparently, they put it there just merely to test you, whether you are a sinful coder deserving eternal damnation or not...
So, one thing I don't really like from people is sometimes they just believe in things without questioning anything. And worst... sometimes they get offended when some random poor guy ask a sensible question regarding to the belief.
Just because Richard Stallman said vi is evil, then they hate every vim users in the world.
Just because this easy-but-effective solution is not PSR-3 compliant, then they ditch it at all...
Ok, back to the eval-is-evil thing.
Yesterday, I show some part of code using safe-eval npm package to someone. And the reaction is like "yike... it's eval..."
So yes, eval is evil. But only if it's miss-used, just like anything else...
The drawbacks of eval are:
2. Performance. Eval is slow. Yes it is, because it is running a parser inside a parser. So it is just a mere calculator. And yes, it is slower 100 ms than native program. Problem?
3. Untrace-able error stack. But again, you just use that eval once. And if it is trowing an error, just catch it and let the user know that his input is wrong. Problem?
No, there is no real problem here. It's just eval is evil and it is...10
So this is a simple calculator I created by using react native. Pretty useful.
A very critical bug was found in this pitty app. Everything works well, but it has this line in it:
For me? Oh I'm a wreck stupid script kiddies who use eval that too lazy to create a so called clean solution...
Also, this funny ecma script foundation put this eval thing so that you should not use it ever...
I heard a similar funny-but-ironic story about a Supernatural Entity who put a pity apple tree in the garden of eden, so that, everyone eat it's fruit become pricky mother fucker who never listen at anyone's argument. They blindly follow everything told by the linter. Because the linter is a perfect entity who knows your use case more than you.
And I'm really sorry, I'm just a sad moron script kiddies, please -- this rant and tell me again why eval is evil.
Because I'm too stupid to understand the risk of using eval, even if it is safe-eval. Also, tell me again this safe-eval is not save if I accidentally put global context as argument. I don't do it, but let's consider this possibility as bug...
No, mother fucker, you are not superior. You are just an asshole trying to act cool. You say something is dirty, and you don't provide any cleaner solution. Why? because you are a knight with shining armor. A certified developer who never goes to real battlefield. It is always fun right?, to see how people doing things "wrongly" and make fun of it without doing anything...
Ah, don't worry, you don't need to know how to do things correctly. You only need to pray to your linter 12 times a day in order to feel superior...5
Favorite function : PHP eval()
Really epic/nasty stuff can be done with eval()
Remember: eval() is evil!1