It's a common misconception that a language must be "dynamic" or "interpreted" to have a REPL, a Read Evaluate Print Loop (also sometimes confusingly called an interpreter), or to have an "eval" function. That's not true at all.
Haskell, OCaml, F#, and Scala are all statically typed languages with very sophisticated static type systems, yet all have REPLs. All are usually compiled although interpreters exist for Haskell. Typed Racket (a variant of Scheme) is statically typed but has a REPL and I think it's always compiled.
Nor does a language have to be interpreted to have a REPL. Groovy is a dynamic language in both the dynamically typed sense and the "mutate my program structure at runtime" sense. It's always compiled, yet it has a REPL. JRuby (Ruby for the JVM) is similarly always compiled as far as I know, but has a REPL. Clojure and Erlang are always compiled, but both have REPLs.
The misconception about the nature of REPLs is caused by the C family of statically typed languages: C, C++, Java, C#, Objective-C and D. They do not tend to lend themselves to REPLs, but it's not because of the static typing or the compiling. It's because of the statement orientation and verbose boilerplate around every construct. A REPL is possible in those languages, it just wouldn't be very useful.
At heart, a REPL is always possible because "eval" is possible in any Turing complete language. That's CS 101 - see universal Turing machine and the Church-Turing thesis.
Remember that compiling vs interpreting is just an implementation choice as far as semantics are concerned. And stop looking to the C-ish languages as examples of the limits of static typing.
Dear Blogger,
ReplyDeletePlease help us! We recently invited you to participate in an online survey run by the Berkman Center at Harvard University about your experiences and opinions as an active blogger. To the best of our knowledge, we have not received your response to the survey. You can participate in the survey by following this link:
http://new.qualtrics.com/SE?Q_SS=3CvisrEArFu1Lvu_4Hp4lVv4k0EMdeI
Please feel free to contact us with any questions you may have. You can reach us at info@bloggingcommon.org or view our FAQ at http://bloggingcommon.org/research.
Thank you in advance for your time.
Sincerely,
The Blogging Common Team
Berkman Center for Internet & Society at Harvard University
eval : context -> term -> term
ReplyDeletewhere context is a map from variables names to types and term is a structure representing the ast of the phrases of the language.
I always considered gdb as a brain damaged REPL for C.
ReplyDeleteAnd stop looking to the C-ish languages as examples _for anything_. FTFY. :-)
ReplyDelete