简体   繁体   English

在“真实世界”应用程序中使用ML

[英]Using ML in “Real-World” Applications

I really liked learning ML at college. 我非常喜欢在大学学习ML。 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. 我听说过F#并且玩了一下。 Still, I've written some interesting functions in ML and would like to integrate them as libraries I could use in other applications. 不过,我在ML中编写了一些有趣的函数,并希望将它们集成为我可以在其他应用程序中使用的库。

Usually I paste my functions into the SMLnj interpreter. 通常我将我的函数粘贴到SMLnj解释器中。 Is there a way I can compile them down? 有没有办法可以编译它们?

You will have to use something like the MLj Compiler . 你将不得不使用类似MLj编译器的东西。 It compiles to Java Byte code. 它编译为Java Byte代码。 Or you can use the SML.NET compiler to compile to .NET IL. 或者您可以使用SML.NET编译器编译为.NET IL。

It is common amongst ML for both sides to export to C and then call each others C functions. 双方共同出口到C然后互相称呼C函数在ML中是常见的。 Just about everything has a FFI library for 'easily' exporting to C. 几乎所有东西都有一个FFI库,可以“轻松”导出到C.

http://www.smlnj.org/doc/SMLNJ-C/index.html 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 *不是保证

Projects popularize languages. 项目普及语言。 Do the ground work for an interesting and undeniably 'cool' project using ML, and people will flock to the language. 使用ML为一个有趣且无可否认的“酷”项目做好准备,人们会蜂拥而至。 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). 例如,看一下Erlang与ejabberd和mochiweb - 这两个很酷的项目已经为像erlang这样的一次性钻石般的语言创造了奇迹(顺便说一下,这是我最近选择的开发语言)。 I for one, would love to see somebody make something rad with ML, the language is a joy to think with. 我是一个人,很想看到有人用ML做出一些事情,语言是一种快乐的思考方式。

There are several Standard ML compilers . 几个标准ML编译器 The MLton wiki also contains a benchmark . MLton维基也包含一个基准

I used Moscow ML which compiles Standard ML into bytecode. 我使用了莫斯科ML,它将标准ML编译为字节码。 It's not fast, but it works. 它并不快,但它确实有效。 MLton is often cited to be the best Standard ML compiler with regard to efficiency. 在效率方面,MLton经常被认为是最好的标准ML编译器。

Note that Poly/ML version 5 or later supports both the traditional "heap dump" model, and C-style standalone executables. 请注意,Poly / ML版本5或更高版本支持传统的“堆转储”模型和C风格的独立可执行文件。 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网站上的文档分布在许多不同的地方,其中一些在标题中有很旧的日期 - 但系统还活着并且踢得很开心。

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. 还有一些Poly / ML C接口,最近已经过一些GUI项目的翻新。 You should ask at the polyml mailing list. 您应该在polyml邮件列表中询问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM