What is Lazy Evaluation?

 If you create any RDD from an existing RDD that is called as transformation and unless you call an action your RDD will not be materialized the reason is Spark will delay the result until you really want the result because there could be some situations you have typed something and it went wrong and again you have to correct it in an interactive way it will increase the time and it will create un-necessary delays. Also, Spark optimizes the required calculations and takes intelligent decisions which is not possible with line by line code execution. Spark recovers from failures and slow workers.

Asked on January 18, 2019 in Apache-spark.
Add Comment


  • 12 Answer(s)
    1. It can boost efficiency. This is the obvious-looking one, but it’s not actually the most important. (Note also that laziness can kill efficiency too – this fact is not immediately obvious. However, by storing up lots of temporary results rather than calculating them immediately, you can use up a huge amount of RAM.)
    2. It lets you define flow control constructs in normal user-level code, rather than it being hard-coded into the language. (E.g., Java has for loops; Haskell has a for function. Java has exception handling; Haskell has various types of exception monad. C# has goto; Haskell has the continuation monad…)
    3. It lets you decouple the algorithm for generating data from the algorithm for deciding how muchdata to generate. You can write one function that generates a notionally-infinite list of results, and another function that processes as much of this list as it decides it needs. More to the point, you can have five generator functions and five consumer functions, and you can efficiently produce any combination – instead of manually coding 5 x 5 = 25 functions that combine both actions at once. (!) We all know decoupling is a good thing.
    4. It more or less forces you to design a pure functional language. It’s always tempting to take short-cuts, but in a lazy language, the slightest impurity makes your code wildly unpredictable, which strongly militates against taking shortcuts.
    Answered on January 19, 2019.
    Add Comment

    Lazy evaluation is an evaluation strategy which holds the evaluation of an expression until its value is needed. It avoids repeated evaluation. Haskell is a good example of such a functional programming language whose fundamentals are based on Lazy Evaluation.

    Lazy evaluation is used in Unix map functions to improve their performance by loading only required pages from the disk. No memory will be allocated for the remaining pages.

    Answered on January 20, 2019.
    Add Comment

    Lazy evaluation is a method to evaluate a Haskell program. It means that expressions are not evaluated when they are bound to variables, but their evaluation is deferred until their results are needed by other computations. In consequence, arguments are not evaluated before they are passed to a function, but only when their values are actually used.

    Technically, lazy evaluation means call-by-name plus Sharing. A kind of opposite is eager evaluation.

    Answered on January 20, 2019.
    Add Comment

    When a compiler encounters an expression,usually it tries to evaluate it. Evaluation is the process of getting the root meaning of a piece of code.
    While most languages do this immediately,it’s not very efficient. Not all expression are worth evaluating. For instance,function parameters might go unused,so we don’t need to evaluate them.

    Answered on January 20, 2019.
    Add Comment

    In lazy evaluation,an expression doesn’t immediate yield a value,but instead it yields or may yield a “thunk” which is conceptually a pointer to needed data,and a pointer to a function to call to actually calculate the value.

    Answered on January 20, 2019.
    Add Comment

    In programming language theory, lazy evaluation, or call-by-need. It is an evaluation strategy which delays the evaluation of an expression until its value is needed (non-strict evaluation) and which also avoids repeated evaluations (sharing). The sharing can reduce the running time of certain functions by an exponential factor over other non-strict evaluation strategies, such as call-by-name.

    Answered on January 26, 2019.
    Add Comment

    good programmer!”, your brain is evaluating the “she” in the sentence. If “she” was defined earlier, it will evaluate to a pointer to a person. 🙂
    While most languages do this immediately, it’s not very efficient. Not all expressions are worth evaluating. For instance, function parameters might go unused, so we don’t need to evaluate them.
    def someFunction(x, y) =
    return x + 1
    someFunction(3, 3 + 2)
    In the example above there is no point in evaluating 3 + 2, because it’s not used. The style of only evaluating what’s needed is called lazy evaluation, while the opposite (evaluating immediately) is called strict evaluation.
    It’s called “lazy” because the compiler will procrastinate. It will not be a good student and study in advance. Instead, it will postpone the evaluation until it’s absolutely needed, and only then will it say, “Sigh. All right, I’ll evaluate your darn expression.”

    Answered on January 27, 2019.
    Add Comment

    In programming language theory, lazy evaluation, or call-by-need  is an evolution staergy which delays the evaluation of an expression until its value is needed  and which also avoids repeated evaluations . The sharing can reduce the running time of certain functions by an exponential factor over other non-strict evaluation strategies, such as call-by-name.

    The benefits of lazy evaluation include:

    • The ability to define control flow (structures) as abstractions instead of primitives.
    • The ability to define potentially infinite data structures. This allows for more straightforward implementation of some algorithms.
    • Performance increases by avoiding needless calculations, and avoiding error conditions when evaluating compound expressions.
    Answered on February 3, 2019.
    Add Comment

    In programming language theory, lazy evaluation, or call-by-need[1] is an evaluation strategy which delays the evaluation of an expression until its value is needed (non-strict evaluation) and which also avoids repeated evaluations (sharing).[2][3] The sharing can reduce the running time of certain functions by an exponential factor over other non-strict evaluation strategies, such as call-by-name.[citation needed]

    The benefits of lazy evaluation include:

    The ability to define control flow (structures) as abstractions instead of primitives.
    The ability to define potentially infinite data structures. This allows for more straightforward implementation of some algorithms.
    Performance increases by avoiding needless calculations, and avoiding error conditions when evaluating compound expressions.

    Answered on February 4, 2019.
    Add Comment

    One website said : In Python 3.x the range() function returns a special range object which computes elements of the list on demand (lazy or deferred evaluation): >>> r = range(10) >>> print(r) range(0, 10) >>> print(r[3]) 3 What is meant by this? …

    Answered on February 5, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.