Good Clojure Code Examples?
I'm in the process of checking out Clojure for the first time. I've found it useful looking at the (doc xxx) and (source xxx) of the Clojure core library, but I'm more concerned with how you would organise and put together a full application.
Are there any excellent, open source examples of this?
For example, to learn how to code well in Java I might look at the Spring source-code, or something similar.
Prominent open source Clojure projects:
A few blog posts explaining bite-sized Clojure applications:
http://corfield.org/blog/archives.cfm/category/clojure
This guy is doing a blog which among other things, has an article series on "real world clojure examples". I think this is one of the best places for this sort of thing, because the articles don't simply provide source files for you to read, he often taken on specific practical problems, describes them first, the rationale behind choosing clojure, and rationale behind choosing a specific way of doing things in each article. (And then some code excerpts as well.) This gives much more eclectic view on the examples themselves, and better understanding of not only What and How, but Why.
(You may want to scroll down a bit in the archives, he has a lot of clojure articles which are good themselves, but this post is especially true about the mentioned "real world clojure" series, which begin with articles like http://corfield.org/blog/post.cfm/real-world-clojure-email-status-tracking)
I find that looking at the project.clj for most of these projects is a good first step in getting a good idea of the core libraries these projects are relying on. Mostly if one of the more popular and heavily used open source libraries, like Compojure for example, are using certain base libraries, like Ring in the case of Compojure, I can then focus on how those base libraries are being leveraged. This is how I got a good idea of how Ring middleware works and that helped me understand Noir worked and allowed me to also understand how one could substitute something like Grizzly for Jetty or how to implement something like OAuth 2 using just middleware.
链接地址: http://www.djcxy.com/p/33618.html上一篇: Clojure静态打字
下一篇: 好的Clojure代码示例?