|
|
|
|
|
by todd8
2560 days ago
|
|
Performance differences are likely not that critical between reading small amounts of data using string I/O vs reading small amounts of data using a library routine that reads and evaluates the data. Runtime evaluation of a string as a language expression is often available in interpreted languages like Python, Ruby, or the Lisp family, and these languages are not usually used in the most performance sensitive programs. Three factors may make a difference between using the two aforementioned functions. First, performance can matter if the program is doing enough I/O. Secondly, the machinery needed to evaluate language expressions will have to be available at runtime, meaning that the executable will have to be interpreted by an interpreter capable of doing the evaluation (which Lisp, Python, etc. are—they have REPLs after all) or the executable in languages without a runtime interpreter will have to be linked statically or dynamically with code that does the evaluation, making it resulting executable larger. Third, there is the really important reason that programs should avoid reading and evaluating their inputs as expressions: security. A process runs code within a certain security context, generally with the same privileges as the user running the program. If the data input to the process can run expressions not found in the code, the program’s author can make few security guarantees about the results of running the program. Programs may receive input from the network and may even run at elevated security levels (e.g. setuid); these programs should not evaluate arbitrary input. For example, many security vulnerabilities come from database programs reading strings that are passed directly to the SQL interpreter. See the XKCD “Exploits of a Mom” [1]. [1] https://xkcd.com/327/ |
|
Lisp isn't an 'interpreted language'.
> have to be interpreted by an interpreter capable of doing the evaluation (which Lisp, Python, etc. are—they have REPLs after all)
SBCL, a Common Lisp implementation...
To me that looks like machine code...A bunch of Lisp implementations use compilers for evaluation in the Read-Eval-Print-Loop.