views:

128

answers:

9

I am currently working on a large project and will relatively soon need a scripting language for utility scripts, like deploying the project in full from source, checking and fixing the database, building a ready to deploy bundle, and so on. The project is written in PHP and I thought about using it, but I dismissed that as not suitable for the task.

What I would mainly require would be, ordered by improtance:

  1. Portable across the top three OSs: Windows, Linux and OS X
  2. Lots of good libraries available, raging from file and directory manipulation to database access. GUI is not needed, though networking might be (download some stuff via FTP or HTTP). A big plus would be ability to natively checkout a Subversion repository.
  3. Good community support is required. Both Python and Ruby are excellent in this area.
  4. Extendability: if there is no good library available to do something, how easy is it for me to implement one or to use a native solution (execute a program, call a native function).
  5. Ease of deployment: how easy is it to get up and running on Windows (XP & 7, Server 2003+), Linux (CentOS 5.2, Ubuntu & Ubuntu Server 8.04+) and OS X (10.5+).
  6. Easiness of learning. While all scripting languages are not hard to learn for any programmer worth his salt, I'm interested in one that's rather quick and easy to learn.

That's all I can think of for now. I have reviewed Python and Ruby; Python satisfies all the requirements, and Ruby seems to as well, though I am not sure about ease of deployment on Windows and the availability of libraries. However, I am also looking for your experiences with using this sort of scripts written in the language of your choice.

+1  A: 

http://ant.apache.org/

I use it for both Java and PHP projects. And to answer to your points:

  • portability: 100%
  • libraries for db, networking, i/o, svn: yes, some are built in, for the rest you use extensions
  • community: many books and online resources
  • extendability: yes, ant was designed to be extensible
  • installation: dead easy
  • easiness of learning: pretty easy
cherouvim
Thanks, looks interesting, I'll look it up.
iconiK
Ant looks more like a build tool than a general scripting language. I'm not very fond of Java either. I'd especially prefer if I were not forced to use OOP.
iconiK
Ant would be my choice too. I haven't used it extensively, but it definitely fits your requirements.
Checksum
Yes, ant is not a programming language but primarily a build tool.
cherouvim
That only satisfies one requirment, and PHP doesn't need much of a build tool per se.
iconiK
It needs a build tool if you want to merge source files (in product line engineering scenarios), run unit and integration tests, compress css and js files, touch deployment descriptors, pack into an archive and send to a remote server via ssh key. I used to do all that by hand but nowadays I prefer typing "ant foobar".
cherouvim
That's a good reasoning. I will use Ant for building and deploying the application.
iconiK
+1  A: 

Python is a great scripting language and very portable. It's my choice when portability of my scripts is the main issue.

But portability is seldom my main issue. Most of my scripts deal rather intimately with OS issues. So when I know I'm running on Windows and may not have python available, I use JScript under Windows Script Host.

John Knoeller
The problem with JavaScript is the inability to easily use external libraries. The way you access a file on Windows is completely different than how you would do it on Unix, so it's inadequate for the task at hand.
Gabe
Python is top on my list right now, but I also asked about how the language does at this specific task. I don't need to do much OS-specific stuff with the scripts.
iconiK
@iconK: sorry I wasn't clear. For your tasks and priorities, I'd go with python. good support on lots of platforms, and pretty good/rich libraries.
John Knoeller
WSH is available on all Windows platforms and has good libraries for system admin tasks and can use COM objects
John Knoeller
@John, yes, but I will need to run the script on Linux servers too. Windows is too expensive right now at cloud hosts.
iconiK
+9  A: 

You said it: Python meets all the requirements. That's my "vote" though I may be somewhat biased.

Edit: (on my first hand experience, in the context of tasks described in question)

  • I have no experience with building releases from Python (I find Ant or even Make a better tool for this particular task).
  • "Messing" with databases : a breeze !
  • Moving files around, inspecting directories etc. : a breeze!

A the risk of seeming either cocky or inexperienced, with regards to scripting-type activities, I've never painted myself in corner that Python didn't allow me to get out of.

A possible "critique" of Python however is, somewhat paradoxically, its extensive package library (in addition to its generous standard library); while it's nice to have all theses "3rd party" libraries, it can be sometimes difficult to gage the maturity, and effectiveness of some of these packages, and one sometimes wastes some time selecting these (or deciding whether to write "from scratch"). Yet, such evaluations can be fast enough however, thanks to the interactive nature of the interpreter.

mjv
So does Ruby, albeit at a lesser level. But: "However, I am also looking for your experiences with using this sort of scripts written in the language of your choice."
iconiK
I think that Python is a better all-rounder than Ruby, which seems more focussed on web dev.
Lenni
+1 for the paradox of being overwhelmed by libraries of varying quality. Not enough attention is paid...
Norman Ramsey
A: 

I use both Perl and Python extensively for scripting on Windows, so I wouldn't hesitate to use either for deployment. I would choose Python for its smoother learning curve.

Gabe
+1  A: 

Ruby is decent, but python is excellent. Python comes with great documentation, is easy to learn, has a large community, sports a very useful standard library, will be pre-installed on most unix-like systems, and is not too painful to install on Windows.

alberge
Not too painful == Run the installer and double-click on a file to run? Seems easier than on Linux.
iconiK
A: 

Perl, except maybe for the learning curve. Portability is not a problem, for libraries there is CPAN, the community is perfect, calling external programs is not problem and you can always wrap a C library and installation is a no-brainer.

zoul
+1  A: 

Python, without a doubt. It meets all of your objectives and has the benefits of being concise and easy to learn.

Miles D
A: 

Python is really great for this kind of thing. I just wanted to draw your attention to Tcl which is absolutely awesome for general purpose scripting and file handling. Wikipedia entry about Tcl

Faisal
+1  A: 

iconiK,

This answer is only peripherally related to your question, but you're gathering more information than you need to solve this problem. Your analysis and preliminary research are pretty impressive, and the cost of postponing your decision is higher than the marginal value of Python over Ruby or vice versa.

I am also looking for your experiences

My experience is that there's a limit to the amount you can learn about a technology through research, and my gut tells me you've already reached that limit. You'll be better off if you stop researching and get on with your project. If you can do a small pilot project, that will be great, but if not, you are at the point where you will learn more by just diving in than you can possibly learn by asking questions.

Probably my most recent salient experience is that in 1999 I had to decide whether a major compiler project would be written in Objective Caml or Haskell. We choose Caml, and there have been many times I wished I had chosen Haskell, but in fact in 1999 Caml was probably the better choice, and certainly we did a lot of good work with that compiler. The worst choice of all would have been to wait to gather more information.

I think the other lesson here is that because no technology is perfect, whatever technology you choose, you will have regrets. Just because you have regrets does not mean you made the "wrong" choice.

Code in good health!

Norman Ramsey
I do have plenty of time however. Until the project itself is half-finished I can look for the perfect scripting language. Anyway I have chosen Python and am reading Dive into Python 3.
iconiK