I really liked learning ML at college. I find functional programming often a refreshingly elegant way to write certain algorithms. I have heard of F# and played around with that a bit. Still, I've written some interesting functions in ML and would like to integrate them as libraries I could use in other applications.
我非常喜欢在大学学习ML。我发现函数式编程通常是一种令人耳目一新的方式来编写某些算法。我听说过F#并且玩了一下。不过,我在ML中编写了一些有趣的函数,并希望将它们集成为我可以在其他应用程序中使用的库。
Usually I paste my functions into the SMLnj interpreter. Is there a way I can compile them down?
通常我将我的函数粘贴到SMLnj解释器中。有没有办法可以编译它们?
5 个解决方案
#1
You will have to use something like the MLj Compiler. It compiles to Java Byte code. Or you can use the SML.NET compiler to compile to .NET IL.
你将不得不使用类似MLj编译器的东西。它编译为Java Byte代码。或者您可以使用SML.NET编译器编译为.NET IL。
#2
It is common amongst ML for both sides to export to C and then call each others C functions. Just about everything has a FFI library for 'easily' exporting to C.
双方共同出口到C然后互相称呼C函数在ML中是常见的。几乎所有东西都有一个FFI库,可以“轻松”导出到C.
http://www.smlnj.org/doc/SMLNJ-C/index.html
so to the outside world your sml library would behave like a C library except with out the assiciated segfaults and memory leaks*
所以对于外面的世界,你的sml库会像C库一样表现出来,除了没有关联的段错误和内存泄漏*
*not a guarantee
*不是保证
#3
Projects popularize languages. Do the ground work for an interesting and undeniably 'cool' project using ML, and people will flock to the language. For instance,look at Erlang with ejabberd and mochiweb - both cool projects that have done wonders for a one-time-diamond-in-the-rough language like erlang (which is, btw, my development language of choice lately). I for one, would love to see somebody make something rad with ML, the language is a joy to think with.
项目普及语言。使用ML为一个有趣且无可否认的“酷”项目做好准备,人们会蜂拥而至。例如,看一下Erlang与ejabberd和mochiweb - 这两个很酷的项目已经为像erlang这样的一次性钻石般的语言创造了奇迹(顺便说一下,这是我最近选择的开发语言)。我是一个人,很想看到有人用ML做出一些事情,语言是一种快乐的思考方式。
#4
There are several Standard ML compilers. The MLton wiki also contains a benchmark.
有几个标准ML编译器。 MLton维基也包含一个基准。
I used Moscow ML which compiles Standard ML into bytecode. It's not fast, but it works. MLton is often cited to be the best Standard ML compiler with regard to efficiency.
我使用了莫斯科ML,它将标准ML编译为字节码。它并不快,但它确实有效。在效率方面,MLton经常被认为是最好的标准ML编译器。
#5
Note that Poly/ML version 5 or later supports both the traditional "heap dump" model, and C-style standalone executables. The documentation on the Poly/ML website is spread over many different spots, some of them with really old dates in the title -- but the system is alive and kicking.
请注意,Poly / ML版本5或更高版本支持传统的“堆转储”模型和C风格的独立可执行文件。 Poly / ML网站上的文档分布在许多不同的地方,其中一些在标题中有很旧的日期 - 但系统还活着并且踢得很开心。
The object-code generation is explained in passing in release notes for the version 5.0 release (we are presently at 5.5): see PolyML.export
there.
在发布5.0版本的发行说明(我们目前在5.5)中解释了对象代码的生成:请参阅那里的PolyML.export。
There is also some Poly/ML C interface, which has been renovated as used for some GUI projects recently. You should ask at the polyml mailing list.
还有一些Poly / ML C接口,最近已经过一些GUI项目的翻新。您应该在polyml邮件列表中询问。
#1
You will have to use something like the MLj Compiler. It compiles to Java Byte code. Or you can use the SML.NET compiler to compile to .NET IL.
你将不得不使用类似MLj编译器的东西。它编译为Java Byte代码。或者您可以使用SML.NET编译器编译为.NET IL。
#2
It is common amongst ML for both sides to export to C and then call each others C functions. Just about everything has a FFI library for 'easily' exporting to C.
双方共同出口到C然后互相称呼C函数在ML中是常见的。几乎所有东西都有一个FFI库,可以“轻松”导出到C.
http://www.smlnj.org/doc/SMLNJ-C/index.html
so to the outside world your sml library would behave like a C library except with out the assiciated segfaults and memory leaks*
所以对于外面的世界,你的sml库会像C库一样表现出来,除了没有关联的段错误和内存泄漏*
*not a guarantee
*不是保证
#3
Projects popularize languages. Do the ground work for an interesting and undeniably 'cool' project using ML, and people will flock to the language. For instance,look at Erlang with ejabberd and mochiweb - both cool projects that have done wonders for a one-time-diamond-in-the-rough language like erlang (which is, btw, my development language of choice lately). I for one, would love to see somebody make something rad with ML, the language is a joy to think with.
项目普及语言。使用ML为一个有趣且无可否认的“酷”项目做好准备,人们会蜂拥而至。例如,看一下Erlang与ejabberd和mochiweb - 这两个很酷的项目已经为像erlang这样的一次性钻石般的语言创造了奇迹(顺便说一下,这是我最近选择的开发语言)。我是一个人,很想看到有人用ML做出一些事情,语言是一种快乐的思考方式。
#4
There are several Standard ML compilers. The MLton wiki also contains a benchmark.
有几个标准ML编译器。 MLton维基也包含一个基准。
I used Moscow ML which compiles Standard ML into bytecode. It's not fast, but it works. MLton is often cited to be the best Standard ML compiler with regard to efficiency.
我使用了莫斯科ML,它将标准ML编译为字节码。它并不快,但它确实有效。在效率方面,MLton经常被认为是最好的标准ML编译器。
#5
Note that Poly/ML version 5 or later supports both the traditional "heap dump" model, and C-style standalone executables. The documentation on the Poly/ML website is spread over many different spots, some of them with really old dates in the title -- but the system is alive and kicking.
请注意,Poly / ML版本5或更高版本支持传统的“堆转储”模型和C风格的独立可执行文件。 Poly / ML网站上的文档分布在许多不同的地方,其中一些在标题中有很旧的日期 - 但系统还活着并且踢得很开心。
The object-code generation is explained in passing in release notes for the version 5.0 release (we are presently at 5.5): see PolyML.export
there.
在发布5.0版本的发行说明(我们目前在5.5)中解释了对象代码的生成:请参阅那里的PolyML.export。
There is also some Poly/ML C interface, which has been renovated as used for some GUI projects recently. You should ask at the polyml mailing list.
还有一些Poly / ML C接口,最近已经过一些GUI项目的翻新。您应该在polyml邮件列表中询问。