20

SML在现实世界中的用途是什么?

它的实际用途是否与 Prolog 相似?

4

7 回答 7

27

At work, we use SML in actual real-life software products which we ship to paying customers. We use MLton to compile our SML code to native code running on Windows, Linux, Solaris, AIX, and HP-UX. It works well, and we're happy with our choice.

I don't see SML as particularly suited to any clear niche. Indeed, SML is a very well-rounded general-purpose programming language. Prolog is well established in the logic programming/artifical intelligence/rule based system solving niche(s), but it's used for a lot of things besides these traditional domains.

For anyone who is considering using SML for a software project in the "real world", here are some of the advantages and disadvantages we've noticed so far:

  • SML is a very nice general programming language, especially the module system rocks
  • MLton optimizes so well that you can use abstractions freely without losing performance
  • Our old code is written in plain C. We can replace that piece by piece with SML, linking both C and SML code to the same executbles.
  • SML/NJ provides a repl for rapid development
  • Portable to all of our platforms

Disadvantages:

  • Miniscule user base
  • Lacking in the supporting tools area (IDE, code documentation, debuggers, etc.)
  • I had to actually port MLton myself to AIX and HP-UX
于 2009-05-01T19:00:00.450 回答
6

ML 不能直接与 Prolog 相提并论。Prolog 是一种声明性逻辑编程语言,基本上是使用 Horn 子句的定理证明器。(非纯 Prolog)的优点之一是它允许您在编译或运行时严格修改程序。例如,在大多数现代 Prolog 实现中,您可以使用 DCG(定句语法)形式直接编写语法。使用“-->”运算符的语法规则使用术语扩展重写为 Prolog 子句。例如:

a(N) --> b, c(N).

将被改写为:

a(N,P0,P2) :- b(P0,P1), c(N,P1,P2).

位置变量的使用强制箭头右侧的女儿相邻。由于 Prolog 将尝试通过证明子句(通过回溯)来证明子句的头部,因此您基本上拥有一个自上而下的左右解析器,无需任何额外工作。程序修改的另一个示例是(动态)事实或子句的断言或撤回,可用于修改程序在运行时的行为。

另一方面,ML 是一种不纯的函数式语言。Prolog 和 ML 之间的联系是一些定理证明器是用 ML 编写的。我会说 ML 更通用,但对于它的利基,Prolog 非常方便。两者都非常有用,即使只是为了拓宽你的视野。

于 2009-04-14T22:12:09.617 回答
3

SML is used by compiler writers. Both Prolog and SML are used in theorem provers.

于 2009-04-07T08:14:14.567 回答
2

卡内基梅隆大学的FoxNet 项目是使用 SML 构建的。

Jane Street 专有贸易公司,使用 O'Caml 为他们自己的内部构建软件。

ML for the Working Programmer 一书的作者 Laurance C. Paulson 使用 SML 构建了 LCF 定理证明器 Isabell。

教授和 Haskell 专家 Philip Wadler 维护了一个使用函数式编程的现实世界项目列表,其中包括使用 ML 的项目,位于 http://homepages.inf.ed.ac.uk/wadler/realworld/

于 2012-01-30T08:44:57.390 回答
1

I have only personally used it in university for a number theory course. I have to say I really enjoyed using it. It could handle huge numbers which was nice when dealing with cryptography.

If it matters I was using Moscow ML http://www.itu.dk/people/sestoft/mosml.html

于 2009-04-07T08:07:04.817 回答
1

I haven't seen many commercial applications of ML, but this may be down to the available environments, rather than a reflection on the language. I've seen a number of banks using F# (which is the same family as ML) to process data streams, do matrix algebra and look for patterns. The fact that Microsoft have packaged it for .NET obviously helps no end.

于 2009-04-07T08:14:01.073 回答
1

Not SML, but closely related, is OCAML, which has been used for a number of things:

http://caml.inria.fr/about/successes.en.html

I rather like the "Faster Fourier Transform in the West" where ML is used to generate optimised C...

于 2009-04-07T08:27:44.237 回答