[OT] My life after AS: shell commands, perl?
[OT] My life after AS: shell commands, perl?
- Subject: [OT] My life after AS: shell commands, perl?
- From: has <email@hidden>
- Date: Fri, 2 Dec 2005 17:41:25 +0000
Serge Belleudy-d'Espinose wrote:
>I'm familiar with AS but now I'm building a personal shoutcast stream and learning everything at once, starting with shell scripts. My needs are mostly simple text manipulations and launching commands depending on the environment. My concern is to choose the right tools, which doesn't have to be the best or the easiest.
>
>The lazy way: the simplest shell scripts, and tap into AS with osascript;
>The normal way: learn shell as much as possible (started here, http://www.osxfaq.com/Tutorials/) and try to manipulate texts with sed/awk, although I get the strong feeling that in some cases a single AS line would do 10 shell commands;
For any kind of application development work, I'd recommend bypassing the old-school shell languages and go for a modern general-purpose scripting language such as Perl, Python or Ruby. (There's also Tcl, but it's not as popular these days.) They're much more powerful, flexible and scalable. Stick to shell scripts for system administration work and stuff like that.
Ruby's the youngest of the three and still lacks in some areas such as Unicode support, so unless you're doing web-application development in particular (its Ruby on Rails framework is currently proving very popular; though Perl and Python are also excellent for this type of work) then you're probably better going with one of the others.
Perl is the classic hacker's language, a vast, baroque, powerful sprawl of a language that draws much of its inspiration from older shell languages. Puts a lot of features directly beneath the fingertips, which makes it very convenient to use but does require a fair amount of learning and practice to master. Often regarded as the world's premiere "write-only" language - super for whipping quick-n-dirty shell-style scripts, requires discipline in larger projects to avoid total chaos. Backed up by the massive CPAN repository, a terrific source of reusable libraries and code. Provides pretty good direct application scripting support via Mac::Glue, while Mac::AppleScript provides a convenient way to run existing AppleScript code. Minimal OSA language component available (c/o Philip Aker). Two Cocoa bridges to choose from - PerlObjC and CamelBones - if you're doing GUI application development.
Python is a more traditional language with a smaller, tighter, well-balanced set of built-in features and a good, if not always perfect, standard library. May not reach the manic highs of Perl, but doesn't hit its manic lows either. Nice clean readable syntax (some folks like to whine about the indentation thing, but it's basically a non-issue). Quick to pick up, though the object system does get a bit complex if you need to go beyond the basics there (still preferable to Perl 5's OOP support). Third-party library support is very good, if not quite at CPAN's level; see PyPI (aka Cheeseshop) and Vaults of Parnassus. Excellent application scripting support via appscript[1] and a complete if still somewhat low-level OSA API wrapper for calling existing AppleScripts (a high-level wrapper is on its way). Also a brilliant Cocoa bridge, PyObjC.
FWIW, I quite enjoy dinking around in Perl once in a blue moon (admittedly with a copy of Learning Perl permanently open beside me:p) - it is a fun language to use, if a pain to learn. For any real work though I always go with Python; took me about a week to get comfortable in coming from AppleScript (much less of a shock to the system than going to Perl) and I've found it more than capable for my needs.
>The learning way: forget AS and learn a more universal language. I was told that for my needs perl is the way to go. If so, are there good resources for learning perl (I suppose so) especially when working on os x?
There's tons online and dead-tree documentation, tutorials, etc. available for all of the above languages. (Hint: Google is your friend.:) e.g. For Python, you could go with the official introduction on www.python.org, or zoom through something like <http://www.ibiblio.org/obp/thinkCSpy/>. I'm certain you'll find similar introductions for Perl no problem - although they may be a bit longer, of course.;)
HTH
has
[1] I should know - I wrote it<g>. Ask if you want to know more.
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden