Slashdot Mirror


Perl Carbon/Cocoa Bindings on Mac OS X?

gigawattwarlock asks: "As an almost new Mac OS X user (I've been adminning my wife's Mac for a while now), I am used to writing Perl scripts for her Mac, which work just fine. Simply put, I have become spoiled with the GTk bindings for Perl on Linux. I love being able to use and abuse a robust GUI, quickly and easily. And to make matters worse, I find the Aqua interface near addictive ... enough so that the idea of installing another desktop environment (KDE, Gnome, et. al) just seems a little silly, and a bit of overkill, to me. Does anyone know if there are any perl bindings in the works for Mac OS X or maybe even an already existent alternative graphical library or interface within Mac OS X?"

5 of 57 comments (clear)

  1. camelbones by Fiery · · Score: 5, Informative

    Here's a project that's doing this. They seem to have functioning code, too.

  2. Just use Objective C by foobar104 · · Score: 5, Informative

    Yeah. There are several, in various stages of incompleteness.

    But why don't you just read the tutorial and learn to program Cocoa with Objective C? Programming Cocoa apps with Objective-C, using Project Builder and Interface Builder, is, I dare say, easier than writing Perl scripts that call Cocoa functions would be. You don't even need to be terribly familiar with C to write simple apps.

    Don't get me wrong. I love Perl as much as the next guy. But I don't like writing GUI code. It's a pain in the ass, no matter how nice the programming language might be. The combination of Interface Builder and Objective C makes whipping up little Cocoa apps easy as pie, and fun, too.

    You can find the Objective-C Cocoa tutorial in PDF form here. It's also included with the OS X developer's tools under /Developer/Documentation/Cocoa/ObjCTutorial.

  3. Ask Pudge! by 2nd+Post! · · Score: 5, Informative

    Have you looked here?

    Pudge has a site with lots of Mac+Perl info and projects, including a link to this, a tool to connect Perl to the Apple Event model.

    Of course this begs the question why you haven't already looked at AppleScript Studio and AppleScript, which allows you to script the OS and many of it's Apps?

    This snippet allows me to start my apps when I get into work:

    tell application "ICQ 3.0X"
    activate
    end tell
    tell application "AOL Instant Messenger (SM)"
    activate
    end tell
    tell application "Yahoo! Messenger"
    activate
    end tell
    tell application "Microsoft Outlook"
    activate
    end tell

    It's not particularly complex nor instructive, but AppleScript is full featured and extensive. I have a cronjob run an AppleScript in the mornings, where the AppleScript opens iTunes, opens a playlist, and then start playing, as my alarm clock!

    tell application "iTunes"
    play user playlist "Sweet-Sad"
    play
    end tell

  4. jaguar by Anonymous Coward · · Score: 4, Informative

    I wouldn't put too much work into your own solutions...

    Perl-Objc bindings are included in jaguar.

    See: Library/Perl/darwin/PerlObjCBridge.pm

  5. More Resources by pudge · · Score: 5, Informative

    I meant to respond earlier, but didn't get the chance. There are several ways to go about this. One is to the oft-mentioned CamelBones, which is in initial stages, but is a great start for Cocoa bindings. For Carbon, there is a vaporware project I've played with, a SWIG-based glue for Perl, Python, Tcl, Ruby, and maybe more, and more details of it will be forthcoming when it's ready.

    Right now there is also the Carbon-based MacOSX::File, which offers much of the same functionality as the Mac::Files module included in MacPerl, and there is OSXMacPerl, a basic clone of the MacPerl module (DoAppleScript and more are provided).

    And some day I would like to port the Mac:: modules to Carbon, if I get the tuits.