Prov.JS Meetup Recap – JavaScript Patterns in Objective C

   Community and Events

Last Thursday night, Andrew Goodale gave an excellent presentation at ProvJS that highlighted some of the similarities between JavaScript and Objective-C. It turns out there are quite a few things we use in JavaScript that can be applied here, especially when it comes to basics of getting things done.

For example:

  • Delegates, Events
  • JSON
  • Function Patterns
  • Closures
  • Loose Typing
  • Dynamic invocation – obj_msgSend() vs. Function.apply()
  • Objects – Key/Value coding vs. Hash table

These can all be taken advantage of in Objective-C. There are certainly some nuances here but it’s nice to see some familiar techniques when diving into a new language. There were some negatives mentioned such as memory management, “wordy” method/property names and funky syntax. Avoiding memory leaks was possibly the only serious fault I heard. I think the wordiness and funky syntax would be pretty easy to get used to. In fact, take a look at this:


    { NSFileManager *mgr = [NSFileManager defaultManager]; NSError *myError;
    BOOL ok = [mgr createDirectoryAtURL : myURL withIntermediateDirectories : YES attributes : nil error : &myError]; }

Sure, its a bit wordy but as Andrew said, it’s not that far from this:

        url: myURL,
        withIntermediateDirectories: true,
            attributes: null

The Objective-C editor will even line up your colons (if you’re into that sort of thing).

So, if you like to code in JavaScript and were thinking about trying Objective-C, give it a shot. You may just find it a little bit familiar. Also, if you’re in the Providence area, stop by ProvJS and join us for a meetup!

This website uses cookies

These cookies are used to collect information about how you interact with our website and allow us to remember you. We use this information in order to improve and customize your browsing experience, and for analytics and metrics about our visitors both on this website and other media. To find out more about the cookies we use, see our Privacy Policy.

Please consent to the use of cookies before continuing to browse our site.

Like What You See?

Got any questions?