Has anyone fully moved to Swift?

Discussion in 'iOS Programming' started by chrono1081, Apr 2, 2016.

  1. chrono1081 macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #1
    Hi guys,

    I was just curious if anyone has fully moved to Swift. I'm currently learning it and...I find it insanely messy and convoluted. I can't imagine writing lots of apps with it.

    Maybe its my lack of experience with the language but the optionals seem atrocious, a lot of functionality that Objective-C had seems to be missing, and I'm seeing no real benefit at all. (If I just need to give it more time let me know).

    Is anyone actually using this for production apps? I'm curious what others thoughts are.
     
  2. AxoNeuron macrumors 65816

    AxoNeuron

    Joined:
    Apr 22, 2012
    Location:
    The Left Coast
    #2
    My previous large project was in Objective-C, and my current project is being written in Swift. I didn't like Swift either at first, but I have really come to love it. The optionals are definitely confusing at first but I have come to appreciate them: they really force you to think intelligently about how your code should work while you are writing it instead of when it crashes or has strange bugs.

    Swift is definitely a work in progress, there are things that are missing. For example, Swift arrays have no function for array.removeObject(object) or array.indexOfObject(object), which is stuff that NSMutableArray had in Objective-C. But these are easy to add using the extension keyword. I also hate hate hate the decision to remove C-style for loops (what the hell...). But overall, I still prefer Swift. It's faster, easier, and much cleaner than Objective-C was.
     
  3. 1458279 Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #3
    Ok, explain something to me. Swift is just syntax, NSMutableArray is not part of Swift, it's a part of the APIs that you use in an app. So why would NSMutableArray not have .removeObject ?

    I don't understand how a language can remove a method that is not a part of the language. Is there something I'm not getting?

    As far as Swift goes, I hated it at first, then jumped in and started liking a number of things.
    +1 on the for..next loop, there's just ZERO reason for that to be removed.

    I've also heard about bugs when dealing with Core Data, I don't know if they've worked out the bugs, but it's very odd for Apple to release a language and have it be so buggy, so different, and then for people to start changing standard programming things like the For..Next loops.
     
  4. npolly0212 macrumors 65816

    Joined:
    Sep 21, 2015
    #4
    Can you tell me the best way to learn this language?

    I am currently a computer science major and interested in learning more languages.
     
  5. chrono1081 thread starter macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #5
    Thanks guys. It's good to hear others ended up liking Swift. I guess I just need to put more time into it.


    The Big Nerd Ranch Swift guide is pretty good. When I learn a new language I usually tackle it using 1 - 3 new sources.

    I'll start with a video series from Lynda or Pluralsight to get up and running quickly. Then I'll use a book to fill in the knowledge gaps.

    Apple has a free guide that is really good but it's kind of boring (but straight to the point) to read through. Here's a link on their site with links to the book and some videos.https://developer.apple.com/swift/resources/
     
  6. *SteveB* macrumors newbie

    Joined:
    Jan 22, 2015
    #6
    It's because Swift has its own array type. NSMutableArray is still available as part of Foundation, but it's not the same array implementation as Swift's native array type.

    The main difference is that Swift implements arrays as Value Types, rather than the Reference Types (classes) that Objective C uses. This also means that there is only one array class for both mutable and immutable uses, as mutability is built in to the language.

    I still have my grievances with Swift, so I'm using for small projects, but sticking to Objective C for large scale projects for the moment. My main issue with it is that the Cocoa apis aren't very 'Swifty' and feels a bit clunky, but those issues should be resolved over time.
     
  7. npolly0212 macrumors 65816

    Joined:
    Sep 21, 2015
    #7
    Awesome I appreciate it! Have always wanted to learn some languages on my own
     
  8. 1458279 Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #8
    That's really odd that Apple allowed that to happen. I can't imagine the pain of moving over to Swift with a project done in ObjC.

    I'm baffled by Apple's approach on this. They were making ObjC more C++ like and then they come out with something that's has C type loops, then take them out.

    There was an article about Swift and the went thru the top apps and found a very, very small percentage that were actually written in Swift. I'm not against new development in tech, but they really put out something buggy. Now we're about 2 years in and it still doesn't have the bugs flushed out, yet they are concerned over the For..Next loop?

    The other issue is about the business of software development. Swift breaks a few business rules. 1. Assume your team will change and stick with something others already know. 2. Reuse what's already there. We have tones of ObjC/C/C++ code already proof tested. 3. Don't introduce something that doesn't justify it's value. If Swift doesn't add enough value to justify it's learning curve, why use it?

    Shipping Swift with bugs and making meaningless changes like For..Next, doesn't help either.
     
  9. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #9
    Many programmers did not like Objective C until they had put a few weeks/months of actually developing an app in it. Many programmers will not like Swift until they do the same. A few programmers don't like any programming language except one (pick one, but a different one for every programmer, usually the first one they got good at). Ossification of the brain.
    --- Post Merged, Apr 4, 2016 ---
    Apple is in the business of breaking the rules. It's how they gain a competitive advantage leading to high profits. Count on your business going with the breaks or being left behind.

    Who still codes in 6502 asm and AppleSoft Basic? Or UCSD Pascal? Or MPW C? Or still uses ToolBox or Carbon or iOS 6 appearance APIs? Many software companies depending on "the rules" are out of business. New Macs (Intel) are incompatible with Macs (PPC) are incompatible with Macs (68k).
     
  10. 1458279 Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #10
    It seems pretty common that programmers resist a new language. I've always been that way. Part of the problem is the learning curve. I try and get to the point where when someone wants something done, I've already studied it and have the code to drop into a project.

    When you get into a new language, you have to forget most of what you knew and dig into a bunch of new concepts.

    Options, For..Next, etc.. Some add value to the project, others are just another way of doing the same thing. Looping is looping, going away from For..Next ads no value that I can see.

    IMO, it's more like English/Spanish, they both do the same thing, not much value in having both. Imagine how much time is wasted just because of all the languages that offer nothing much better than others offer.

    I'm not saying the a new language for mobile is a bad idea, but you have to compare the good with the bad.

    I don't think the compare to Pascal, Basic, Toolbox, etc... is the same. I'm talking about developing a new language that doesn't follow standards of other mainstream languages.

    I worked at a company that had all their code written in a language that very, very few people knew. They couldn't find new people to even go in and learn it because it was career suicide. There are no jobs in it.

    About 20 years ago, Computer Associates was huge and came out with "the solution" for business software. It was called Visual Objects. I tried it and it looked very good, but never took off. Same with Microsoft saying Visual FoxPro was the future of business software.

    There's a difference between breaking the rules of having an installed user base and breaking the rules for a new advancement that's a game changer.

    Swift is a bit different because it's hitting at the entry level of a fast moving market (mobile), so it has a chance. Apple and others are pushing it really hard. It's hard to find modern tutorials that are in ObjC. Probably the same for books. Everything has moved to Swift.

    Other than being a different language and (IMO) not much easier to learn, it doesn't seem to offer much above what ObjC can do.

    Different isn't always better.
     
  11. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #11
    There are almost no new concepts. Most compiled languages spit out the same results: assembly code for memory references, arithmetic and logic operations, conditional jumps, etc. The rest of the "new concepts" is mostly arbitrary syntactic sugar and punctuation abuse. Occasionally some nice abbreviations and library runtimes for commonly used code sequences.

    Nearly the same was said about every other language, including Basic, Cobol, C++, Java, Haskell, Scala, Python and etc.
     
  12. 1458279 Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #12
    I can see that, I'm not against Swift myself. I guess some say it takes some things from Google Go language.

    Some of the changes, like the For..Next either should have been done at the start, or should be left alone. I really can't see much of an argument for making the change.

    They really do need to dig in and make it a solid language, the array issue really shouldn't be coming from a company like Apple.
     
  13. patent10021 macrumors 68020

    patent10021

    Joined:
    Apr 23, 2004
    #13
    lol I fully moved the day it was released.

    In saying that, you will never rid yourself of having to encounter Obj-C. I feel like it's the same when Morpheus said we're were a plague on this earth lol

    There is only ONE benefit to Obj-C. When you open an old Obj-C project it usually just works. If you open an old Swift project chances are good you'll be there for hours updating your code lol

    Even pods have moved on. Pure Swift pods are ubiquitous.

    Updating legacy C-style loops to Swift 3 style loops is the new rage:mad:. Quite literally. :p:apple:
     
  14. 1458279 Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #14
    I hope you're being paid for that rage :D

    What does the bolded statement mean? Pods have moved on? I'm under the impression that pods are universal and have no tie to any language. I'm I missing something about pods I'm not getting?
     
  15. AdonisSMU, Apr 8, 2016
    Last edited: Apr 8, 2016

    AdonisSMU macrumors 603

    Joined:
    Oct 23, 2010
    #15
    I think the decision to remove c-style loops makes complete sense once you realize how the assignment operator works in Swift. Developers in the community urged Apple to ditch the c-style loop.

    You can just set the array item to nil if you want to get rid of it. It accomplishes the same thing as "remove" would.
     
  16. 1458279 Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #16
    Can you give us a bit more insight to this?
    What is it about assignment operators that are different in Swift?

    Also, if you run thru an array performing an action on each element, what happens when you hit the nil?

    Do you have to check each element for nil before performing an action on it?
     
  17. AdonisSMU, Apr 9, 2016
    Last edited: Apr 9, 2016

    AdonisSMU macrumors 603

    Joined:
    Oct 23, 2010
    #17
    Assignment operators in swift are supposed to return void. This is not possible with C-style post/pre increment/decrement operators ++ and --.

    https://github.com/apple/swift-evolution/blob/master/proposals/0004-remove-pre-post-inc-decrement.md

    I did experience some problems with Arrays inside of dictionaries.... if I want more than one type for a value in a key value pair say I want the dictionary to be

    Code:
    [
        "key": "String",
        "key": [Array]
    ]
    
     
  18. vvrinne macrumors member

    Joined:
    Feb 28, 2010
    Location:
    Helsinki, Finland
    #18
    Haven't written a line of objective-c in over a year. Actually convinced the client on my latest project to only support iOS9+ as well :)
     
  19. 1458279 Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #19
    This is one of the things I hate about Apple products. A test device is expensive and becomes worthless so quickly. It's actually kinda sad that all those millions of devices have no more value. Can't hardly find even simple apps to work on older devices (yet I still see people trying to get top dollar for them).

    It's clearly an upside to the company and developer to dump the old backward compatible stuff.

    Can't hardly wait for Google to adopt Swift, you'll see a huge increase in the usage of Swift. Reminds me of the Mac/Windows wars of the past, except this time Apple actually has meaningful market share.
     
  20. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #20
    I still test my Objective C apps on an iPhone 3GS, and Swift code on an iPhone 5s. Not for any revenue potential (likely close to zero), but because if my app runs on such and old slow iOS devices, they will likely have tons of responsiveness and performance headroom on current devices and future (slower?) OS releases.

    A mobile app that lags on device with 64-bit 1GHz+ ARM processors makes me suspect the competence level of that app's developer(s).
     
  21. 1458279 Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #21
    That's a great point, many programmers just find some way to get the job done without any concern for performance. Depending on the app, if it's going to be on the market for a while and added to, it can kill the performance later and they'll have to go back and rework the code.

    Performance is often overlooked.

    So you test Swift on a higher level machine, why is Swift naturally slower, or will Swift not work on older machines because of compatibility?
     
  22. cerberusss macrumors 6502a

    cerberusss

    Joined:
    Aug 25, 2013
    Location:
    The Netherlands
    #22
    I've been doing Swift projects for the last 1.5 years exclusively. I'm a freelancer, btw. I'm not taking any Objective-C projects, I like new things and Swift is nice to learn.
     
  23. 1458279 Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #23
    I can see the benefit of not having one of those "we need you to fix up some old code" jobs :D
     
  24. recoil80 macrumors 68000

    Joined:
    Jul 16, 2014
    #24
    I'd like to move but my main project still supports iOS 5 so no swift for me at leat till the end of the year.
    If I develop something new Swift is the language I chose
     
  25. 1458279 Suspended

    1458279

    Joined:
    May 1, 2010
    Location:
    California
    #25
    I thought I was crazy for supporting iOS 6.1 ...

    Just wondering, why can't you get up to at least 6.1?

    I'm stuck because my test devices are old. I really want to get to 7 for the WiFi stuff, but it'll have to wait.
     

Share This Page