Clojure是编译还是解释? [英] Is Clojure compiled or interpreted?

查看:144
本文介绍了Clojure是编译还是解释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了Clojure编译的地方。

I read somewhere Clojure is compiled. Is it really compiled, like Java or Scala, rather than interpreted, like Jython or JRuby?

推荐答案

Clojure是总是编译

Clojure编译器生成Java字节代码,然后通过JVM将其编译为本地代码。

The Clojure compiler produces Java byte code, which is typically then JIT-compiled to native code by the JVM.

可以混淆的事情是Clojure的动态和交互性,这意味着如果你想要在运行时调用编译器。这是Lisp代码是数据传统的所有部分。

The thing that can be confusing is the dynamic and interactive nature of Clojure that means you can invoke the compiler at run-time if you want to. This is all part of the Lisp "code is data" tradition.

例如,下面将在运行时调用Clojure编译器来编译和执行形式(+ 1 2)

For example, the following will invoke the Clojure compiler at run-time to compile and execute the form (+ 1 2):

(eval '(+ 1 2))
=> 3

在运行时调用编译器的功能非常有用 - 例如,通过使用REPL在运行的Clojure应用程序中编译和运行新代码。但重要的是不要将这种交互式的开发风格与解释混淆 - Clojure开发是互动的,但仍然总是编译。

The ability to invoke the compiler at run-time is very useful - for example it enables you to compile and run new code in the middle of a running Clojure application by using the REPL. But it's important not to confuse this "interactive" style of development with being "interpreted" - Clojure development is interactive, but still always compiled.

这篇关于Clojure是编译还是解释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆