r/iOSProgramming • • Jun 04 '14

Apple Wants Devs To Love Swift, Its Shiny New Language—But There's A Catch

http://readwrite.com/2014/06/04/apple-swift-programming-language-wwdc#awesm=~oGf2uWdKZsfRbt
2 Upvotes

12 comments sorted by

4

u/mkrupinski13 Jun 04 '14

How important will it be to learn Objective-C if Swift takes off?

9

u/derpasoreass Jun 04 '14

Important for a long time. The sheer bulk of 3rd party libraries, tutorials and general knowledge base in Objective-C aren't going away any time soon

0

u/[deleted] Jun 05 '14 edited Jun 05 '14

3rd party libraries in Objective-C is irrelevant: you can access Objective-C code directly from Swift without having to drop down to Objective-C.

Objective-C tutorials age very badly: you're taking a risk if you use one older than a year. Same with tutorials for Cocoa and the other APIs. Neither Objective-C nor the APIs are stable (in the sense that they change significantly with each release).

Ditto the 'general knowledge base in Objective-C' and for the same reason.

0

u/[deleted] Jun 05 '14 edited Jun 05 '14

it depends.

If you are working on a large code base of Objective-C then yes you will need to learn that.

However if you are doing greenfield development or, like me, coding for pleasure then skip Objective-C and go straight to Swift: even with its slightly bizarre design choices it's a huge improvement over Objective-C.

And, of course, the change few people have noticed that I think will have by far the biggest impact is that Swift supports functional programming. Once idiomatic Swift matures it will be much, much more concise and elegant than Objective-C: and quite different.

I posted an example [here] (http://www.reddit.com/r/learnprogramming/comments/277xiv/then_all_ios_7_books_are_obsolete_with_swift/chyz5qz).

The main downsides are:

  • very limited learning material.

  • whilst it's mostly straightforward to convert Objective-C to Swift -so API materials are still useful- there are a few tricky edge cases.

  • Swift and XCode6 are both in beta and there are some bugs and missing features (for example Swift does not yet support class (type) properties) and there are some strange design decisions in Swift that I hope get fixed before it's finalised.

12

u/stcredzero Jun 04 '14

This entire article seems to be written by someone who doesn't understand the implications of Swift not only natively targeting the Obj-C runtime, but existing entirely to target it. The comparison with RubyMotion breaks down, because Ruby is a foreign ecosystem with a somewhat foreign conception of Object Oriented. (Only somewhat. Both of them owe a lot to Smalltalk. But the long absence of Blocks from Obj-C combined with class and header files changed the flavor of Obj-C's OO.)

Basically, Swift is facing an entirely different set of obstacles. Instead of trying to target Rubyists and make them happy on the Obj-C runtime, they are targeting Obj-C programmers and trying to make them happy there.

2

u/[deleted] Jun 05 '14

Exactly. You get articles like this when a blogger learns programming at a bootcamp for 3 months and start analyzing developer platforms.

1

u/[deleted] Jun 06 '14

I think the bigger miss is not understanding the new language features, especially the functional ones. The type system and pattern matching comes to mind. It's silly for the article to call it a 1st party RubyMotion analog.

0

u/stcredzero Jun 06 '14

Agreed. Those two features are actually a bigger deal than anything else! (Improved performance is nice, though. And better block syntax is quite important too.)

2

u/[deleted] Jun 06 '14

Speed improvements aren't a given yet. I've seen some code that can perform a lot worse (certain loops using the generators and such). There are some very neat tricks that the compiler can pull though (specializing generics, etc.), but does make debugging retail builds more of a pain.

9

u/Legolas-the-elf Jun 04 '14

Essentially, Apple is wagering that Swift will save enough time and effort that it might encourage more developers try their hand at building iOS apps. So Apple would clearly like to see developers learn and adopt Swift—well, swiftly.

I see no indication that this is the case. Even if Swift were as difficult for newbies to learn as Objective-C, it would still be a massive step forward.

The trick here is that this kind of interoperability basically has to work perfectly for Swift to succeed. If it doesn't, then developers will still need to tinker with Objective-C to make their apps work

Firstly, this is not true. For instance, Objective-C itself is a relatively thin layer on top of C, and plenty of Apple's APIs require developers to drop down to C. Yet Objective-C is still a success.

Secondly, Apple have a track record of something very close to perfection in this regard. For instance, when Apple introduced ARC, it interoperated with non-ARC seamlessly in the general case, with only a few minor areas where some developers needed to pay attention to the bridging. Likewise with things like toll-free bridging.

In some ways Swift is like an official Apple version of the RubyMotion experiment. It’s an easier language that interfaces directly with the Objective-C libraries and Cocoa and Cocoa Touch frameworks. But that means many—possibly all—Swift users are still going to need to know Objective-C.

I don't think that's likely. Apple are clearly positioning Swift to be a complete replacement for Objective-C for the average developer, and it seems very achievable to me.

5

u/arrowoftime Jun 04 '14

This piece is built from the idea that Swift is built on top of Objective C. In the short term, it's true that many of the frameworks and libraries are written in Objective C, and one could argue this. However, they are both compiled languages, and it seems Apple fully intends to phase out Objective C in the long term.

The real problem, alluded to in the article, is that so many resources will continue to exemplify interacting with framework api's in Objective C syntax. A complete lack of familiarity with Objective C will be hard for new developers, especially those without a background in C/C++, to read old stack overflow threads and tutorials. However, this problem will quickly fade.

1

u/[deleted] Jun 05 '14

Pure fluff article.

It's based entirely on assumption. Not a single concrete example of something you can't do in Swift and would have to drop down to Objective-C for.