Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should using Eval carry the same stigma as GoTo?

Tags:

eval

goto

It is taught in every computer science class and written in many books that programmers should not use GoTo. There is even an xkcd comic about it. My question is have we reached a point where the same thing can be said about Eval?

Where GoTo is not conductive for program flow and readability, Eval is the same for debugging, and program execution, and design.

Should using Eval have the same stigma as GoTo, and same consequences as in the xkcd comic?

like image 975
QueueHammer Avatar asked Apr 09 '10 14:04

QueueHammer


2 Answers

If anything, it should carry more stigma.

GoTo often creates code that's difficult to maintain. Eval often creates code with security vulnerabilities - that's worse.

like image 148
JoeG Avatar answered Sep 30 '22 02:09

JoeG


Eval has some fairly serious security concerns; if there's any chance untrusted or user-supplied input can end up in an eval, it's vulnerable.

Jslint will warn about usage of eval() in js code run through it.

like image 37
Broam Avatar answered Sep 30 '22 03:09

Broam