Joel Spolsky praised native-code versions of programs that have no dependencies on runtimes.
Joel Spolsky赞扬了不依赖于运行时的本机代码版本的程序。
What native-code compilers are available for functional languages?
什么本机代码编译器可用于函数式语言?
4 个解决方案
#1
10
This post is really quite unclear. The question appears to be "Are there compilers for functional languages which can produce native executables without the need to install additional software?"
这篇文章真的很不清楚。问题似乎是“是否存在可以生成本机可执行文件而无需安装其他软件的函数式语言编译器?”
The answer, generally, is yes. For example, Haskell has a compiler that produces native binaries. Many other functional languages have similar compilers.
一般来说,答案是肯定的。例如,Haskell有一个生成本机二进制文件的编译器。许多其他函数语言都有类似的编译器。
#2
6
Yeah, also:
ocamlc
is the bytecode compiler, and ocamlopt
is the native code compiler. GCL
compiles Common Lisp to native binaries.
ocamlc是字节码编译器,ocamlopt是本机代码编译器。 GCL将Common Lisp编译为本机二进制文件。
There isn't anything for F# since, for what I am aware of, .NET doesn't have a native compiler, like Joel mentions. Actually, CSML can be used to call C# from ocaml, uhh, not sure if you can compile this down to native code --it doesn't seem likely-- although the documentation alludes to it, yet it is very incomplete.
F#没有任何东西,因为据我所知,.NET没有像Joel提到的原生编译器。实际上,CSML可以用来从ocaml调用C#,呃,不确定你是否可以将它编译成本机代码 - 虽然文件似乎不太可能 - 虽然它是非常不完整的。
#3
4
A lot of functional languages are compiled just like any other language.
许多函数式语言的编译方式与其他语言一样。
For example in Clojure:
例如在Clojure中:
- The reader translates the source code text into a data structure that represents the program (an s-expression)
- If required, macros are then applied to transform the code
- The Clojure compiler then translates the code into Java bytecode - this is the same machine-portable format used by Java, Scala and other JVM languages
- Finally, the JIT compiler in the JVM converts the bytecode to native machine code, possibly performing various optimisations on the fly. This is the code that then gets directly executed on whatever platform it is running.
读者将源代码文本转换为表示程序的数据结构(s表达式)
如果需要,然后应用宏来转换代码
然后,Clojure编译器将代码转换为Java字节码 - 这与Java,Scala和其他JVM语言使用的机器可移植格式相同
最后,JVM中的JIT编译器将字节码转换为本机机器码,可能会动态执行各种优化。这是在运行的任何平台上直接执行的代码。
One interesting point is that all this happens dynamically, i.e. at any point during program execution you can write new source code, pass it through the reader and various compilation steps and run the new compiled native code without having to restart the program. This is important as it enables interactive development at the REPL while still providing the benefits of fully compiled code.
一个有趣的观点是,所有这些都是动态发生的,即在程序执行期间的任何时候,您都可以编写新的源代码,通过读取器和各种编译步骤,并运行新编译的本机代码,而无需重新启动程序。这很重要,因为它可以在REPL中实现交互式开发,同时仍然提供完全编译代码的好处。
#4
1
PLT Scheme has got a JIT compiler.
PLT Scheme有一个JIT编译器。
Stalin is a Scheme compiler which does ridiculously aggressive optimisation.
斯大林是一个Scheme编译器,可以进行极其激进的优化。
All Common Lisp implementations that I know of except CLISP compile to native code. (Whether one ought to consider CL a functional language depends on what is meant by the term “functional”, however.)
除了CLISP之外,我所知道的所有Common Lisp实现都编译为本机代码。 (然而,是否应该将CL视为功能性语言取决于术语“功能性”的含义。)
MLton is a highly optimising compiler for Standard ML.
MLton是Standard ML的高度优化编译器。
Functional languages can be and have for some time been compiled very effectively. There is no difference to imperative languages in this regard.
功能语言可以并且有一段时间非常有效地编译。在这方面,命令式语言没有区别。
#1
10
This post is really quite unclear. The question appears to be "Are there compilers for functional languages which can produce native executables without the need to install additional software?"
这篇文章真的很不清楚。问题似乎是“是否存在可以生成本机可执行文件而无需安装其他软件的函数式语言编译器?”
The answer, generally, is yes. For example, Haskell has a compiler that produces native binaries. Many other functional languages have similar compilers.
一般来说,答案是肯定的。例如,Haskell有一个生成本机二进制文件的编译器。许多其他函数语言都有类似的编译器。
#2
6
Yeah, also:
ocamlc
is the bytecode compiler, and ocamlopt
is the native code compiler. GCL
compiles Common Lisp to native binaries.
ocamlc是字节码编译器,ocamlopt是本机代码编译器。 GCL将Common Lisp编译为本机二进制文件。
There isn't anything for F# since, for what I am aware of, .NET doesn't have a native compiler, like Joel mentions. Actually, CSML can be used to call C# from ocaml, uhh, not sure if you can compile this down to native code --it doesn't seem likely-- although the documentation alludes to it, yet it is very incomplete.
F#没有任何东西,因为据我所知,.NET没有像Joel提到的原生编译器。实际上,CSML可以用来从ocaml调用C#,呃,不确定你是否可以将它编译成本机代码 - 虽然文件似乎不太可能 - 虽然它是非常不完整的。
#3
4
A lot of functional languages are compiled just like any other language.
许多函数式语言的编译方式与其他语言一样。
For example in Clojure:
例如在Clojure中:
- The reader translates the source code text into a data structure that represents the program (an s-expression)
- If required, macros are then applied to transform the code
- The Clojure compiler then translates the code into Java bytecode - this is the same machine-portable format used by Java, Scala and other JVM languages
- Finally, the JIT compiler in the JVM converts the bytecode to native machine code, possibly performing various optimisations on the fly. This is the code that then gets directly executed on whatever platform it is running.
读者将源代码文本转换为表示程序的数据结构(s表达式)
如果需要,然后应用宏来转换代码
然后,Clojure编译器将代码转换为Java字节码 - 这与Java,Scala和其他JVM语言使用的机器可移植格式相同
最后,JVM中的JIT编译器将字节码转换为本机机器码,可能会动态执行各种优化。这是在运行的任何平台上直接执行的代码。
One interesting point is that all this happens dynamically, i.e. at any point during program execution you can write new source code, pass it through the reader and various compilation steps and run the new compiled native code without having to restart the program. This is important as it enables interactive development at the REPL while still providing the benefits of fully compiled code.
一个有趣的观点是,所有这些都是动态发生的,即在程序执行期间的任何时候,您都可以编写新的源代码,通过读取器和各种编译步骤,并运行新编译的本机代码,而无需重新启动程序。这很重要,因为它可以在REPL中实现交互式开发,同时仍然提供完全编译代码的好处。
#4
1
PLT Scheme has got a JIT compiler.
PLT Scheme有一个JIT编译器。
Stalin is a Scheme compiler which does ridiculously aggressive optimisation.
斯大林是一个Scheme编译器,可以进行极其激进的优化。
All Common Lisp implementations that I know of except CLISP compile to native code. (Whether one ought to consider CL a functional language depends on what is meant by the term “functional”, however.)
除了CLISP之外,我所知道的所有Common Lisp实现都编译为本机代码。 (然而,是否应该将CL视为功能性语言取决于术语“功能性”的含义。)
MLton is a highly optimising compiler for Standard ML.
MLton是Standard ML的高度优化编译器。
Functional languages can be and have for some time been compiled very effectively. There is no difference to imperative languages in this regard.
功能语言可以并且有一段时间非常有效地编译。在这方面,命令式语言没有区别。