Apple's new Swift programming language looking better to iOS, Mac coders

Apple's new Swift programming language looking better to iOS, Mac coders

Summary: As the dust settled following the WWDC introduction of Swift, Apple's new and future programming language, Mac and iOS developers had plenty to ponder. Many are coming around to Swift after voicing early concerns.


Mac and iOS developers are taking hard looks at Swift, Apple's new programming language introduced this month at WWDC in San Francisco. Some urgent questions include whether Swift is good or bad, whether it should be used for current and future projects, and whether or not programmers should go back and recode their past Objective-C work.

Apple's new Swift programing language looking better to iOS, Mac coders

David Owens, of Microsoft's MS Office for Mac and iPad team, had previously posted on Medium that the introduction of Swift was a bad day for ObjC programmers.

This has me very sad for the future of iOS and OS X development. I do not see, at this point in time, any major changes happening to Swift. There are many fundamental items about Swift that I'm just not a fan of that I think break the spirit of what ObjC was about: pragmatism.

However, in a recent post, Owens said he had changed his mind. He was blogging about creating a lightweight JSON (JavaScript Object Notation) library that provides the "expressiveness" he had with ObjC, "while keeping true to the semantics of Swift." He was upbeat on Swift's feature of Convertibles.

With just a little bit of work (and a lot of time fighting with current bugs in Xcode and Swift), Swift makes it possible to toe the line between type-safety and expressiveness. I can only imagine, that when we get proper documentation for all of this goodness, that most of my static typing concerns will simply dissapear.

Feeling much more bullish on Swift today. =)

At the Cocoanetics blog, Oliver Drobnik responded to the question whether programmers should switch to Swift as well as to whether it makes sense to migrate existing code to Swift. Of course, his answer to the first question could be summarized as "it depends," mostly based on when a particular app will be released. However, on the subject of backwards migration, Drobnik said there are good reasons to wait.

We have several closed- and open-sourced projects using Objective-C. There is nothing to be gained by rewriting everything in a new language. Apple lets you mix and match languages. If you add a new class to an existing project, you may let yourself be tempted by the allure of Swift and use that for the implementation. Or even a new app is something that you can tackle in Swift right from the start to learn about it and be able to give feedback to Apple. I don't see Swift replacing all of Objective-C development right away.

To my sense, Drobnik's approach was similar to starting up a new relationship. He said he would continue coding in Objective-C for existing projects and when Appledoc supports Swift, he might consider doing a project in it. But there was no reason to "rush into a new relationship with a new language and abandon one you have grown to love over several years. Take your time to get to know each other first."

Rob Napier, coauthor of iOS 7 Programming Pushing the Limits, posted on the Cocoaphony blog that despite reports that Swift was a functional programming language, there was little "functional" about it. He said it was a "pretty traditional object oriented language." But that was okay.

I would have loved all of Cocoa development to go functional, but just because I enjoy it. I don't know if it would have furthered the goal of really fantastic iOS and Mac apps, at least in the short term. It's not that FRP isn't a good idea. I don't have a strong opinion on that. It's just that the learning curve is high for ObjC programmers compared to Swift.3 And we'll need to integrate Swift with (non-functional) ObjC for a long time.

Check Out: Mac developers musing on Apple's new Swift language

Napier hopes that Swift will incorporate more functional features. If so, he said, "Swift might be a surprisingly important language and could improve the programming discipline because programmers would have to learn functional programming to develop on a very popular platform. ... Or none of that may happen, and Swift might just be a language for writing really fantastic iOS and Mac apps, and that's OK, too.

Practical Swift posted a list of 74 built-in functions (of which only 7 are currently documented). "The definition used for 'built-in function' used in this article is a function available in Swift without importing any modules (such as Foundation, etc.) or referencing any classes."

Michael Ash, author of The Complete Friday Q&A: Advanced topics in Mac OS X and iOS programming, posted an analysis of what he called "interesting features" in Swift. The list includes:

Explicit optionals. Swift makes optional values a first-class language construct, and requires that any optional type be explicitly marked as such. 

Multiple return values. Swift allows a function to return multiple values. 

Generics. This is a huge one. Swift supports generic classes and functions. 

Type inference. Static typing is nice, but it can lead to painful redundancy in code. 

Class-like structs. Like Objective-C, Swift has both classes and structs. Unlike Objective-C, Swift structs can contain methods. 

Trailing closures. This is a nifty feature that's simultaneously pointless and really nice. 

Operator overloading. I imagine this one will be controversial. 

Ash says he's looking forward to using Swift. "It has a lot of features that may seem foreign to someone coming from Objective-C, but I think they ultimately make a lot of sense and will be nice to use."

We are in the earliest days of the transition from ObjC to Swift and there will continue to be naysayers, no doubt. Eventually, there will be fans. That transition, however, won't be — dare I say it — swift.

Topics: Apple, iOS, Operating Systems, Software Development

Kick off your day with ZDNet's daily email newsletter. It's the freshest tech news and opinion, served hot. Get it.


Log in or register to join the discussion
  • I have been refocusing on Objective C like crazy lately

    Making sure I know it inside out. I just have this feeling that there's enough magic under the hood of Swift (and I don't care for magic), that we'll need to understand the Obj C underpinnings for those gotchas that are bound to come along.
  • Hey... if Apple wants to implement a goofy form of C#...

    More power to them. At least it's saner than Objective C.

    Welcome to the 21st Century, Apple programmers. You'll find out why this kind of language has been so popular on that 'other' platform for over a decade.
    • Except for the fact that it isn't that kind of language

      Certainly Swift has some C-ifications, has inferred typing, and dot syntax (Obj C had some of that already)... but only people who don't know many programming languages would say that comes from "that other platform"... unless by "that platform" you mean Java or PHP.

      C# is a very nice language, but it didn't come about in a vacuum either. For some reason, a lot of the people who only know C# and not anything else seem to think it sprang up in whole cloth from from the ground or something....
      • Answer the question filth...
        • Truly...

          I've tried to answer the vexing question, of why Zdnet's resident rabid dog is so hung up on "filth"
          It's a bit too anal for me.
  • Reasonably Swift adoption

    I'm liking Swift, but will probably stick with ObjC until end 2014. Favourite thing so far is explicit optionals.

    Looks like Apple's strategy is to really leverage the fact that they control hardware, software and developer toolchain, hence Swift and Metal.

    Xcode (if it isn't crashing) is getting better and gobbling up various third-party tool makers' businesses.

    Will be interesting to see how new devs cope with needing to be conversant with both Swift and ObjC. There's always been a bit of archaeology needed (Carbon APIs for AddressBook etc., pre-ARC libraries), but this may be a bit bigger.

    Interesting times....
    • Swift will replace Obj-C

      Swift will replace Objective-C as the third most popular language in TIOBE index. It has a huge potential. There is a good resource center and a community forum at, in case you want to hop on the Swift bandwagon.
  • Why Swift Exists

    I think that many people are missing the point of Swift. It's not a programming language designed to replace anything, but rather a gateway for new developers to the platform. A lot of developers have been put off iOS and OS X development, because of Objective C.
  • How would you write this in Swift...

    Can anyone provide some sample code in Swift for joining two lists on a common key, removing items from the result where the items in list B have a Price greater than 5, and then ordering the result based on the ReleaseDate of items in list A, skipping the first 20 items, and then selecting 10.

    Sadly, victims of domestic violence often believe their spouse is a great person. Moving from Objective-C to Swift is like moving from an abuser who uses a belt to one that slaps you around. Your injuries may be less severe, but your life still sucks.
    • Not this LINQ crap again

      Are you ever going to stop beating that horse? Cause she's pretty dead, Jim.

      As traditional programmers know, all languages can do these things. It isn't this vortex that suddenly became possible when LINQ arrived, nice as it is.

      Now, I'm not going to do your actual homework for you (not unless you plan to pay me, at any rate), but if your interest is real and not rhetorical, there actually are examples of how to do typical LINQ operations in Swift.
      • Filth can't differentiate between...

        "can do it" and "does it well." In your diseased brain dead mind, you believe that since you can sort a list in assembly, well, what more do you need? Does filth ever consider implementation time and maintainability?

        var fenceSitterIsFilth =

        (from p in ListA join q in ListB on p.ProductId equals q.ProductId
        where q.Price > 5
        orderby p.ReleaseDate
        select p).Skip(20).Take(10);

        Took me 30 seconds to write that filth, it's essentially self-documenting, and trivial to maintain. Go ahead filth, show us the Swift equivalent. Provide the code, or admit your filth. Which will it be?
        • Who is jackbond

          Somehow I've found the quote "Provide the code, or admit your filth" strangely poetic. I mean, yes it's insane and you've completely ignored the parent post and you're amazingly rude, but there's something so beautifully bizarre about it.

          It put me on a quest to look at your past posts (some of the recent ones even had Mac PC FenceSitter agreeing with you on a point or at the very least politely posting an alternative point to you) and the spitting venom goes back at least to 2008.

          You don't seem to be a troll, I doubt a troll would care enough to keep the act up for 6 years. You're part genius, part violent paranoid delusional. You call everyone else filth and suggest they need therapy, and you seem to be genuine about it. To the point where I feel I should check myself to a clinic and when they ask the reason I'm going I should respond "I like doing complicated tasks in HTML5 and JavaScript (aka JavaPuke). I'm clearly brain dead and need therapy".

          I mean don't get me wrong, if ZDNet finally banned you the quality of conversation would go up. You have nothing to add to intelligent discourse as your blinkers are on as soon as you see one of your trigger words. Like I say, there's just something bizarrely intriguing about someone who is intelligent enough to understand what goes on here yet insane enough to post everything you do.
          • Beautiful

            The fundamental problem is ZDNet doesn't ban anyone. So yes, my anti-Linux posts are purely an over the top response to the "Linux is god's gift to mankind, Microsoft is evil" nutjobs. And seriously, many of them in fact are quite brain dead. I've maintained the running joke that Linux programmers are serial killers for quite a while. And it is truly hilarious when one of them takes the bait. The ones with a scintilla of intelligence see it for what it is.

            As for fanboys like Mac_PC_FenceSitter, he's said some truly moronic things, such as programmers don't use LINQ in business apps because the loop performance is terrible. Kind of ironic that he's now posting pseudo LINQ equivalents in Swift (which according to him, won't be used due to loop performance.) I also mentioned that Objective-C doesn't have decent async implementation, which he ineptly interpreted as my saying Objective-C doesn't support async. I've got an app in the store, which does async, so I actually asked him the method one uses to get back onto the ui thread, and guess what, he couldn't name it. And now I've asked him to provided some sample code in Swift, and what does he do, he provides a link to some code. Thus, it's pretty natural to assume that he's either a VERY junior programmer or no programmer at all. Either way, he's professing expertise in a subject which he knows nothing about. That to me is a sign of a disturbed individual who ought to seek counseling. He certainly isn't someone who merits an iota of respect.

            As for you, I was entertained by your post, as you clearly got the impression that while my posts are part parody, they are informed. It appears you've read some of my anti HTML5/JavaPuke posts, and realistically, very little has changed over the last several years on that front. If you in fact "like" working with HTML5 / JavaPuke, I suggest you graduate to some real coding, and leave that grunt work to the amateur hacks.
          • You really don't read, do you?

            What I said was LINQ isn't used in commercial apps - and it isn't. Those don't even tend to get done in .NET for that matter (MFC in C++ is about as high level as it gets.)
          • Thank you for repeating the nonsense

            You are truly effing brain dead. Exposed for the world to see. Like I said before, you are not worthy of an iota of respect. Get therapy, you are truly ill.

            P.S. As you've provided no code AND still can't name the method for getting back onto the UI thread in iOS apps, it is abundantly clear you are FILTH. Need something easier? While using Autolayout, how do you make a control the same width as its parent? Hmm, still too tough? How do you populate a UITableView? So sad for you filth.
          • Wrong, wrong, and wrong

            "The fundamental problem is ZDNet doesn't ban anyone."
            Sure they do, I can list numerous examples of people who have had to change their usernames because their old ones had been deactivated. Owl((n)net anyone. They were deactivated for far less egregious rudeness than yours.

            "So yes, my anti-Linux posts are purely an over the top response to the "Linux is god's gift to mankind, Microsoft is evil" nutjobs. And seriously, many of them in fact are quite brain dead. I've maintained the running joke that Linux programmers are serial killers for quite a while. And it is truly hilarious when one of them takes the bait. The ones with a scintilla of intelligence see it for what it is."

            The truly sad thing is that you fail to recognize that this is the definition of trolling.

            Also note that it is you who failed to address key questions in that thread. Note that posting insults and other attempts at hand waving do NOT count as addressing the points. You continue that nonsense here. E.g., you claim Mac_PC_Fencesitter stated that LINQ is not used for "business apps". to which he responds "You really don't read, do you? What I said was LINQ isn't used in commercial apps - and it isn't."
            Your response? "Thank you for repeating the nonsense. You are truly effing brain dead. Exposed for the world to see. Like I said before, you are not worthy of an iota of respect. Get therapy, you are truly ill."

            I.e., hand waving and insults. You TOTALLY fail to address the fact that you mischaracterized his statement, to the point that you flat out lied, and you have the audacity to call anyone else "filth".
            But since you are keen on logical fallacies (and being an ass) take a second and note that there is not a single thread on ZDNet (and probably the internet, with the possible exception of some Aryan Nations chatrooms and al Qaeda web portals) where your posts are greeted by ANYONE positively. Even the trolls don't want to associate with your level of vitriol and rudeness.
          • Filth defending filth...

            His argument is that "commercial apps" are written with MFC. It's a laughable moronic statement to anyone with a scintilla of intelligence. As you are not laughing, it is obvious you are brain dead as well. But let me explain it for those with functioning brains. Every app in the Windows phone app store is a commercial app by definition. The last majority of those are written in C#, it isn't even an option to write them in MFC. Phones are SIGNIFICANTLY less powerful than desktops, and yet they manage to run applications written in C#. But according to filth logic, desktop apps are written in MFC because writing them in managed code would be too much of a performance hit. While that may be true for games, it's not for your run of the mill commercial app. And just to be clear, games are not written using MFC either.

            Again, all of this is abundantly obvious to real windows programmers. It's not obvious to those pretending to be developers, or what I call filth.

            Finally, what exactly is the distinction between business applications and commercial applications other than perhaps the former is used internally while the latter is sold for third party use? It's a moronic distinction in regards to this discussion. In general, developers don't sit down and say, "well guys, we're going to sell this app, so let's write it in C++." Again, real developers know this, filth doesn't.
          • You have the "jack" part right

            First off, you jackass, nice job with the straw man argument. And nice job demonstrating why it is a logical fallacy. His argument was NOT that "that 'commercial apps' are written with MFC". He never said that, nor anything any person with even a modicum of intelligence would interpret as same. from there, the rest of your argument, built as it is on this sloppy nonsense, falls apart.
      • Thanks, FenceSitter!

        An excellent set of examples.
  • The transition to Swift will be rapid

    Apple has provided us with a language that kids, young programmers, and new programmers will RAPIDLY LEARN and use for future iOS and MacOS X programming. They will create the next era of apps on the iOS and OSX platform.

    Swift is designed to be easy to learn. So easy, millions of Chinese Programmers will be able to pick up Swift easily. Since Swift can use the native language of the programmer, this is big for every newcomer.

    This means old farts are going to be in danger of being caught by and passed by new competition.