我应该学习哪种Lisp方言? [英] Which dialect of Lisp should I learn?

查看:191
本文介绍了我应该学习哪种Lisp方言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道Lisp有几种不同的方言.决定学习Lisp将是一种新的知识体验之后,我想知道该学习哪种Lisp方言,以及为什么.

I know there are a few different dialects of Lisp. Having decided that learning Lisp would be a new intellectual experience, I would like to know which Lisp dialect to learn, and why.

有没有一个比其他人更受欢迎?它们中的任何一个是否更完整",如文档中得到更好的记录和支持?这种方言的优缺点是什么?

Is there one which is more popular than the others? Is any one of them more "complete", as in, better documented and supported? What are the pros and cons of this dialect?

推荐答案

您想要在简洁与整洁,引人入胜的功能以及一个平台之间找到平衡,该平台将使您能够(自己)编写有趣且有用的软件以及作为学习工具. (这最后一个可以使您继续学习并学习更长的时间.)以下是一些可能性:

You want to look for a balance between simplicity and cleanliness, attractive features, and a platform that will allow you to write interesting and useful software (to yourself) as well as serve as a learning tool. (This last will keep you going and learning for a lot longer.) Here are some possibilities:

  1. 方案.可能是所有方言中最干净的一种.毫无疑问,为什么将小计划者从LISP转换为Scheme.第五个Scheme标准规范 R5RS 本身就是一个很好的教育;它可能是我读过的最好的语言和库规范,也可能是最短的,相当全面的规范. PLT方案(现为Racket)平台包括相当不错的解释器和编译器,非常适合脚本编写,并且还具有一些视觉工具,使其非常适合学习.

  1. Scheme. Probably the cleanest of all dialects. This is no doubt why The Little Schemer was translated from LISP into Scheme. The fifth Scheme standard specification, R5RS, is a wonderful education in and of itself; it may be the nicest language and library specification I've ever read, as well as the shortest that's reasonably comprehensive. The PLT Scheme (now Racket) platform includes a fairly decent interpreter and compiler, is good for scripting, and also has some visual tools that make it excellent for learning.

Common Lisp.可能是最易移植,功能最全面的变体,如果您要编写诸如商业软件之类的东西,这很可能是您想要的.该标准定义了广泛的库,除此之外,还有更多可用的库,它具有 CLOS ,该库可能它比任何OO语言都能教给您更多有关OO的知识,并且其中一些编译器非常出色.缺点包括Scheme所没有的一些缺点(例如为引用函数的变量使用单独的命名空间),不够干净和简单(就像任何必须具有扩展名和做出必要折衷处理的事情一样)对于现实世界中的大型应用程序而言),没有卫生宏,并且对递归的重视程度远低于Scheme.

Common Lisp. Probably the most portable and comprehensive variant, this is most likely what you want if you want to be writing things such as commercial software. The standard defines extensive libraries, and many more are available beyond that, it has CLOS, which will probably teach you more about OO than any OO language could, and some of the compilers are very good. Disadvantages include some warts that Scheme doesn't have (such as having a separate namespace for variables that refer to functions), not being as clean and simple (as is the case with anything that has had to have the extensions and make the compromises necessary for large applications in the real world), not having hygienic macros, and emphasizing recursion much less than Scheme.

Clojure..该程序在JVM上运行,对于Java开发人员来说,这可能是一个不错的选择.有很多缺点(例如,您必须明确要求进行尾部调用优化,尽管如果将TCO添加到JVM可能会改变一天).宏虽然不卫生,但确实具有一些功能来帮助您避免变量捕获,因此,如果确实需要,则可以捕获变量,而与CL相比,意外捕获的风险要小.您可以轻松访问所有Java库.对于现实世界"代码而言,这可能是一件好事,而对于学习而言,这毫无意义.它具有一组用于持久数据结构和对STM的支持的库,从并发的角度来看,这非常有趣.如果您有兴趣了解更多有关并发和并行编程的新方法的知识,那么这可能是最好的选择.看起来Clojure像Java一样适用于大型生产应用程序,从某种意义上说,它将具有处理您宁愿不愿做和不愿意做的生产应用程序中丑陋的事情"的能力.在学习时.

Clojure. This runs on the JVM, which may give it a leg up right there for Java developers. It's got a few warts (e.g., you must explicitly ask for tail call optimization, though this may change one day if TCO is added to the JVM). The macros, while not hygienic, do have some features to help you avoid variable capture, so you can capture variables if you really want to, while running less risk of accidentally doing so than in CL. You've got easy access to all the Java libraries; that's probably a good thing for "real world" code, and fairly pointless in terms of learning. It's got a set of libraries for persistent data structures and support for STM, which make it very interesting from a concurrent point of view; this makes it probably your best bet if you're interested in learning more about new methods of dealing with concurrent and parallel programming. It appears as if Clojure is as usable for large, production applications as Java, in the sense that it's going to have the ability to do the "ugly stuff" you do in production apps that you'd rather not do and don't do when you're learning.

Emacs Lisp.就LISP而言,这不是最好的例子之一.其最大的缺点之一是动态范围界定,但还有许多其他缺点.但是,如果您是Emacs用户,则它可能是您可以学习的最强大的工具,可以改善对编辑器的使用.但是,除了学习如何扩展Emacs之外,您从学习Emacs Lisp中真正学到了多少东西,这对我来说是一个开放的问题;我不知道Emacs Lisp中真正使用有趣的技术(例如高阶函数)的频率.

Emacs Lisp. In terms of a LISP, this is not one of the better examples out there. One of its biggest faults is dynamic scoping, but there are many others. However, if you're an Emacs user, this may be the most powerful tool you can learn to improve your use of the editor. How much you'd really learn from learning Emacs Lisp, beyond how to extend Emacs, is for me an open question however; I don't know how often interesting techniques such as high-order functions are really used in Emacs Lisp.

2018更新

自从我写这篇文章以来已经快十年了,Lisp语言家族现在似乎在普通程序员的意识中获得了很大的吸引力.其中大部分似乎与Clojure有关,Clojure本身已成为Lisp的一种适当的独立方言,介绍了许多自己的好主意,但现在具有针对JavaScript的几乎完全相同的版本,并启发了许多其他Lisps针对其他平台.例如, Hy 以CPython AST和字节码为目标,首先旨在与Python进行互操作,但是在不确定时使用Clojure思想. " (尽管从最近的提交来看,后者可能有所变化.)

It's been almost a decade since I wrote this post and the Lisp family of languages now appears to be gaining significant traction in the general programmer consciousness. Much of this appears to be related to Clojure which has not only become a properly separate dialect of Lisp in its own right, introducing many of its own good ideas, but also now has a near-identical version targeting JavaScript and has inspired many other Lisps targeting other platforms. For example, Hy targets the CPython AST and bytecode, aiming first for interoperability with Python, but using Clojure ideas "when in doubt." (Though from the latest commits, the latter may be changing a bit.)

这会给您的决策过程带来很大的变化,那就是您还应该考虑使用与Lisps或类似Lisp的任何语言,以及它们是否可以与已经使用的语言或平台进行互操作,无论是 Ruby Erlang 开始,甚至微控制器上的C ++ .

The big change this brings in your decision-making process is that you should also be looking at whatever Lisps or Lisp-like languages are available for and interoperate with languages or platforms you already use, be it Perl, Ruby, Erlang, Go or even C++ on microcontrollers.

这篇关于我应该学习哪种Lisp方言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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