Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Where does Perl fit into OS X?

by Acolyte (Hermit)
on Aug 12, 2005 at 22:18 UTC ( [id://483436]=perlquestion: print w/replies, xml ) Need Help??

Acolyte has asked for the wisdom of the Perl Monks concerning the following question:

As a Perl user in a fully MS shop it has been my recent pleasure to finally have picked up an *nix box in the form of a new Apple PowerBook. I've since been poking around the innards of the OS and haunting the ADC site to try to get a handle on the motley collection of tools and dev languages that are hiding underneath that pretty hood. All my poking around has raised a few questions for any seasoned OS X developers out there:

  • What are the advantages to using Perl over AppleScript or vice versa?
  • Where does Perl fit into the OS X application programming framework?
  • Do the Carbon API's or Cocoa framework take the place of some of the "glue" functions that Perl would have been used for when developing with C, C++ or Java?

I'm just trying to get an idea of what the best path is to learn *nix on OS X and the best use of Perl in that environment.

Cheers!

Acolyte
Studying at the feet of the masters

Replies are listed 'Best First'.
Re: Where does Perl fit into OS X?
by borisz (Canon) on Aug 12, 2005 at 22:39 UTC
      Excellent resource, Boris. Thanks for the link!
      Acolyte
      Studying at the feet of the masters
Re: Where does Perl fit into OS X?
by graff (Chancellor) on Aug 12, 2005 at 23:59 UTC
    Given the BSD foundation, I just treat my powerbook as a unix system (which it is). I installed the X-windows development kit so I could use Tk, I use CPAN to install modules whenever I feel like it (though as suggested above, sometimes this takes a little extra effort), I edit my perl scripts with emacs, I NFS-mount the terabyte server volumes when I'm at the office, and while I use xterm a lot for day-to-day command-line stuff, I'm really loving the quartz-native "Terminal" with its nifty transparency feature and full unicode support (including bidirectional display for handling right-to-left text data -- amazing stuff).

    I avoid anything that's Apple-centric, because for most of the perl stuff I do, I'd like it to work equally well on any other unix box (or even M$-windows, if absolutely necessary).

Re: Where does Perl fit into OS X?
by halley (Prior) on Aug 12, 2005 at 22:27 UTC
    The only downsides I've found are:

    (1) it's more of a pain to try out modules that may or may not be PowerPC friendly, since so much code out there is developed on x86 architecture. CPAN works but doesn't manage package installations and dependencies like Fink would, and Fink rarely lists the perl package you want.

    (2) you can't use generic shebang scripts as Speakable Items and probably some other carryovers from pre-OSX days. You have to wrap each one with a little AppleScript stub instead. There are easy programs to make those stubs, like Platypus.

    I haven't tried Gtk2::* packages on OSX though. If someone else lets me know how that works out, I'd like to know.

    --
    [ e d @ h a l l e y . c c ]

Re: Where does Perl fit into OS X?
by friedo (Prior) on Aug 12, 2005 at 22:44 UTC
Re: Where does Perl fit into OS X?
by sh1tn (Priest) on Aug 12, 2005 at 22:48 UTC
    What's more important from my point of view -
    how does OS X fits into Perl? The OS is just tool.
    The language is not just tool.


Re: Where does Perl fit into OS X?
by jhourcle (Prior) on Aug 15, 2005 at 12:22 UTC

    I don't think anyone has yet answered your first question --

    What are the advantages to using Perl over AppleScript or vice versa?

    AppleScript has the advantage that it's a little bit easier to learn for some folks, particularly non-programmers who view it as being more english-like. The advantage to programmers is that many programs have exposed an AppleScript API, so that people can write macros. AppleScript can also 'record' actions, making it even more like a macro writing language.

    You can also be more assured that if the person's using a Mac, they'll have AppleScript -- even if it's pre-MacOS X.

    What are the advantages of Perl? Well, I'm guessing in your case, you're more familiar with Perl, and if you're been using it for any sort of time, it's much more productive to work in a language you're familiar with, than to have to keep referring back to language documentation, and debug it.

    But, Perl can't interfact with the applications -- for instance, to keep this on topic -- in BBEdit, it'll mark perl functions, so that you can quickly jump down to them. It doesn't, however, mark when you change packages within the same file, so the function scanner isn't useful when you're reading through SOAP::Lite or things written in a similar style. I use an AppleScript to set marks at the 'package' and 'sub' declarations (but it's on my machine at work, so I'll have to post it from there)

    Update: Almost forgot to mention -- there are Applescript modules in CPAN, to call AppleScript from Perl

    Update 2: AppleScript to mark Perl namespaces in BBEdit

      AppleScript has the advantage that it's a little bit easier to learn for some folks, particularly non-programmers who view it as being more english-like.

      The fact that it looks more like English causes more problems than it solves in my experience. Newbie's, hell experienced programmers too, find it harder to separate out the meat from the syntactic fluff.

        Perhaps 'easier to learn' isn't the right term ... 'less scary' would probably be more acurate -- there are a large number of people who are turned off when they see languages that rely heavily on punctuation and other symbol characters to do their work, just because they're not used to seeing it in their every day use. They see it, and are immediately turned off, which make it impossible to convince them that it's worth learning.

        You're right in that mistaking it for English can cause no end of headaches for people who don't understand the concepts of a 'Structured English' language, where you don't have as much freedom as with a true natural language. I wouldn't suggest that you try to write AppleScript without using Apple's 'Script Editor' which will quickly highlight some problems. Typically, I don't write Applescript from scratch--I use it to record my tasks, then go back and modify the script recorded to make it more generic.

        Those times that I've written AppleScript without recording, I've made heavy use of the Dictionaries feature in Script Editor.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://483436]
Approved by bassplayer
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found