• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [OT] My life after AS: shell commands, perl?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OT] My life after AS: shell commands, perl?


  • Subject: Re: [OT] My life after AS: shell commands, perl?
  • From: Kevin Walzer <email@hidden>
  • Date: Fri, 02 Dec 2005 13:45:04 -0500
  • Organization: WordTech Software

has wrote:
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.


I'd like to add a quick word for Tcl. :-)

Tcl is of the same generation as Perl and Python, making its debut in 1988. While its general capabilities make it a peer to the other languages, let me elaborate on some of the differences:

1. Tcl is designed to be very compact. Its core library is much smaller than either Perl or Python, with more functionality added via extension packages. This makes Tcl very easy to learn.

2. Excellent resources for GUI programming. Tcl's Tk GUI tookit extension is tightly integrated with Tcl and makes it very easy to develop quick and simple interfaces. By contrast, Python and Perl lack native resources for GUI development and instead wrap a variety of different GUI toolkits (including Tk, wxWidgets, and Cocoa)--this can substantially increase the learning curve. Tk has gotten a (not entirely undeserved) bad rap in recent years for being ugly and outdated, but substantial work has been done on theming, data display, and so on, and now Tk is a first-rate environment.

3. Excellent support on the Mac. Tcl/Tk is now included on Tiger, with a lot of Apple-specific extensions that developers have created over the years. A more up-to-date distribution can be found at http://tcltkaqua.sourceforge.net.

4. Very nice integration with AppleScript. With the Tclapplescript extension, you can run AppleScripts from Tcl like this:

package require Tclapplescript


AppleScript execute "

set thePath to (choose file with prompt \"Choose the location of the DarwinPorts port command.\" with invisibles)
set theFinalPath to POSIX path of thePath


"

5. A nice, supportive user community. comp.lang.tcl and the wiki at http://wiki.tcl.tk are excellent resources.

--
Cheers,

Kevin Walzer, PhD
WordTech Software - "Tame the Terminal"
http://www.wordtech-software.com
sw at wordtech-software.com
_______________________________________________
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


  • Follow-Ups:
    • Re: [OT] My life after AS: shell commands, perl?
      • From: "Mark J. Reed" <email@hidden>
References: 
 >[OT] My life after AS: shell commands, perl? (From: has <email@hidden>)

  • Prev by Date: Excel 2004 - How to set fill color of cells?
  • Next by Date: Re: Shell script timing, regex
  • Previous by thread: Re: Excel 2004 - How to set fill color of cells?
  • Next by thread: Re: [OT] My life after AS: shell commands, perl?
  • Index(es):
    • Date
    • Thread