http://github.com/technomancy/leiningen/blob/94c675afe6767aa142bfc882298f0f828e476e24/README.md
-SS
On Feb 3, 4:50 pm, ajay gopalakrishnan <ajgop...@gmail.com> wrote:
> Hi,
>
> I was wondering if the time is right to replace Perl/Bash/Ruby/Python with
> Clojure for system administration / dev productivity scripts. I would not do
> things in Java (for obvious reasons), but clearly Clojure is more concise
> than Java in most cases.
> I would however want to know in detail if it is suitable for Sysadmin tasks
> like the following:
>
> 1. Count # words in a folder , Count # files of particular extension in a
> folder or search regular expression
> 2. Search for a particular regexp in a search path
> 3. Copy files from one folder to another
> 4. Walk through a directory structure
> 5. Fork another program and read it's results
>
> I've gone through this tutorialhttp://java.ociweb.com/mark/clojure/, but
Also relevant is the fact that launching Clojure from the command-line
is very inconvenient compared to scripting languages. If you want
something simple you can just put on your path, you'll need to wrap it
in a bash (or other language) script anyway to handle the classpath,
etc. The combination of startup time and the need to roll your own
bash script even for simple things has kept me from wanting to use
Clojure as a perlish-replacement.
-Phil
The classpath is a perpetual source of frustration. It drives me nuts
every time I have to restart swank to work on a different project with
a different classpath. It certainly means that something like a
Clojure shell would be unnaturally limited.
For example: "clj script.clj" or just "clj script" will run as script.
You may also pass args to the Clojure script like this "clj script
arg1 arg2". You may also pass arguments starting with "-X" through to
Java. I also have shorthands for other things like the arg -Xjmx is
converted to -Dcom.sun.management.jmxremote. Just typing clj at the
command line anywhere will start a REPL. I created this when I started
using Clojure to make it easier to work with and have been hacking on
it for a while. I add stuff all the time for my own convenience.
The basic idea is that you have a default classpath which is used when
you are not working within a project. If I execute clj within a
directory that contains a lib directory then it will put the jars in
lib on the classpath. If there is no lib directory then it will use
the default classpath. I explicitly set which jars are on the default
classpath but I think a better general purpose approach would be to
have a directory somewhere on your system that contains the default
jars. For example groovy has the .groovy/lib dir under ~ for this
purpose. This would allow you to easily add default jars without
modifying the clj script.
I also use a file named .cljrc.clj to configure the REPL. When the
script starts it will find the nearest parent dir that contains a file
named .cljrc.clj. When it finds this file it will run it and then
start the java process in that directory. I usually create a default
file in my root directory or ~ and one in each project. This file
usually contains an exit function to shutdown the REPL but you can
also configure the REPL here so that you don't have to do it each
time.
I created this before leiningen was available but I still use it and
the two work together very well. I also configure Emacs to use this as
my Clojure binary.
(setq swank-clojure-binary "clj")
What the others have said is still true. I only use Clojure for admin
stuff when the startup time is not a factor. But this clj script takes
away a lot of the pain of launching Clojure from the command line.
I hope this has more signal than noise.
Brenton
On Feb 4, 9:35 am, Phil Hagelberg <p...@hagelb.org> wrote:
> On Thu, Feb 4, 2010 at 8:33 AM, Stuart Sierra
>
Clojure also ignores lines starting with #!, so you can have a file
with the first line being:
#!/usr/bin/env clj
and with the rest being just normal Clojure s-expressions, and then
you can even run it directly instead of "clj script.clj". :)
--
Michael Wood <esio...@gmail.com>
On Feb 4, 9:35 am, Phil Hagelberg <p...@hagelb.org> wrote:
> On Thu, Feb 4, 2010 at 8:33 AM, Stuart Sierra
>
I whole-heartedly recommend newLISP for this:
Clojure is excellent when you need a powerhouse LISP capable of great feats, but newLISP is far better suited for scripting tasks, it was designed for that.
Or you can implement a *nix shell in Clojure. :-p
- Greg
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
On Feb 4, 9:35 am, Phil Hagelberg <p...@hagelb.org> wrote:
> On Thu, Feb 4, 2010 at 8:33 AM, Stuart Sierra
>
> <the.stuart.sie...@gmail.com> wrote:
> > Clojure can certainly do these things; clojure-contrib contains many
> > file and io-related utilities. But remember that Clojure, like any
> > Java program, takes more time to start up than "scripting" languages
> > like Perl/Bash/Ruby/Python, so it may be less suitable for programs
> > that you intend to run at the command-line.
>
> Also relevant is the fact that launching Clojure from the command-line
> is very inconvenient compared to scripting languages.
Does nailgun not solve that issue?
This has been the main reason I haven't completely abandoned
Python and ruby for such tasks. I think the original question
was phrased perfectly -- "wondering if the time is right". For
me, I'd say "not quite yet". I'm still holding out for
Clojure-in-clojure targeting a unix-embracing, fast-starting
host platform like golang or parrot.
--Chouser
http://joyofclojure.com
On Feb 5, 6:42 am, Tim Clemons <tclem...@gmail.com> wrote:
> Perhaps the solution is to have a *nix shell implemented in Clojure.
> That would limit the start-up issue to a single initial instance.
> Then the user can proceed to use regular command-line functionality
> interspersed with Clojure scripts. Think of it as a hybrid REPL.
Sincerely
Meikel
A much easier solution is to go with a lisp designed for exactly the task of scripting.
Woah! Seems like an understatement. This newLISP looks POWERFUL. Lot's of new stuff to read. Thank you, thank you.
Only about halfway; boot time issues are solved, but classpath issues
are not. In addition, you bring in a whole new "dirty VM" notion that
may or may not cause problems depending on how you use it. Plus you
have to decide how to start your new Clojure service--will it be for
the lifetime of the machine (in /etc/init.d) or just for the user's
login session? (in .profile then; but how to stop it?)
-Phil
On Feb 5, 6:02 pm, Phil Hagelberg <p...@hagelb.org> wrote:
I've been wondering about this. The classpath issue seems like a
major thorn in the side of the JVM, especially for Clojure and other
more scripty languages. Besides, it makes it a lot more annoying to
just pop open a file in Vim or Emacs and start editing. Is there not
some way we can figure out to get around this? Even if it's a bit of
a hack, if it works it would be incredibly helpful to have a lib in
contrib that could help get around restarting the JVM all the time.
It especially sucks when you've got some useful state in the REPL that
you have to trash in order to load a new jar file or add something new
to the structure of a project. Could we use something like remove-ns
to cleanup the namespaces, and then load updated files, maybe even
symlinked into temporary names that are always on the classpath, or
something like that?
The Parrot vm looks really great for Clojure----presumably Clojure
could have continuations and TCO there.
On Feb 5, 9:59 am, Chouser <chou...@gmail.com> wrote:
> On Thu, Feb 4, 2010 at 11:33 AM, Stuart Sierra
>
It would be super-fast, you could start from scratch and leave behind all of the issues associated with the JVM, no more complicated classpath, namespace, imports, etc. and the startup time would be very fast.
I only wish I had the time to work on such a project...
- Greg
Scripting languages also have very easy access to launch/use other
utilities.
What I did find clojure useful for back when I had time to look at it
(a year ago), was presentation of data. For example, I had one script
that scanned the maillog and made charts (Using Jfreechart) of sent/
received/rejected emails, another took patch data from all our servers
and gave a historical view of how many servers were patched/unpatched/
had missing data. This is things where there is no advantage to
scripting languages, and availability of java libraries is an
advantage.
--
-asbjxrn