从 Lisp 学习 Clojure

发布于 2024-10-13 06:51:49 字数 1539 浏览 9 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时间你老了 2024-10-20 06:51:49

在 Blip.tv 上观看尽可能多的 Clojure 视频 不会出错你可以处理的,尤其是 Rich Hickey 本人的作品。这些确实有助于理解 Clojure 独特的概念点和方面。

如果您足够熟悉 Lisp 概念,您可能希望首先重点学习 Clojure 如何“映射”到您使用过的 Lisp。观看 Rich Hickey 在 “面向 Lisp 程序员的 Clojure” 上的视频。

您确实需要有一些熟悉 Java,因为 Clojure 并不回避使用它。在聪明的地方使用 Java 并不是不符合 Clojurey(据我所知)。我至少会浏览一下 java 的 API 文档 .langjava.io 包,因为 java.lang 在 Clojure 程序中自动可用,并且使用了 java.io频繁地。

有了我的 Clojure-to-Lisp 字典和我的 Java 基础知识,我会选择一个小项目来工作。将 Clojure 和 Clojure-contrib API 文档放在手边(无论是在网络上还是使用 REPL 中的 (doc) 命令),并仔细阅读大量的 Clojure 博客。我最喜欢的两个是 http://nakkaya.com/http://stuartsierra.com/。如果您使用 Diigo,大量博客已被添加到 clojure 组 中。

注意:不要纠结于你的开发环境。 入门 wiki 页面上列出了许多选项。为了学习 Clojure 和您的第一个小项目,我只需选择您选择的纯文本编辑器,学习和使用 的基础知识Leiningen 获得一个良好的项目目录设置,并处理所有路径和依赖项,然后使用命令“lein repl”启动 REPL,并加载所有依赖项并可用。假设您使用 Emacs(基于您之前的 Lisp 经验),您可以将您的 inferior-lisp-program describe-variable 描述为 lein repl ,然后只需从示例项目的根目录启动 Emacs,一切就可以自动运行。

您可以阅读书籍,特别是《The Joy of Clojure》、《Programming Clojure》和《Practical Clojure》。后两者比第一个更“实用”,第一个更“哲学”(请原谅粗略的概括)。实用 Clojure 是最新的 Clojure 1.2,而编程 Clojure 则稍旧一些。

最后,进入 #clojure IRC 频道并使用 Clojure Google 群组,因为那里有一群聪明、友好、乐于帮助他人的人。

You can't go wrong watching as many of the Clojure videos on Blip.tv as you can handle, especially those by Rich Hickey himself. These really help drive home the conceptual points and aspects unique to Clojure.

If you are sufficiently familiar with Lisp concepts, you may want to initially focus on learning how Clojure "maps" to the Lisps you've played with. Watch the videos by Rich Hickey on "Clojure for Lisp Programmers."

You do need to have some familiarity with Java, because Clojure doesn't shy away from using it. It's not somehow un-Clojurey (as far as I can tell) to use Java where it's smart. I'd at least skim through the API docs for the java.lang and java.io packages, because java.lang is automatically available within your Clojure programs and java.io is used frequently.

With my Clojure-to-Lisp dictionary in my head and my Java basics behind me, I'd pick a small project to work on. Keep the Clojure and Clojure-contrib API docs handy (either on the web or use the (doc) command from the REPL), and peruse the many, many Clojure blogs out there. Two of my favorites are http://nakkaya.com/ and http://stuartsierra.com/. If you use Diigo, a whole slew of blogs have been bookmarked to the clojure group.

NOTE: don't get hung up on your dev environment. There are a multitude of options listed on the Getting Started wiki page. For learning Clojure and your first small projects, I'd just pick your plain text editor of choice, learn and use the basics of Leiningen to get a nice project directory setup with all your paths and dependencies taken care of, then use the command "lein repl" to startup a REPL with all of your dependencies loaded and available. In assuming you use Emacs (based on your previous Lisp experience), you can describe-variable your inferior-lisp-program to be lein repl, and just start Emacs from the root of your example project for everything to work automagically.

There are books you can read, notably The Joy of Clojure, Programming Clojure and Practical Clojure. The latter two are more "practical" than the first, which is more "philosophical" (excuse the gross generalizations). Practical Clojure is up-to-date with Clojure 1.2, whereas Programming Clojure is a little bit older.

Finally, get on the #clojure IRC channel and use the Clojure Google group, because there's a bunch of smart, friendly folk who enjoy helping others.

笛声青案梦长安 2024-10-20 06:51:49

只是从另一个方向(Java -> Clojure)来到 Clojure 的人的快速视角,

  • 我实际上发现一旦我掌握了语法和常见习惯用法,Clojure 的 Lispy 部分就很容易学习。我希望这对您来说会更容易。
  • 您实际上并不需要太多的 Java 知识来完成大多数事情 - 如果您愿意,您可以用纯 Clojure 完成几乎所有事情。
  • 可能只有当您开始想要使用 Java 库时,您才需要深入研究 Java 互操作。幸运的是,互操作非常简单 - 它更像是 LISP 风格而不是 Java 风格,因此您唯一需要弄清楚的是如何理解 Java 接口并从 Clojure 端进行适当的调用。

对于我的环境,我使用 Eclipse + 逆时针。如果您喜欢 IDE 和/或认为您最终可能也想在 Java 中完成一些工作,那么这种方法非常有效。它不需要进一步的依赖项,为您提供了一个出色的调试器,具有完整的 REPL(嵌入式 nREPL 我相信),负责所有项目文件管理(Git、SVN 等)并自动处理诸如 Java 类路径设置之类的事情(这对于 Java 新手来说可能是一个主要障碍!)。如果您认为这可能适合您的风格,我建议您查看一下,我也听说过有关 Enclojure 也是如此。

如果您不喜欢 IDE,那么您可能最好使用您最喜欢的文本编辑器和命令行工具,正如 semperos 在他的出色答案中所建议的那样。

Just a quick perspective from someone who came to Clojure from the other direction (Java -> Clojure)

  • I actually found the Lispy parts of Clojure easy to learn once I got my around the syntax and common idioms. I expect that will be even easier for you.
  • You don't really need much knowledge of Java to do most things - you can do pretty much everything in pure Clojure if you want to.
  • It's probably only when you start wanting to use Java libraries that you will need to dive into Java interop. Fortunately, the interop is very simple - it's more LISP-style than Java style, so the only thing you will need to figure out is how to understand Java interfaces and make the appropriate call from the Clojure side.

For my environment, I use Eclipse + Counterclockwise. This works exceptionally well if you like IDEs and/or think you may ultimately want to do some work in Java as well. It requires no further dependencies, gives you an excellent debugger, has a full REPL (an embedded nREPL I believe), does all the project file management (Git, SVN etc.) and automatically handles things like the Java classpath setup for you (which can be a major obstacle for newcomers to Java!). I'd recommend checking it out if you think that might suit your style, I've also heard good things about Enclojure as well.

If you're not into IDEs, then you're probably best with your favourite text editor and command line tools as semperos suggests in his excellent answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文