Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the relationship between static typing and lazy functional languages? [closed]

I'm curious about the relationship between static typing and lazy functional languages. Is it possible to have a dynamic lazy functional language, for instance? It seems as if all of the lazy functional languages out there are statically typed (Haskell, Miranda, etc), and all of the dynamic functional languages use strict evaluation (Clojure, Scheme, etc).

In particular, the Wikipedia article on Lazy evaluation reads:

However, with lazy evaluation, it is difficult to combine with imperative features such as exception handling and input/output, because the order of operations becomes indeterminate. Lazy evaluation can introduce space leaks.

What is the role that static typing plays in preventing space leaks?

like image 969
Josh Voigts Avatar asked Oct 16 '12 01:10

Josh Voigts


People also ask

What is difference between static typing and dynamic typing?

There are two main differences between dynamic typing and static typing that you should be aware of when writing transformation scripts. First, dynamically-typed languages perform type checking at runtime, while statically typed languages perform type checking at compile time.

What is a lazy functional language?

Haskell is a lazy language. This means that the evaluation of expressions is delayed until their values are actually needed. The opposite is eager evaluation, which is what most programming languages implement, like C, Java, and Python.

What is the difference between static and dynamic typing in Python?

Python is a dynamically typed language which means checking of the variable is done at the runtime. Whereas in the Statically typed language the checking of the variables or any other is done at the compile time.

What is the difference between dynamically typed and statically typed languages Mcq?

Statically typed languages: each variable and expression is already known at compile time. Dynamically typed languages: variables can receive different values at runtime and their type is defined at run time.


1 Answers

I don't believe that static types play a role at all. For example, consider the untyped lazy language, Lazy Racket. I haven't heard any indication that it leaks space in a way that Haskell (for example) does not.

Side effects, on the other hand, are a problem because humans find the order of evaluation of strict evaluation to be (relatively) natural, and call-by-need is much harder to mentally predict.

like image 57
Paul Stansifer Avatar answered Jan 02 '23 02:01

Paul Stansifer