Swift: Throw away your Objective C books!

Discussion in 'iOS Programming' started by firewood, Jun 2, 2014.

  1. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #1
    Apple introduced a new programming language today at WWDC. Although Swift uses a similar run-time model to Objective C, the syntax is completely different.

    Swift looks cleaner, safer, faster and probably easier to learn than Objective C and C. Especially with the built-in JIT/interpreter and Playground.

    PDF documents and an iBook on Swift programming are already available from the Apple Developer web site. Get 'em while they're fresh.

    To bad about all those obsolete books on Objective C...
     
  2. dejo, Jun 2, 2014
    Last edited: Jun 3, 2014

    dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Objective-C is not so much obsolete as deprecated, I would say. :)
     
  3. Dookieman macrumors 6502

    Joined:
    Oct 12, 2009
    #3
    I'm at work and can't try the new Xcode yet, but I can still use Objective-C in my current app I'm working on right? From the slides and other information it looks like you can use C, Objective-C and Swift to make Mac/iOS programs now.

    Apple will obviously be switching gears away from Objective-C in the future, but I'm not stuck needing to implement things in Swift now.
     
  4. ben123456 macrumors regular

    Joined:
    Jan 22, 2012
    #4
    im considering learning a programming language. Would this be a completely new coding language that i would have to learn separately or?
     
  5. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    Or what?
     
  6. EX1127 macrumors 6502

    EX1127

    Joined:
    May 26, 2009
    Location:
    Louisiana
    #6
    Does anyone know if you can use Swift outside of Xcode 6? I want to learn the language but it looks like all I can do right now is read the book that they released today.
     
  7. Dookieman macrumors 6502

    Joined:
    Oct 12, 2009
    #7
    I'm 99.999999% its Xcode 6 only.
     
  8. ben123456 macrumors regular

    Joined:
    Jan 22, 2012
    #8
    or is it just like objective c except improved?
     
  9. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #9
    It's a new programming language, quite different from Objective-C. I wouldn't call it "completely" new, though, since it borrows some things from previous languages.
     
  10. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #11
  11. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #12
    Oh great, yet another overloaded name.

    I wonder how many different programming languages named "swift" there are. There seem to be at least two before Apple's announcement today:

    1. The Swift parallel scripting language. Code sample p3.swift:
    Code:
    type file;
    
    app (file o) simulation (int sim_steps, int sim_range, int sim_values)
    {
      simulate "--timesteps" sim_steps "--range" sim_range "--nvalues" sim_values stdout=@filename(o);
    }
    
    app (file o) analyze (file s[])
    {
      stats @filenames(s) stdout=@filename(o);
    }
    
    int nsim   = @toInt(@arg("nsim","10"));
    int steps  = @toInt(@arg("steps","1"));
    int range  = @toInt(@arg("range","100"));
    int values = @toInt(@arg("values","5"));
    
    file sims[];
    
    foreach i in [0:nsim-1] {
      file simout <single_file_mapper; file=@strcat("output/sim_",i,".out")>;
      simout = simulation(steps,range,values);
      sims[i] = simout;
    }
    
    file stats<"output/average.out">;
    stats = analyze(sims);
    
    Taken from:
    http://ec2-54-196-24-118.compute-1.amazonaws.com/tutorials/cloud/tutorial.html

    2. The Swift web language. Code sample hello.jif:
    Code:
    package hello;
     
    import webil.ui.*;
     
    public class Hello {
     
        final label{*<-*} cl = new label{Client->; Client<-};
    
        Text[cl, cl]{Client->; Client<-} message;
        final Panel[cl, cl]{Client->; Client<-} mainPanel;
     
        public Hello{Client->; Client<-}()
        {
            message = new Text("Hello World");
            mainPanel = RootPanel.getRootPanel(Client);
    
            if(mainPanel != null) {
                mainPanel.addChild(cl, cl, message);
            }
        }
     
        public static void main{Client->; Client<-}()
        {
            final Hello h = new Hello();
        }
    }
    

    They should have named it Blue Tit, which would at least be memorable, funny, and unique. Plus, we could all make "Do you mean an African or Eurasian blue tit?" jokes.
     
  12. MattInOz macrumors 68030

    MattInOz

    Joined:
    Jan 19, 2006
    Location:
    Sydney
    #13
    Aren't Apple custom designed ARM cores also under the name swift?
     
  13. 1458279 Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #14
    One thing I noticed was that they mentioned they wanted Swift apps, so does that mean that an app will be either Swift or ObjC?

    Right now, you can mix, C, C++, ObjC in one app... is Swift going to be different in that you can mix it with ObjC?

    If you can't mix, that'll mean you'll see a whole bunch of apps needed to be re-written and if Apple pushes Swift like Retina and iOS7, you'll see a bunch of apps gone and new ones coming in like never before.

    Funny, the BNR book just came out a few months ago.. I almost ordered one.

    Anyone know if the iTunes book comes in a .pdf version instead of the ePub only?
     
  14. thekev macrumors 604

    thekev

    Joined:
    Aug 5, 2010
    #15
    That's good to know. That other link reminded me how much I hate java.
     
  15. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #16
    If by "they" you mean Craig Federighi, he also mentioned that "your Swift code can fit right alongside your Objective-C and your C code, in the same application". You can see this at around the 01:46:54 mark of the Keynote video.
     
  16. Madd the Sane macrumors 6502a

    Madd the Sane

    Joined:
    Nov 8, 2010
    Location:
    Utah
    #17
    Swift can use C and Objective C functions, but not C++ (you need to wrap those in C code). As far as I know, you can only use Swift code in Objective C, and maybe C.

    So if you have C++ or Objective C++, you'll need to wrap your code.
     
  17. Dranix macrumors 6502a

    Dranix

    Joined:
    Feb 26, 2011
    Location:
    Gelnhausen, Germany
    #18
    And C code is currently a little frontier to get working ;)
     
  18. mripah, Jun 13, 2014
    Last edited: Jun 13, 2014

    mripah macrumors newbie

    Joined:
    Oct 10, 2010
    #19
    Lets be honest I think Apple eventually wants to get away from ObjC and Swift is the future. They won't get rid of ObjC right away, but once a certain number of developers (and core OS systems) switch over, I think they give the warning, the later drop the hammer.
     
  19. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #20
    I expect that all development going forward will be Swift.

    Possibly we'll see Apple go through another transition, like from Carbon to Cocoa, where slowly but surely the old code will go away and be replaced with new code.

    I mean, is Apple even done killing Carbon, quite yet, or was the newest version of Logic the final nail in Carbon's coffin (I think that's the most recent app that Apple transitioned from Carbon to Cocoa, right?)
     
  20. firewood thread starter macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #21
    Although Objective C may see some continued but rapidly declining use due to its huge existing code base (source code to around 1 million apps, plus all the stuff on github/cocoapods, frameworks/libraries, etc.), between 6 months to a year from now, all those books on Objective C will likely be in the discount/remainder and $1 bins, as anyone who doesn't know Objective C, won't be interested in it. Students and programmers will eventually be able to write all their Mac and iOS (and if we get lucky, linux) code faster in Swift.

    I'm hoping some educators and teachers (e.g. not just expert programmers) will write some intro to Swift books.

    But we are currently in limbo, as Swift is buggy and unfinished, and likely will be until maybe a release or two after iOS 8 ships.
     
  21. McGiord macrumors 601

    McGiord

    Joined:
    Oct 5, 2003
    Location:
    Dark Castle
    #22
    From the Keynote my interpretation is that most of the tutorials are kind of oriented toward people that already know how to code, and much of the references seem to be to Objective-C.
    It sounds like it still makes sense to first learn Objective-C to be a proficient coder and then move into Swift?
     
  22. firewood thread starter macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #23
    For the next 3 to 6 months, yes.

    After that, up to maybe a year from now, it will be easier to start directly with Swift, and just ignore Objective C, unless you get a job working on old code or libraries. All the intro books and tutorials on Swift will take a few months to write and publish, but I'm guessing that they will be a lot better than the books on Objective C.

    So it depends on when you want to start.
     
  23. s2mikey macrumors 68020

    s2mikey

    Joined:
    Sep 23, 2013
    Location:
    Upstate, NY
    #24
    Nah, I'm gonna stick with my BNR objective C book and finish it through. Can't hurt me to get some experience writing some programs in Obj C.

    There isn't even a gaurantee that Swift will take over that quickly. It's still pretty new, right?
     
  24. McGiord, Jun 15, 2014
    Last edited: Jun 17, 2014

    McGiord macrumors 601

    McGiord

    Joined:
    Oct 5, 2003
    Location:
    Dark Castle
    #25
    Look into these interesting takes and comments about both languages:

    From http://daringfireball.net :

    "
    Aaron Hillegass: ‘iOS Developers Need to Know Objective-C’ ★
    Aaron Hillegass, who I think is universally regarded as the preeminent teacher of Cocoa:
    http://www.bignerdranch.com/blog/ios-developers-need-to-know-objective-c/


    When Apple announced Swift, I heard a few people say “Hurray! Now I can be an iOS developer without learning Objective-C!” I have three messages for these people:

    If you want to be an iOS developer, you will still need to know Objective-C.
    Objective-C is easier to learn than Swift.
    Once you know Objective-C, it will be easy to learn Swift.
    Before I proceed, let me preface this with a confession of love for Swift. The syntax is lovely. The Swift compiler will catch so many errors for us; I’m certain that when everyone is coding in Swift the reliability of apps will improve considerably. The enum construct is gorgeous. Swift is a major step forward for the entire iOS and Mac OS X ecosystem. But…

    Points 1 and 3 I agree with. Point 2, I’m not so sure about. But the real question is time. I don’t think anyone would dispute that a serious Mac or iOS developer needs to know Objective-C today. But what about a year from now? Two years? Five? At some point, the answer to “Do I need to learn Objective-C?” will be “No.” I don’t know when that will be.

    I’m bullish on Swift’s uptake not because I think it will appeal to new developers (although eventually I think that will help too), but because I think it appeals to the huge base of developers who already know Objective-C and Apple’s frameworks.
    "
     

Share This Page