Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8821089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:46:04+00:00 2026-06-14T05:46:04+00:00

Lately I came across the eval() function in a couple of places (some D

  • 0

Lately I came across the eval() function in a couple of places (some D and JavaScript code). This experience make me realize that I didn’t understand the difference between a language with or without eval().

In fact, I have been able to survive without using it (although sometimes is tempting :)).

Do you know from any fundamental difference between a language implementing eval() and a language that does not implement it (even if it is at compile time)? If there is no fundamental difference is there an expressiveness difference?

Do you know any paper or reference explaining what is the added computational power/expressiveness provided by eval()? This is, What can we implement with eval() that we can not implement without it (or at a higher cost)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:46:05+00:00Added an answer on June 14, 2026 at 5:46 am

    There is no difference in capability between a language with eval and a language without. You can always implement eval yourself in a language that doesn’t have it, although it is easier in some languages (Lisp) and harder in other languages (C). This is why we know it doesn’t add any new capabilities to a language.

    Eval is generally considered “powerful but dangerous and unnecessary in production code”. If you ever get your source code reviewed, and it uses eval, you will have to get used to people telling you not to use eval. Usually, if you use eval, there is a more straightforward and safer way to accomplish the same task.

    Security vulnerabilities

    The eval function often leads to security vulnerabilities, such as in web applications. For example, in Python:

    i = input('Enter a number> ')
    

    The input function in Python prior to 3.x evaluates the user input, leading to security problems:

    Enter a number> __import__('os').system('rm -rf $HOME') # DO NOT TRY THIS
    

    This can be avoided in fully sandboxed runtimes, such as JavaScript, Lua, CLI, etc. However, in code that is not sandboxed, it is just too difficult to use eval safely.

    REPL

    The one glorious use of eval is the REPL, which is a useful tool for software development. In Google Chrome, you can bring a REPL up right now by pressing Ctrl+Shift+I — just start typing JavaScript in the box that comes up. Firefox and Safari both have REPLs too.

    Why not include eval?

    The eval function is usually incredibly complex. Including it in the standard library means that the library or runtime has to include a complete compiler or interpreter for the language, which is a hefty chunk of code. That’s why you usually see eval in languages that are typically interpreted or JITed — Lisp, Python, and JavaScript runtimes typically already include a complete compiler, so eval is no extra baggage.

    Implementations of eval for C are real beasts, so they’re optional and shoved into libraries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Doing some code reviews lately I came across a number of classes that have
I have been reading over some code lately and came across some lines such
I've been learning Objective C lately, and I came across some code for using
I've been reading on Generics lately, and I came across this method: protected <V>
Lately I've been writing some JS code using jQuery and JavaScript as it is
I've been practicing certain techniques in XNA and lately came across an issue that's
I've been fiddling with flash lately and I came across this issue. I've noticed
I've been working a lot with JavaScript lately and have created some large function
Lately I came across some weird behavior with the defined? operator used to check
I've been trying to self-teach some OOP lately, and I came across something which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.