
Ask HN: Swift or Objective-C for new iOS app in 2017? - beacham
This question was asked a little over a year ago on HN and I noticed many answers said something along the lines of &quot;Give swift another year&quot;. What do you think now?
======
karmelapple
Swift, since it's Apple's preferred language of the future. On Apple
platforms, you pretty much should embrace whatever the Mothership prefers
going forward.

Additionally, once you start coding in it, you'll likely find it's a joy
compared to Obj-C.

------
veidr
I can think of only two reasons to use Obj-C over Swift in 2017:

1) The app will rely heavily on outside libraries or codebases that are Obj-C,
to the extent that it will be annoying even though Swift-ObjC interop is
pretty OK, and

2) You (or your developer(s)) are grizzled Obj-C veterans, haven't yet learned
Swift, and you are in a rush and don't want to waste time learning stuff

Swift has some warts still, but the show-stoppers like "all your code will
break in the next release" are over (well not on Linux yet, maybe, but on iOS
for sure). Swift is better than Obj-C in almost every way you could think up,
even if thinking them up was the whole point of a drinking game. (And I say
that as somebody who did Obj-C programming for 19 years and Swift only 2 so
far.)

So it's pretty much truck-vs-horse at this point. The horse will still let you
ford that river after a flood, and you can eat it if you get trapped for weeks
by a blizzard or something... but basically the truck is gonna be better for
almost anything unless your app is really unusual.

------
exidy
Swift, unless: 1) You intend to keep this app maintained but can't afford to
track future Swift languages changes, or 2) You want to optimise for binary
size above all other considerations. (apps written in swift bundle the swift
libraries)

------
jordansmithnz
I developed in Objective C for years. Have been on the Swift boat for a while
now, and not long ago I did some maintenance on an old Obj C project.

Even allowing for the re-learning time and rustiness, there was such a sharp
contrast. Swift is just so much more fluid, productive, expressive, and a joy
to use.

Yep, there are plenty of issues, stability isn't 100%. Despite that, it is
well worth the jump.

------
sehr
_Maybe_ Obj C if your machine is a bit old or underpowered. SourceKitService
is a hungry, hungry little beast.

The tooling in general around swift still feels a bit "in progress" imo but
it's defo the future, and for me, the present.

~~~
senc01a
I can't agree with this rationale. Your machine will change over the years,
while decisions as important as the programming language to choose will remain
over time.

~~~
sehr
I don't completely agree with it either, hence the italicized _maybe_

------
benliong78
Swift is simply a safer language to use, safer as in it tries to prevent you
from shooting yourself in the foot. And at this point the framework support
has pretty much caught up. So my vote is for Swift on new projects.

And stick with Swift 3.0

------
dfansteel
Hands down: Swift.

I absolutely adored Objective-C. But there were a few things I never felt
comfortable with and just drank the Kool-Aid on.

1\. Message passing to `nil`. Sure it's nice that you can safely pass a
message to nil, but the idiom is a little weird. `guard` and `defer` have
completely changed the way I write code in functions to exit safely.

2\. Protocol Oriented Programming. This has changed the way I architect my
applications for the better. I end up with less code over all and fewer Unit
Tests in particular.

3\. Associated Value Enums. Another big win over Objective-C. Now I can have a
type and value all wrapped in one little package for my switch statements. It
sounds minor, but it minimizes cyclomatic complexity.

4\. It's going to be very good to know this language in 2 years. Javascript
has owned the browser for too long.

------
orange_county
Swift and its not even close.

------
Vanit
Now that the language is more feature rich the rose tinted glasses have come
off a bit. The dev experience can be slow even on a decent MacBook, and the
language has its own gotchas if you deeply nest type inferences.

But it still beats Obj C by a longshot.

------
abhpan27
Swift. Even after going through the pain of migrating from swift 2 to swift 3.

------
st3fan
Objective-C is a dead end. Swift.

~~~
benguild
Not 100% true. There are tons of apps in Objective-C that have been around for
years and the support continues.

~~~
pjmlp
There was only one Objective-C presentation at WWDC 2016, the content was
related to improvements done for better Swift interoperability.

Also Apple is very clear about that in their documentation.

------
IBalic
Definitely Swift. But: 1) If you plan to develop a SDK/lib compatible with
both Obj-C and Swift and don't want to adapt to new Swift changes coming
forward or 2) You absolutely can't stand SourceKit related bugs in XCode
happening now and then.

then consider Obj-C.

Would go pretty far to use Swift over Obj-C anyway, so I can deal with both 1)
and 2) and still use Swift. It will just get better, so probably best to go
Swift sooner than later.

------
bsaul
Swift unless : 1/ you're working on a very big project ( 3/4 ios dev working
on the app for a year full time) And 2/ all the members of your team are
already fluent with objc

Then, it's debatable, whether you bet on the swift tool suite to fix all the
compiler crashes and compile time issues before your code base reaches the
critical point.

------
gt2
I like Swift after using Objective-C for many years, and most agree. As others
have said, I don't see much new code coming from Apple or anyone else in
Objective-C.

Also note that it's trivial to manually convert small blocks and idioms from
Objective-C to Swift.

And that you can include Objective-C libraries and classes/files and call them
from Swift.

------
bsvalley
There is no good or bad answer. Here is how I'd pick a language:

Swift \- Do I want to attract young developers in a near future? Do I value
awesome user interface over app stability?

Objective-c \- Am I looking to collaborate with Sr. developers? Do I need
tones of support and documentation on the Web?

Other than that, it really doesn't matter even in 2017.

------
soulchild37
I am still coding with Objective-C for production apps. Random SourceKit crash
on Xcode causing auto-complete to go haywire impede productivity especially
you are in the flow.

And to adapt to new syntax whenever a new Swift version come out... is painful

------
36bydesign
Not just swift, specifically Swift 3.0 since it will stay stable. Some
libraries haven't caught up but worst case you spend three hours manually
updating lines the converter couldn't figure out.

------
HunterRoach
Swift for your own code. Choose ObjC for any 3rd-party frameworks and
libraries otherwise you risk being stuck waiting for them to be fixed when
swift is upgraded.

------
tomvon
React Native

~~~
breeny592
Hidden option number 3!

Doing some playing with react native at the moment and can say it's refreshing
(although Swift is nice to use, especially compared to the bloat that is Java
for Android)

------
pensatoio
100% swift.

------
eridius
Definitely Swift.

------
proyb2
Swift and new features will be coming to Swift 4 and 5. What more learn how
Bitcode can really improve apps and others.

------
joejohnson
Swift

------
supercoder
C or Perl

