Apple adds new iOS/OS X programming language: Swift

By , Jun 2, 2014

Swift

Swift, a programming language for distributed parallel scripting (if you’re a developer, you know what I’m talking about), can now be used to develop apps for both iOS and OS X, Apple announced during today’s keynote at its five-day WWDC developer-only show in San Francisco.

Matter of fact, Swift code can co-exist with Objective-C, which has long been the preferred programming language for iOS development. Jump past the fold for the full breakdown…

Built with the speediest LLVM compiler, Swift is native, supports Cocoa and CocoaTouch development (so both iOS and OS X development is possible), has complete Xcode support and produces the same runtime code as he much more complicated Objective-C.

Apple Swift (image 001)

What’s best, developers don’t need to choose between C for Mac development and Objective-C for iOS development because Swift supports both iOS and OS X and can co-exist with C and Objective-C code.

Apple Swift (image 002)

Why would anyone develop with Swift?

Because it’s simpler than Objective-C yet as powerful – if not more. Also, Swift allows developers to create as complex apps as in Objective-C, but with fewer lines of code. But most importantly, Swift is really optimized for speed.

Here’s a side-by-side example of an example RC4 encryption code produced in C, Objective-C and Swift.

Apple Swift (image 003)

Another example follows below.

Apple Swift (image 004)

The speed gains alone should prompt developers to consider switching to Swift. And for would-be developers who are new to the platform, Swift is tempting due to its far less steeper learning curve.

What’s more, the complete Swift guide is available as a downloadable iBooks document. And when iOS 8 launches this Fall, developers will be able to submit apps created with Swift from day one.

  • Share:
  • Follow:

  • Gróf Attila

    wasn’t expecting that

  • Yash Gorana

    I’ll miss you Objective-C.

    People, from now on you too can code easily.
    Damn Apple has done some really great job.

    • Anmol Malhotra

      Not great.. Incredible job for devs

      • Yash Gorana

        What were you expecting? Coding with cats, dogs, leprechauns and unicorns?

      • Weberson Soprano

        Yash! Apple is starting a new level of programming. No, you will not coding com cats, dogs, dragons etc. But the language is ready to teach logic to children. I believe that some great apps in this direction is comming.

    • Arkadi

      For some resin i think that it’s way to early to think so, did you look at the known bug section….?
      Still a long way to go.

    • Wassim Omais

      I don’t know about you @yashgorana:disqus but after coding in C for about 3 years now, ending statements without semicolons is just weird. Like, right when I’m about to finish my typing my finger hovers over the semicolon key.

      Also, I have a quick question that hasn’t been answered yet. I am already up to date and knowledgable on Objective-C and the cocoa libraries (for mac). Does Swift contain the same classes and methods (NSDictionary, NSTableView, NSView, NSString, etc) and simply uses them with different syntax? Or are the class names and methods completely different in Swift?

      • Ara Rezaee

        They’re the same, “Swift is designed to provide seamless compatibility with Cocoa and Objective-C. You can use Objective-C APIs (ranging from system frameworks to your own custom code) in Swift, and you can use Swift APIs in Objective-C. This compatibility makes Swift an easy, convenient, and powerful tool to integrate into your Cocoa app development workflow.”

      • Yash Gorana

        Same name, same classes, same function, different syntax.

      • Wassim Omais

        Thanks!

      • BlueBoomPony

        I always felt the same way. Can the compiler not see the linefeeds or carriage returns? My beloved Ruby doesn’t need them. 😛 I wonder if it’s a punch card era relic.

    • BlueBoomPony

      I keep hoping for something to bring in someone other than tech geeks into coding. So much software blows entire monkeyhouses full of chimps. We need some new blood and new perspectives. Kick the old paradigms and all the graybeards to the curb.

      • Craig Certo

        I personally think we are all better off having people who dont want to put effort into coding out of that area.

  • Arkadi

    Point of order, you can use Obj-C in OS X development today

    • Juan Enrique Hernández Pérez

      In addition, they said “Here’s a side-by-side example of an example RC4 encryption code produced in C, Objective-C and Swift”.. Not true, was Python, Obj-C and Swift;

      • Amit

        Correct me if I’m wrong, the standard python release is based off C.

      • Juan Enrique Hernández Pérez

        To be honest i’m not sure but, Obj-C is not called C because it’s a set of C; If somebody tests Python code and says that it’s C code it’s wrong!, regards!

  • sriram varadarajulu

    i’m not a developer but i did some ios coding and i would like to know what is distributed parallel scripting.. can anyone explain?

    • Yash Gorana

      It’s a script that run many copies of ordinary programs concurrently.

      A script is interpreted. A program is executed.

  • Quang

    Craig Federighi was right…I was like “What the heck are they talking about?” at the time they were talking about this

  • Psykr

    This release is making me want to start developing! I hope they release this guide as soon as possible!

    • Yash Gorana

      It’s up on iBooks Store.

      • Psykr

        Really?! I can’t find it here, is it available only in US iBook Store?

        Edit: Forget it! Just found, thanks 😀

      • I still cant find it, please help…

      • sriram varadarajulu

        link please “:D

      • Yash Gorana

        Search for “Swift ibooks store” on google

      • Psykr

        Just one more question, if you can answer me. Do we have to wait for an update to Xcode so we can program with Swift language, or does is already support it?

      • Yash Gorana

        Yes, you’ll have to wait. Current Xcode (5.x) doesn’t support Swift.

      • Psykr

        Thanks for the help!

      • Yash Gorana

        Trust me, Swift is very easy. It’s more of human readable form. You’ll enjoy coding.

        Just don’t forget that you’ll require math (trig math too) to do some nice stuff.

      • Psykr

        I’ve just started to read the book! It seems pretty agreeable for new programers, like me :D’

        And about math, that’s what I like xD

      • One more thing, Can I develop app by only using Swift or do I still need hand of Objective-C alongside…

      • Yash Gorana

        Only swift from now on.

        Okay, first you need to know what’s Cocoa (Like what are UILabels, UITextField, UIButton, NSString, etc. What their attributes are).

        Then when you follow up your Swift guide, they’ll teach you how to do stuff with Cocoa for Swift.

      • That’s friggin’ awesome Wow man! and yup I do have basics about UILabels, UITextField, UIButton, NSString, et cetera.

        That’s just so Appy language…

      • Thanks again for the clarification… 🙂

      • Yash Gorana

        You’re welcome 😀

      • :-B

      • duongel

        is it possible to write apps for iOS versions prior to iOS 8 with Swift?

      • Psykr

        There are many experiments in the book that they ask you to do in Playground. Now I want it even more!

      • BlueBoomPony

        Beta is available now

      • Thanks, that helped me… 🙂

      • sriram varadarajulu

        thank you

      • BlueBoomPony

        They need a Cocoa guide for people who *don’t* know ObjC. Right now that part is very “importing your ObjC stuff to Swift” oriented.

        Supposedly you can start from scratch and develop entirely in Swift. That’s the book I want. You only brush up against ObjC when declaring API calls, but the mapping there is easily understood.

  • Best-Ever release…

    Hats off to Apple… 🙂

  • Arkadi

    WTH, this language (Swift) look like java script

    • Yash Gorana

      It’s a script. It can take any form.

      Java script is a HLL, so is Objective-C, C# and Swift.

      Ofcourse that’s the plus point of “looks like” feature of programming language. I haven’t learn Java but i know C#, it will just take weeks for me to learn Java because it feels like C# and vice versa.

      • Arkadi

        Yash they didn’t say hi this is our new scripting language

        They are pushing is as a regular programming language.

        Personally i don’t know C# but i’ve seen the code some times it’s a lot closer to Obj-c or regular Java then to JavaScript.

        Swift looks like JavaScript, if you a script programmer its a plus but if you tend to program in regular languages it can be a major minus.

        i personally hate JS cuse i freaking hate the idea of:

        “var num = 5”
        “num = num + Arkadi”

        its like WTH is going on in this code it looks broken to me

      • Yash Gorana

        It’s totally upto you which language do you prefer. You will still be able to use Obj-C (I’ll continue to use Objectiv-C)

        My comment was to support your statement with rational reason that similarity in programming language is good.

        PS – I agree that sometimes Javascript freaks it up.

      • johnsmartypants

        Swift looks more like Java rather than Javascript. Javascript doesn’t have classes and ECMAScript 6 is ways ways away and it still doesn’t work like Swift/Java.

        Though the good thing is that now everything seems to be merging around similar programming syntax so it will be easy to do stuff Java/Javascript (in the future)/Swift as they all look similar.

    • Dominic Tobias

      oh no the “oh no let’s hate javascript because we suck at it” brigade is here. It is possible to code good C/C++ and JavaScript if you know what you are doing. Especially once ECMAScript6 comes out. There are quirks in javascript sure, but the syntax is good (mostly).

      • SuckOnTheTruth

        Give me a break. I’ve seen a lot of bad code over the years, but by far the worst code has always been that written in scripting languages, precisely because most of that code was written by people who don’t know what they’re doing. Have fun with the steaming piles of crap your graphic designers are going to dump in your lap, now that everyone will fancy themselves an iOS developer.

  • Mark Babatunde

    Looks like I’ll be able to develop some awesome apps now! Can’t wait for this summer! iNES or iSNES will come soon!

  • Wassim Omais

    I wrote a library that I am using with my cocoa application in C++. I used a few Objective-C++ (.mm) files with my program. Does anybody know if C++ can be mingled with Swift? I would hope so.

    • BlueBoomPony

      I think you just need to put it in a ObjC wrapper.

  • Alberto Espinal

    I guess this is something that has to do with a larger and more resolution Iphone, not just change the way people code, its just getting them ready for the future devices!!

  • 60hz

    lol was never a fan of ObjC, so i’ll stick to C++, at least that way I can port to Android quickly… which is probably the real motivation behind this new “programming” language.