Getting pretty hard to ignore Swift after watching WWDC

Discussion in 'iOS Programming' started by 1458279, Sep 20, 2015.

  1. 1458279 Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #1
    I'm noticing that ObjC really takes a back seat at WWDC. The samples shown rarely show ObjC.

    Not exactly fair to those that choose not to learn a new language or have to maintain current ObjC projects.

    I wonder how the industry is taking this. Any shops dumping ObjC and converting over to Swift?
     
  2. AxoNeuron macrumors 65816

    AxoNeuron

    Joined:
    Apr 22, 2012
    Location:
    The Left Coast
    #2
    Personally I will likely move to Swift over the next few months. But Apple is still improving Objective-C, even if the spotlight is mostly on Swift.
     
  3. Dookieman macrumors 6502

    Joined:
    Oct 12, 2009
    #3
    I've dabbled with Swift a couple of times and I've come back to Obj-C every time because Swift still doesn't feel ready for the prime time yet. There are a couple reasons for this but Xcode is the main culprit for my frustrations, it just doesn't seem play as well with Swift as it does Obj-C.
     
  4. Hagrid macrumors member

    Hagrid

    Joined:
    Jul 13, 2005
    Location:
    New Jersey
    #4
    I'm still up in the air about Swift. Maybe because I started life as a hardware engineer, and started with Assembly, and FORTRAN, and BASIC and C, I find Swift "harder." I can understand the experts saying it has many advantages, but they say the code is simpler and easier to understand. I find just the opposite. All I can say is that I GROK Obj-C, I have yet to have that same feeling with Swift.
     
  5. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #5
    Both Swift and Obj-C are pretty horrible languages.

    Swift didn't fix many mistakes that Obj-C had, and it went on to make many new mistakes.
     
  6. 1458279 thread starter Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #6
    I haven't watched the Swift WWDC 2015 vids yet, but they've talked about a few changes to Swift in other videos and it looks like it's having a few growing pains.

    New updates to things don't seem to be more automatic, just different syntax. What exactly was the gain supposed to be if not making things a bit more automatic?

    I don't know all the changes yet, but manual to automatic ref counting was a gain, typing different syntax for the same effect is not a gain.

    Based on some of the changes, it looks like Swift might have been shipped out too soon. I would have thought they would've ironed things out more because they have so much background in programming languages.

    In other words, at this point, you'd expect a completely new language would be a big improvement over a very old language. Kinda like a 1940's car vs a brand new car... just expected more advancements.
     
  7. 1458279 thread starter Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #7
    I haven't learned the new mistakes yet, but that's really not what I wanted to hear. If Swift is having this many mistakes and if ObjC is not going to be updated much and if the support for C++ doesn't continue... I don't know what to think...
    Oh well, we're programmers, we the ones that have to understand the instructions :D
     
  8. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #8
    I think it's mixed regarding companies moving to swift. I'm currently job hunting so I've looked at a lot of job descriptions lately and spoken with some companies. Some are currently sticking with Objective-C. Some are half and half. Apple seems to be pushing swift quite a lot.

    Regarding improvements vs Obj-C there are definitely some. Part of the problem though for developers is that all the existing iOS APIs were written in Obj-C. The way that nil is handled in the two languages is completely different. In Obj-C having APIs that return nil makes perfect sense. In swift, not so much. You end up with optionals and a lot of ugly code to unwrap, force unwrap, yadda yadda. I kind of hate optionals.

    Also, it is possible to write code that is line-for-line the same in Obj-C and swift. That doesn't do you any good. If swift is to be valuable it has to have different and better ways of expressing the same functionality. And it does, but it takes a while to understand the new idioms. As an example I read about recently, doing date comparisons in Obj-C is verbose and error-prone. In swift you can override operators so your date comparisons can look more like

    if dateOne > dateTwo { // do something

    The string concatenation operator is also better than stringWithFormat. There are also functional programming features like map, filter, reduce on arrays that should make code terser and easier to understand.

    As they say 'you can write FORTRAN in any language.' Until you learn the swift idioms you won't understand the benefits of the language. What I'm afraid of is that swift becomes overly complicated like C++. One of the advantages of Obj-C is that it's not a complicated language. It let's you accomplish anything you want but doesn't tie you up in a lot of complex and crazy syntax that takes an inordinate amount of time to learn.
     
  9. Dookieman, Sep 22, 2015
    Last edited: Sep 22, 2015

    Dookieman macrumors 6502

    Joined:
    Oct 12, 2009
    #9
    I started to fiddle around with Swift again about month ago and started working on a 3rd party Twitter Client and got my first taste of optionals. I hate them.

    The most frustrating part was I could SEE the data I wanted when I used 'println', but I couldn't set any String objects to it or set a label... took me forever to finally figure out how to "unwrap" the optional especially if it was an array or dictionary of them.

    I get that it's used to avoid null checking and may save some lines of code here and there, but I think checking for NULL or NIL just makes more sense...
     
  10. 1458279 thread starter Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #10
    Well that certainly doesn't sound good. From a business standpoint, it seems like an easy decision to stick with ObjC. There should have been a big reason to upgrade.

    Kind of ironic that it seem inline with some of the phone upgrades. The iPadPro is much like the older surface, the 1st mini was outdated, the upgrades to the mini were behind the times.

    A new language should have knocked it out of the park, it's clear it hasn't.
     
  11. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #11
    The big advantage for me is that you can just drop down to plain C if you want in your programs at any point and it'll continue to work. As a person who learned C before I learned Objective-C I find C much easier to read (and much less verbose) so using it makes sense. Plus Objective-C has the advantage of Objective-C++ which is great because I can use the same C++ I wrote for Android in my iOS apps as well.

    Swift doesn't offer me any of those things as far as I can tell and because of that I'll stick to Objective-C. Apple will never replace Objective-C with Swift 100% (unless they design an entirely new operating system for iOS and Mac OS) so you'll be safe for years to come. If Apple drop support for Objective-C at any point in the next 20 years I'll eat my hat.
     
  12. 1458279 thread starter Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #12
    Good points. Interesting point that wasn't raised before, C++ being used on Android. I know Apple has a hate relationship with Android. Maybe Swift is a hit on Android.

    I'm watching these WWDCs and it's a bit of work to understand the Swift code which is mixed in on several of the videos. I'm not really seeing much new ObjC code in these videos.
     
  13. AlanShutko macrumors 6502a

    Joined:
    Jun 2, 2008
    #13
    This is the first group I've seen that's really been down on swift. I really like it. It's built as a safer language: it does more compile-time checking on things like types (optionals as well as numeric) to avoid a bunch of common errors. Type inference and the generics system remove a lot of the repetitive stuff you have to write in Objective C. It interoperates beautifully with Objective C. And there are new frameworks coming out that are really nice. For example, look at Alamofire vs AFNetworking.

    Here's a few things I really like about Swift:
    1. Enums with values associated.
    2. Better pattern matching! Being able to write a switch based on pretty much anything instead of just ints.
    3. Functions in structs, not just classes
    4. String interpolation (finally, no stringWithFormat for simple stuff)
    5. Tuples, no need for classes for simple stuff!
    6. Simple availability checking
    It's not perfect though, here are some things that bother me:
    1. Source compatibility breaks a lot. If you want to keep your project compatible between Xcode 7 and Xcode 6.4 (because you want iOS7 emulators but also want to run on iOS9) you can't really use swift. They have an update wizard that works quite well, but it's a one-way trip.
    2. No refactor yet for swift in Xcode!
    3. No implicit conversions between numeric types! I get that this is part of the safety thing above (so you KNOW when things might break because of differences in the sizes of ints, etc) but it's still crazy-making on some things.
     
  14. 1458279 thread starter Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #14
    That sounds good, but I have to wonder why they couldn't do these things with ObjC. Since I've started with ObjC, it's had many improvements and looked as if it was on a good path. Instead Apple decided to create a new language.

    IMO, any language can be made to do most anything and given the many years of ObjC, it would have been in the best interest of the people already using it to continue to make the changes you've described.

    The bottom line is that you have to compare the advantage Swift offers vs the advantage of upgrading ObjC to offer the new things to ObjC and consider the learning curve and cost of moving a project from one language to another.

    This really seems to point to Apple wanting their developers further away from anything that could be reused on Android.

    Hard to think these advances couldn't have been made to ObjC. Even stringWithFormat could be hidden on a function or preprocessed to make simpler, maybe already has.
     
  15. page404 macrumors regular

    page404

    Joined:
    Mar 5, 2013
    Location:
    The Netherlands
    #15
    The introduction of Swift made it possible for me to jump on the bandwagon for iOS development. Couldn't get my grip on Obj-C, but I'm learning swift rather.... swift ;)
    In the process I'll learn Obj-C too I guess. I like it. For those complaining; try working with Java and all it's gazillion IDE's, frameworks and external libraries. Or worse, Oracle's PL/SQL that has been there for 25 years and becoming very stale now. XCode is a blessing then.
     
  16. 1458279 thread starter Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #16
    Interesting point "Couldn't get my grip in Obj-C"
    All markets are free markets, any market can become flooded and create a bubble.

    ObjC being harder (if it actually is) would keep some from creating a larger bubble but we have a bubble (flooded market) either way. On the other side, ObjC is odd. I've studied from COBOL to C++/C# and many others... ObjC is odd. An intuitive language is always best and I don't see much intuitive about ObjC.

    I'm not sure Swift is much of an improvement, but I haven't gone much past a browse thru the 1st book.

    I'm NOT encouraged by the updates, it tells me Swift was half baked when released.

    As far as Java, we should all ban Android until google develops something at least on par with Xcode. Moreover, we should continue the ban until they offer a native code system and offers the same level of security as Apple.

    At this point, I don't see much solution to the flooded app market except to just see the AppStore as a distribution system and market on your own.

    I'm unsure if Swift is a 'better language' for those that already know ObjC.

    I'm unsure if moving existing work from ObjC to Swift is a loss or a gain, that's time that could be spent moving forward with ObjC, so Swift would have to be a meaningful improvement.

    IMO, Apple was making nice gains with ObjC in terms of more C++ support and better syntax/compiler support. Creating arrays/strings in the old days just plain sucked.

    Hard to say if the world really needed another programming language and does Swift actually have some specific advantage for mobile development, or is it simply a easier language?
     
  17. Naaaaak macrumors 6502

    Joined:
    Mar 26, 2010
    #17
    It was, and it still is. I'm giving them another year to fix crap.


    I don't see many benefits, either. You trade a ton of knowns for a bunch of new bugs waiting to bite you.


    This. Read notes from people who have started new projects in Swift, then restarted them in Obj-C because of unforeseen issues with Swift or its toolchain. I would not use Swift for anything beyond toy projects, yet.
     
  18. page404 macrumors regular

    page404

    Joined:
    Mar 5, 2013
    Location:
    The Netherlands
    #18
    But why choose? Is there any reason not to use swift and Obj-C in the places where they best fit? Although I don't have much experience with Xcode, I've already noticed that working with Swift means that you still have to fall back to Objective-C once in a while. I don't see the problem with that.
     
  19. 1458279 thread starter Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #19
    One reason to choose is to save the time to learn a language that would offer no net gain.

    Another reason is that (as I understand it) you have to do something special to get ObjC and Swift to work together in the same app.

    Another reason is that if someone is going to maintain or modify the code later, they probably have to know BOTH ObjC and Swift.

    If you have to "fall back to ObjC" ... why not just start with ObjC. What language is so weak that you have to "fall back" to another language?

    IMO, it seems like Apple really didn't think this thru. Many praise the iPhone/iPad and rightly so, but remember, they started without the ability to write real apps, it was a closed system. Android would have killed them if they didn't follow the demands of the developers and users.

    So far, nobody has given a clear, objective, logical, unbiased reason for Swift. What can Swift do that ObjC couldn't have been made to do?

    This whole argument is much like the Android/Apple different code sets argument of the past. It sucks to have to become an expert in both Android and Apple and maintain two different code sets in two different languages. Much like the old days of Mac vs PC.
     
  20. Dranix macrumors 6502a

    Dranix

    Joined:
    Feb 26, 2011
    Location:
    Gelnhausen, Germany
    #20
    No it's a question of coding style. Any turing complete language can be used to write everything. The difference in languages is simply the style they force on the code. And the style of Swift is way more in sync with modern development theories then Objective-C.
     

Share This Page