r/iOSProgramming • • Jan 10 '16

Discussion The most important decision: Objective-C or Swift

Assume you're at a Fortune 500 that is launching a new business unit. No legacy code to deal with. It is now the beginning of 2016 and it is just you and your CTO. You are empowered to decide whether the mobile team that eventually will be hired should build the iOS app in Objective-C or Swift. What do you decide and why?

0 Upvotes

35 comments sorted by

View all comments

Show parent comment

1

u/mmellinger66 Jan 11 '16

The 75,000 line Swift app was reduced to 25,000 lines. That's a lot more than 30%. If you are starting from scratch now, isn't it more costly to write the extra 30,000 lines of code in the first place?

To put it another way, if someone is going to start an iOS project that would be about 100,000 lines of Objective C or 70,000 lines of Swift, shouldn't they choose Swift? The tooling will get better for Swift, but it's probably at a dead end for Objective C.

3

u/brendan09 Jan 11 '16 edited Jan 11 '16

The 75,000-100,000 line app was NOT reduced to 25,000 lines. That's absurd. Most line counts ignore header files anyway. That 30% number you've been using is complete BS, unless you count header files (which most people don't).

You're also falling into the fallacy that Swift saved that many lines. If I were to rewrite an Objective-C app from scratch (having the hindsight of written the first version), you can bet it'll be a TON shorter. That's just a rule of rewriting.

We have Swift code in existence that's in excess of 100,000 lines. It would've been around the same length / development time regardless of the language. If anything, Swift took longer from the pathetic tooling available.

It's absolutely less costly to write Objective-C right now. You can find a LOT more talented developers, there's more established libraries and knowledge, etc. Plus, you don't have to count rewriting substantial portions of the code every few months. The initial development time isn't any different (in any meaningful number). Most time isn't spent coding on large projects, it's spent planning / evaluating / testing.

Code from years ago will still compile and run fine in Objective-C. Code from Swift won't. It's a stupid amount of time investment to keep migrating that much Swift code.

It's absolutely not at a dead end for Objective-C. Apple has stated that Objective-C will be supported as long as Swift is, that it'll continue getting language features and updates, the IDE will continue getting new features, and that Apple will continue using Objective-C internally. Craig Federighi has said this in an interview. It's not a secret.

You can't walk up to a client and say "Hey...we chose this trendy language and jumped on the bandwagon too soon....we're gonna need you to pay $10,000 - $20,000 every few months for us to fix this poor decision." You don't keep clients like that. The same thing applies to internal projects at a company.

There is currently no defensible position for using Swift in large projects. There just isn't. From maintenance time, to libraries, to maturity, to tooling, to stability, to ABI (Application Binary Interface) instability, to the larger distributed binary size.

Literally the only people recommending it are the people not doing this in large projects professionally. The techies who jump on the tech bandwagon or write blog posts for a living. The same type of people who said MongoDB was production ready 4+ years ago, who are now regretting it. No one who's been in the industry or had responsibility for large projects / budgets thinks Swift is a good idea to jump on right now. As companies, we're not in it to beta test Swift for Apple. We're in it to ship responsible, maintainable code.

I'm not saying Swift won't be the first choice in 2-3 years. But, right now, it absolutely isn't. I've been doing iOS development for 8 years and have shipped dozens and dozens of large apps for big companies. You don't do well by jumping into immature software stacks. It's a ticking time bomb.

2

u/mmellinger66 Jan 11 '16

Look, I'm only stating what I've read. Lyft made the claim, I didn't:

"Swift code was also far more compact than Objective-C, which made it easier to understand and manage. Over the years, the original version of Lyft had ballooned to 75,000 lines of code. By the time the company was done recreating it in Swift, they had something that performed the same tasks in less than a third of that."

Swift isn't a trendy language, it's Apple's designated future software development language. Yes, you might have to pay a little more now but that's better than paying a lot more in the future. Why would you start a large in-house project in Swift today knowing that in 2-3 years most iOS developers will be using Swift?

The transition to Swift is happening quickly: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

Objective C usage is going to crater in 2016.

2

u/brendan09 Jan 11 '16 edited Jan 11 '16

And Lyft discounted the very real fact that rewriting anything from scratch in any language will lead to a massive savings in line counts. Even if they rewrote it in Objective-C, they likely would've seen similar savings.

Swift is a trendy language right now. The only people jumping on board are the ones not responsible for maintaining or managing large software products.

That's the same reason you see the 'transition' happening (like in the link you cited). It's only small, open source, often personal, projects that that they can count. It's not counting companies or industry, where the change won't happen until the language is ready and solid.

Swift is the future. Swift isn't the now. Objective-C in companies won't crater this year, not even remotely. The effect you're seeing is similar to designers on dribbble. Lots of people making concepts, showing off, showing the 'future' of design trends.....almost none of them are employed doing that professionally, and have zero impact on the actual industry.

0

u/mmellinger66 Jan 11 '16

You have provide zero evidence for anything that you have stated. It's basically your opinion. At this point, we should probably wait 12 months to see who was right. In the meantime, if anyone is looking for a Swift job, this board started recently:

https://www.natashatherobot.com/swift-jobs/

2

u/brendan09 Jan 11 '16

I have a lot of industry experience, which is more than anyone heavily pushing Swift has. 8 years of it being in iOS. 4 years of it owning a company that does this professionally for many, many clients.

Talk to any professional developer with experience and they'll tell you the same thing.

If your "evidence" is blog posts and nothing hands on, then you don't have the ability to be making claims like you are.

1

u/mmellinger66 Jan 11 '16

I've been working for over 20 years as a developer. I'm well aware of how conservative industry is. Large enterprise is extremely slow to change. Choose whatever works for you. However, I'm sure many developers and companies will realize the large productivity gains even with the current state of Swift. It's pretty obvious.

Your argument to wait is the classic argument that works with most technologies. (e.g. Stick with Python 2.x vs 3.x). However, with Apple things tend to move a bit quicker as far as them pushing developers towards their new technologies. They only released their tvOS examples in Swift, for example. It's possible that all new WWDC examples will be Swift.

Anyway, watch out for the companies that realize that writing 30% less Swift code that's easier to write correctly. They might eat your lunch:

http://www.sunsetlakesoftware.com/2014/12/02/why-were-rewriting-our-robotics-software-swift

2

u/brendan09 Jan 11 '16 edited Jan 11 '16

watch out for the companies that realize that writing 30% less Swift code that's easier to write correctly.

  1. As stated, the less code comes mostly from a rewrite, not the language.
  2. Watch out for companies losing clients (like dozens have already) from jumping to Swift too prematurely. Several people on this sub alone have mentioned how they left development agencies / fired devs for choosing to jump on the Swift bandwagon too soon. It's irresponsible and a waste of money.

It's called responsibility, and the ones who have it keep their clients / jobs. Pretty much every respected iOS developer is saying to keep using Objective-C for now. It's the responsible thing to do. We get paid a hefty sum of money to make responsible decisions, like making sure we transition technology stacks when appropriate: Not too early, and not too late. Less than 1.5 years after a brand new language comes out, and less than 4 months since the last breaking syntax revision, is most certainly not that time

When a company's livelihood / primary product is dependant upon software, you don't make bandwagon decisions and jump on tech before it's ready. It's a carefully calculated move that must be considered from all angles.

1

u/NSIRLConnection Jan 19 '16

Just incidentally, you might not want to use Lyft as an example for adopting Swift/shortening lines of code.

At least one of their iOS Engineers said that they think they would have been better off rewriting it in Objective-C, and from the context, you can tell that the number of lines was greatly reduced through better architecture, not Swift magic.

https://www.skilled.io/keithsmiley/tales-of-a-rewrite-at-lyft