Swift 2 or 3?

Discussion in 'Mac Programming' started by jasnw, Jul 31, 2016.

  1. jasnw macrumors 6502

    Joined:
    Nov 15, 2013
    Location:
    Seattle Area (NOT! Microsoft)
    #1
    Quick question for Swift programmers. I'm planning to start learning Swift, so should I start learning with Swift 2 or wait for 3? I'm reading that there are some major changes with 3, and I don't want to waste time learning Swift 2 usage that will change with 3 (I was a Java early adapter, and I don't want to go through THAT again!).
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    You will go through that again. Swift (or any programming language) is a moving target.

    Swift 3 is already being moved to a back burner, and Swift 4 is in the pre-baking stages:
    http://arstechnica.com/apple/2016/0...ng-up-swift-3-and-lays-out-plans-for-swift-4/

    Learn one stable version first: the one with the best learning materials for you. Once you have the basics down, you can transfer to the next moving train, or get off the trains altogether and halt.
     
  3. jasnw thread starter macrumors 6502

    Joined:
    Nov 15, 2013
    Location:
    Seattle Area (NOT! Microsoft)
    #3
    I read that Ars Technica article just before I posted my question. I've been programming since the late 1960s, so I know languages change. What I'm hoping to do is pick up Swift at a point where changes are more incremental than fundamental. There were big changes from 2 to 3 (from what I can tell), but it looks like mostly behind-the-scenes changes in store for 3 to 4 (like stabilizing the ABI and the .swiftmodule binary file format). You can't hold off forever (like waiting for the perfect Mac Mini), but you can try to avoid learning a language when it's about to have large chunks of it deprecated or dropped in the next version.
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    It sounds like you can use your experience as a guide.

    I would start by going through the list of deprecations and changes in Swift 3 relative to Swift 2. If it seems like a lot of really fundamental stuff you'd have to "unlearn", then that suggests using books and tutorials targeting only Swift 3. You'd then have to account for the availability or absence of learning materials that target only Swift 3. You'd also have to account for the target audience of the learning materials: it may be that Swift 3 materials are largely targeted at people who know Swift 2, and would be confusing to those with no Swift knowledge at all.

    As an example, for myself, I wouldn't much care about reduction in functionality of the 'for' loop, because that doesn't strike me as fundamental enough. Yeah, it matters a lot if you're trying to migrate existing code that relies on the removed capability, because that's a rip-and-replace kind of change. But in terms of learning the language, loops is loops, and I've seen enough of them in Basic, Forth, Fortran (implied DO (yay)), Java (iterators and non-iterators), etc. that the feature-set of a 'for' loop isn't going to be a huge obstacle. That's my assessment, as it applies to me, from my experience. YMMV.

    If there's some particular thing in Swift 3 that you're not sure about, then please ask about that particular thing.


    On a side note, it's good that you mentioned your past experience, though if it had been in the 1st post it would have given an important context for the question. When I see a question that doesn't list past experience, I start by assuming it's from someone with no programming experience at all.
     
  5. jasnw thread starter macrumors 6502

    Joined:
    Nov 15, 2013
    Location:
    Seattle Area (NOT! Microsoft)
  6. dan1eln1el5en macrumors 6502

    dan1eln1el5en

    Joined:
    Jan 3, 2012
    Location:
    Copenhagen, Denmark
    #6
    just get documentation for Swift 2, Xcode will help you upgrade to 3, and 3 is similar, but simpler than 2.
    avoid 1, too many changes IMHO.
     
  7. Starfia macrumors 6502

    Starfia

    Joined:
    Apr 11, 2011
    #7
    Start with 3. This version plants major forward-thinking flags deep into the ground, fills in most conceivable missing features for the first time, and clears a bunch of cruft away, presumably forever – there's no need to learn it unless you're interested in a nerdish way.
     
  8. Analog Kid macrumors 601

    Analog Kid

    Joined:
    Mar 4, 2003
    #8
    It's worth tracking the Swift Evolution mailing list to see where the language is heading. It's an interesting process to watch and your experience would be valued. Swift 3 was intended to stabilize the syntax, but it looks like that won't come until 3.x or 4.

    Swift 3 is available as a preview already, I believe, but even if you start with Swift 2 I think Xcode will help with most of the migration.
     
  9. ukmacpro macrumors member

    Joined:
    Oct 1, 2008
    Location:
    London
    #9
    Start with Swift 3. There no point in learning syntax that we already know will be depreciated in the future... if you're starting to learn from scratch, the basics are pretty much the same regardless, so you may as well start with the version that will be the future.

    The only real downside is that a lot of existing examples and answers on stack overflow, and the like, are in Swift 2 syntax... But this will sort itself out in time...
     
  10. mac666er macrumors regular

    Joined:
    Feb 7, 2008
    Location:
    San Francisco, CA
    #10
    I have been programming since Swift 1 and while it is very exciting to learn about the future and take a peek in swift 3, I would recommend to use swift 2 for now.

    My only reason is really stability. I have small programs that have several classes in dozens of files and in total are about 10,000 lines of code. This summer, I migrated to swift 3 and the Xcode releases did compile but crashed the program for very small details some times.

    The migration tool from swift 2.3 to 3 is indeed very good, but Xcode beta (which you will have to use to use swift3) is not stable enough to use AND learn at the same time. I would hate to have my program crash only to have exactly the same code run without issues after a new Xcode beta release. I had to revert my code to swift 2 just for it to run again and then re-convert to swift 3 with a new release.

    If you want to learn Swift3 and can wait, I would wait until the stable release of Xcode.

    After all, what is the point of learning to code if your program can't run because of issues outside of your control.

    My first language was logo (many, many, many years ago) and swift is very easy to learn. Certainly easier than Objective C in my opinion.

    You will enjoy it.
     
  11. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #11
    Beware! At one company, they are trying to write a new app in Swift 3, and almost every new beta of Xcode, the Swift 3 syntax changes enough that lots of code needs to get re-written again.
     
  12. mac666er macrumors regular

    Joined:
    Feb 7, 2008
    Location:
    San Francisco, CA
    #12
    While I appreciate that Apple makes available a preview of Swift 3, I don't think it is a good idea to start from scratch in it.

    I think Apple is very far from being an inclusive company and so when I was starting out in their tools, it took me a while to figure out sometimes there are undocumented issues or things that are broken. I think this makes it difficult to learn, especially if you start using their graphical tools like interface builder. I can see a beginner pulling their hair with swift3 and interface builder or the usage of user interface constraints.
     
  13. jasnw thread starter macrumors 6502

    Joined:
    Nov 15, 2013
    Location:
    Seattle Area (NOT! Microsoft)
    #13
    I hear that. My company bought a Sun 4 server just after Sun released their Sun 4 line. We were not a Unix shop and were heavily into Fortran (scientific research). We went with Sun because they had a good rep. Well, we should have bought their older Sun 3 stuff. What we weren't told was that Sun had redone their Unix OS implementation almost from the ground up for Sun 4 (which was their first RISC machine), and they threw out their well-tested Fortran compiler for a brand new one. We were constantly running into wacko problems that we thought were because we were unfamiliar with Unix. Turned out about 80% of our problems were because of bugs in the OS and the compiler. Great fun all around.

    So, Swift 2 it is.
     

Share This Page