开发者_StackOverflow中文版
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this questionI have started learning Clojure recently, my main programming language is Ruby and I have no Java experience whatsoever.
Which Java standard classes are a must to know when working with Clojure?
Obviously Clojure doesn't come with a wrapper for everything and a lot of functionality is provided by Java's libraries.
There's like a gazillion of them on javadocs - which ones should I explore?
Where do I look for and how do I install third party libraries (clojure and java ones)?
In Ruby I'd visit Rubyforge or Rubytoolbox, git etc. and then just gem install the package I found interesting.
Which editor/ide for Clojure would you recommend (with the lowest learning curve)?
I am trying to use Netbeans with Enclojure and paradoxally it's my biggest obstacle so far:
Each generated project has some xml files, folders, library dependencies etc. the purpose of I have no clue.
I am doing some labrepl exercises and wanted to try out some of the bundled libraries separately in a new project, but this simple task I cannot accomplish :/
How to distribute clojure programs?
This is pretty much related with the question above.
Are there any clojure community driven blogs with news, code tips etc?
Explore the javadocs only as needed when you can't figure out how to do something using Clojure's core API or the Clojure contrib libraries.
For 3rd party libraries, there is Clojars. I'm not sure how widely it has been adopted by the community, but it's a good place to start. Many Clojure projects are hosted on github, so you can try searching for clojure there.
If you already know Emacs, there is good support for editing Clojure in Emacs. If you don't know Emacs, don't try to learn Emacs and Clojure at the same time. Check out the getting started page on the Clojure wiki for infomation on getting going with a number of different IDE's. Unfortunately, the wiki link on the Clojure homepage is wrong.
Finally, check out Planet Clojure for lots of good blog posts about using Clojure for a wide variety of different things, including helpful posts on getting started.
Which Java standard classes are a must to know when working with Clojure??
None. You can get by with googleing and asking questions on the Clojure IRC channel here. You'll learn what you need over time. You can investigate java.lang and java.io classes, but you wont need them until you need them.
Where do I look for and how do I install third party libraries?
Leiningen is an extremely simple maven-wrapper-kinda-thingy. You can use it for dependency management and as a build tool for your code, http://github.com/technomancy/leiningen, and there is http://clojars.org/ where lot's of Clojure libraries are placed in a maven repo that can be accessed by Leiningen and Maven. http://www.assembla.com/wiki/show/clojure/Getting_Started
Which editor/ide for Clojure would you recommend (with the lowest learning curve)?
That would probably be Enclojure, or Counterclockwise. Most Clojure users use Emacs or to a lesser extent, Vim. Emacs is the best editor around for Lisp, but has a bit of a learning curve to get friendly with. If you aren't willing to learn a language and an editor, you might want to head in the Enclojure/Eclipse(counterclockwise) direction.
Are there any clojure community driven blogs with news, code tips etc?
http://planet.clojure.in/ and the Google group.
How to distribute clojure programs?
Easiest way is with Leiningen and the jar and uberjar commands. You can write your code, and then you can put that code in a .jar file and write a start-up script for it. You don't even have to put it in a jar if you don't want to. Jars are really only useful if you actually compile your code, and most Clojure code isn't compiled. Certain features require compliation, but they aren't used that much.
All in all, the Clojure IRC channel is very helpful and newbie friendly. It can be difficult entering JVM-world without prior experience. Don't be afraid to stop in and ask questions. We're here to help.
Which Java standard classes are a must to know when working with Clojure?
It's not so much java language that you have to know about for Clojure, though it helps. The most important knowledge is how to compile, how to set the classpath, and so forth. I've programmed in java a bit, and I still find this tripping me up at times.
- Setting the classpath
It might also be useful to go through one or two beginner tutorials on java, but don't spend much time on this at all.
- Here's one with a hideous color scheme, per Oracle's design standards
Where do I look for and how do I install third party libraries (clojure and java ones)?
You can use leiningen to manage dependencies per project automagically. (I've edited this portion of my answer. Upon further evaluation, Leiningen is the way to go in almost all cases.)
Which editor/ide for Clojure would you recommend (with the lowest learning curve)?
I've learned to love emacs. The major java IDEs all have their own clojure flavour available (in decreasing order of maturity):
- Netbeans -- enclojure
- IntelliJ -- la clojure
- Eclipse -- counterclockwise
If you have any inclination to learn emacs, though, this might just be the time. This tutorial is ridiculously comprehensive.
How to distribute clojure programs?
In jars.
Are there any clojure community driven blogs with news, code tips etc?
The google group and planet clojure.
(EDIT: added blanket recommendation of Leiningen.)
There will be a free month-long Clojure course on RubyLearning starting next week that could be interesting for you:
http://rubylearning.com/blog/2010/03/09/clojure-101-a-new-course/
Which Java standard classes are a must to know when working with Clojure??
Clojure is a radical change from Java. I suggest you concentrate only on one of them (clojure) and and not both. There is plenty to learn anyway. Use a basic editor, and use the REPL as much as you can. A good intro for clojure is in here and here
Where do I look for and how do I install third party libraries?
Clojure contrib is a good place to start http://github.com/richhickey/clojure-contrib Another one is leninmgen -http://zef.me/2470/building-clojure-projects-with-leiningen
Which editor/ide for Clojure would you recommend (with the lowest learning curve)?
Just use notepad++ or vim. It should be more than enough for you. I personally use kate under ubuntu because it gives you lisp code formatting. The hard core users probably use emacs (which I really hate)
Are there any clojure community driven blogs with news, code tips etc?
The Clojure google group is friendly and very knowledgeable
- for blogs you need to look to Planet Clojure
- for Java - you need at least know java.lang & java.io
- for IDEs description it's better to look to Getting Started page
- for using 3rd party libraries you can use Leiningen or Maven build tools - they both provide automatic resolve of dependencies. Getting Started page contains all necessary information
- distibution of Clojure programs usually implemented as providing jar with source (or compiled) code. You can bundle only your code with 'lein jar' or provide complete solution with all dependencies with 'lein uberjar' commands
Best First Clojure IDE: Nightcode
To concentrate on Clojure until you beat the learning curve on IDEs and tooling: get Nightcode It was initially made to get beginner classes going without blowing half the time on emacs, but it just keeps getting more useful. Basically it puts the features to get you up and running in a simple package.
It has a general Clojure REPL in a corner of the window, and a second REPL you spin up, under the editor area, which will have access to the functions you've written so far. A quick keystroke runs the line you've just written down in the REPL. For clojure-optimized editing, you have a button for turning on/off paredit (actively managed parentheses with keystrokes to wrap/unwrap/etc).
It can deploy a set of ready-to-go templates to start your project in a ready-to-code state. There's a one-click button for creating a jar (Single file Java executable). It has GIT integration to pull from and push to github without requiring GIT installation on the machine.
I'm sure the JDK (java development kit) is necessary for making the jar properly; but I've been able to just download Nightcode to any computer with a recent Java runtime and work away (It's a Java jar, with no installation necessary).
You'll use Leinengen and learn more editors; but to start actually programming without the soul-sucking start-up confusion, Nightcode is an awesome tool.
I agree with almost all of the other advice about things that I know about. Here are two further points that no one has made yet:
Beginners should learn standard Clojure conventions about how to use namespaces with appropriate filenames and directory names, and follow these conventions religiously. (Maybe Nightcode lets you avoid this--I don't know--but once you start using Leiningen, you can't avoid it.) If you don't, namespace problems will quickly drive you crazy as soon as you get beyond trivial experimentation. Colin Jones' tutorial on namespaces is the best starting point that I found when I was starting out. Some of the conventions actually come from Java, btw, but you don't need to learn any Java for their sake.
You may not need third-party libraries at all at first. Depends on what you want to do. The standard Clojure libraries cover a lot of ground.
精彩评论