Slashdot Mirror


Swift: Apple's Biggest Achievement For Coders

GordonShure.com writes: Despite its publicity and hype being rather quiet by Apple standards, the Swift programming language has attracted praise since its release last year. Swift is one of the few Apple products that represent a departure from the hardware-led Steve Jobs approach to the business. If this year's survey of coders by Stack Overflow is anything to go by, it looks as if the language might have potential to really shake things up in a landscape which has been little changed since the 1990s. Might the days of Apple programmers relying upon objective C be numbered?

37 of 337 comments (clear)

  1. One more in a crowded field by TWX · · Score: 5, Insightful

    How's Swift's cross-platform suitability?

    There are two Apple platforms, one popular Google platform, one less-popular Google platform, plus Microsoft's platform. Is Swift suitable for writing applications for all? If not, developers would be writing for a limited, albeit popular platform, but limited to a certain subset nonetheless.

    --
    Do not look into laser with remaining eye.
    1. Re:One more in a crowded field by Anonymous Coward · · Score: 2, Interesting

      No, and that's what Apple wants.

      Most developers will pick Apple over Android. Then you have to rewrite the code for Android. Apple will get first release on a lot of apps, just what they prefer.

    2. Re: One more in a crowded field by Anonymous Coward · · Score: 3, Informative

      Most developers? I don't know who you have been talking to or what you have been reading (maybe you work at Apple?), but the Android market share is much greater than the Apple market share. Plus it doesn't take much for a Java dev to turn his/her skills to Android, and C is the only language more popular than Java. In reality I doubt either platform will have issue finding developers.

    3. Re:One more in a crowded field by Lunix+Nutcase · · Score: 2
    4. Re: One more in a crowded field by ShanghaiBill · · Score: 3, Insightful

      the Android market share is much greater than the Apple market share.

      For phones, yes. For apps, no. The average iOS user buys far more apps than the average Android user.

    5. Re:One more in a crowded field by IamTheRealMike · · Score: 5, Interesting

      Is Swift suitable for writing applications for all? If not, developers would be writing for a limited, albeit popular platform, but limited to a certain subset nonetheless.

      No, it's Apple specific. However that's OK because there's a language which is much like Swift, except it runs on pretty much every device you might have.

      That language is new. It's called Kotlin, and it is from JetBrains, the makers of the highly popular IntelliJ series of IDEs (+ WebStorm, PHPStorm, RubyMine, PyCharm etc).

      Kotlin targets the JVM and JavaScript. It interops perfectly with Java. That means code written in it runs on Windows, Mac, Linux and Android. Additionally, via the RoboVM project, JVM bytecode can be compiled to native ARM iOS/OSX binaries. There is no JIT compiler. RoboVM provides bindings to all Objective-C APIs on iOS so you can build native UIs and access all the same functionality as a native app. Programs written this way are on the app store, so Apple is cool with the technique.

      Kotlin has a clean, concise syntax and many modern features that match those in Swift. For example it has nullability/optionality integrated with the type system. It has Markdown comments. It has extension functions. It has some support for pattern matching. It has named parameters. It has the ability to define "data classes" that have easy immutability, content equality, hashcodes, serialization etc all in a single line of code. It has type inference and compile-time inlined lambdas, so you can do high performance functional programming with it. It has features to support complex DSLs. It has a full IDE with many built in refactorings, online static analysis, and via the JVM it has high quality CPU/memory profilers and debugging support.

      In short, programming with Kotlin is much like programming with Swift, except you have better tools, an IDE at least as strong as Xcode and in my experience stronger, and you can write apps with it that are indistinguishable from native iOS and Android apps.

    6. Re: One more in a crowded field by Feral+Nerd · · Score: 5, Informative

      Most developers? I don't know who you have been talking to or what you have been reading (maybe you work at Apple?), but the Android market share is much greater than the Apple market share. Plus it doesn't take much for a Java dev to turn his/her skills to Android, and C is the only language more popular than Java. In reality I doubt either platform will have issue finding developers.

      He is talking about profit potential, not who's got his OS installed on the most devices. The implication is that iOS development is more profitable than Android development which is something that I have heard from more mobile developers than just him.

    7. Re: One more in a crowded field by unami · · Score: 4, Insightful

      whatever the reason may be, this still makes apple's platform more interesting for professional developers.

    8. Re:One more in a crowded field by gnasher719 · · Score: 2, Informative

      No, it's Apple specific. However that's OK because there's a language which is much like Swift, except it runs on pretty much every device you might have.

      Well, pretty much any device accept the odd iPhone here and there?

      Looks like they are trying to create a Swift clone. Excuse me, but I think I prefer the real thing. Which will quite soon run everywhere, unless Google throws its toys out of the pram. And which has the brains of LLVM behind it. And most importantly, which is in actual use. Maybe Swift will never be as good as Kotlin's claims, but Kotlin will never be as good as Swift.

    9. Re: One more in a crowded field by mfearby · · Score: 2

      We may not be able to prove that a particular app isn't spying on us, but I can state with a high degree of confidence that said app isn't installing spyware on my device!

    10. Re:One more in a crowded field by itsdapead · · Score: 4, Informative

      Is Swift suitable for writing applications for all? If not, developers would be writing for a limited, albeit popular platform, but limited to a certain subset nonetheless.

      Well, Apple just announced that they are planning to open-source Swift and will be also be releasing a Linux version of the compiler. So the language itself isn't going to be Apple-only for much longer.

      However, that only solves the language problem - the big divide between platforms is the totally different APIs that developers have to learn. Frankly, that's usually a bigger learning curve than picking up a new language.

      Mind you, you can say the same for most of the big languages - off the top of my head only Java (and maybe Javascript/HTML5) come with baked-in crossplatform APIs suitable for writing GUI applications.

      --
      In a survey of 100 programmers, 111111 thought that duck-typing was a good idea.
    11. Re:One more in a crowded field by mfearby · · Score: 2

      Exactly. I've grown tired of all these new languages that claim to be better than the real thing. You're far better of using "the real thing", and I've never liked IDEA as an IDE (mind you, I think XCode's code editor and workspace tabs suck, too, but I've learned to tolerate it).

    12. Re: One more in a crowded field by 0123456 · · Score: 2, Informative

      And Apple apps don't spy on you?

      How can you prove they don't?

      Well, for a start, you can deny them permissions when they try to do something you don't expect. When the Happy Kitty Screen Saver wants to access your camera and contacts on an Android tablet, you can't. You already had to accept 'let this app do random crap' when you installed it, or you wouldn't have been allowed to install it.

      As far as I'm concerned, Android isn't much use for anything other than a mobile web browser until it gets proper per-app permission controls.

    13. Re:One more in a crowded field by jblues · · Score: 2

      You can currently write Android apps in Swift with Apportable. Although Apple doesn't blow a whistle about this, most of the low-down parts of the stack are open-source. Moving up, Apportable have implemented in-house versions of Foundation, UIKit and so forth.

      In the coming months, Apple will be releasing Swift for Linux, though its not clear whether that will include Foundation and UIKit. If not I can see the Apportable ones possibly being open-sourced in the future.

      --
      If it acquires resources on instantiation like a duck, then its a shared_ptr<Duck>
    14. Re:One more in a crowded field by Chalnoth · · Score: 3, Insightful

      Just as with Objective-C, I doubt that hardly anybody else will make use of the language.

      The problem is it just doesn't have all that much to offer for projects that are already making use of other languages. It's got a few slick features, but it can't really stand out all that much and the library support is going to be very far behind more mature languages for a long time (if not forever).

    15. Re: One more in a crowded field by bigfinger76 · · Score: 2

      Wrong. The money is in the hardware; app developers don't get any of that.
      Quoting the article you linked:
      "The figures given here relate to profits generated by handset makers, not the services ecosystem and potential profits made by app publishers and others..."

    16. Re: One more in a crowded field by laird · · Score: 2

      QT gives you a "least common denominator" GUI everywhere. If your UX matters at all, you're better off writing a native GUI layer for iOS and Android, so your app doesn't suck compared to competitors.

    17. Re:One more in a crowded field by Anonymous Coward · · Score: 2, Informative

      Looks like they are trying to create a Swift clone. Excuse me, but I think I prefer the real thing. Which will quite soon run everywhere, unless Google throws its toys out of the pram. And which has the brains of LLVM behind it. And most importantly, which is in actual use. Maybe Swift will never be as good as Kotlin's claims, but Kotlin will never be as good as Swift.

      Kotlin has been released in 2011, so I don't think it tries to be a clone of Swift. It's more a "Java replacement", like Ceylon, Gosu or Fantom, which is not a bad idea when you have something like Oracle Corp which get to decide how to manage an open technology (Java...)

    18. Re: One more in a crowded field by SpaghettiPattern · · Score: 3, Interesting

      ... and C is the only language more popular than Java...

      Nitpicking here. I started with C nearly 3 decades ago, I switched to Java but I'd be able to pick up C again in a very short time. Large parts of large/huge systems I design in C structures as they provide a nice abstraction of the underlying hardware. No matter how much I like C, it's no longer number 1 when considering the number of programmers involved. It's "too technical" for application programmers. Considering that financial programmers push the numbers and that they are moving from COBOL to Java, I see Java as the COBOL of the future. The upshot is that Java is good enough to do almost anything and much more elegant than COBOL.

      --

      I hadn't the slightest objection to his spending his time planning massacres for the bourgeoisie... (P.G. Wodehouse)
    19. Re: One more in a crowded field by master_kaos · · Score: 3, Insightful

      And I have the exact opposite experience. We have 8x the usage on iOS vs android, and android users complain a lot more (some legit, some just outrageous requests)

    20. Re: One more in a crowded field by the_B0fh · · Score: 3, Insightful

      That's why the top 10 flashlight apps in the Android App Store all need access to networking, your SMS, mailbox, contacts, etc. "creative ideas for monetization" indeed.

    21. Re: One more in a crowded field by the_B0fh · · Score: 2

      Gee. One registered user, and one anonymous coward, each with direct opposite experiences.

      Who can I believe, who can I believe...

    22. Re: One more in a crowded field by shutdown+-p+now · · Score: 2

      This is more or less true for desktop platforms. But for mobile, the design you're expected to adhere to on different platform is sufficiently different (and not just in the way buttons look, but general layout and flow) that an app like that really sticks out like a sore thumb.

  2. Quiet schmiet, frosty already by Hognoxious · · Score: 5, Funny

    Despite its publicity and hype being rather quiet by Apple standards

    I haven't seen it mentioned on CNN or the BBC, but there's about a dozen stories about it per day on a former tech new website.

    In fact, it's pushed 3D printers off the number one spot.

    --
    Confucius say, "Find worm in apple - bad. Find half a worm - worse."
    1. Re: Quiet schmiet, frosty already by phantomfive · · Score: 2

      The value of static typing over dynamic typing, strong typing over weak typing, safe memory programming languages over unsafe memory programming language, etc. is becoming undeniable.

      Now you are dreaming.......have you looked at Javascript?

      --
      "First they came for the slanderers and i said nothing."
  3. Re:Yes, but it will be a while. by Lunix+Nutcase · · Score: 5, Informative

    Obj-C is on the way out.

    Uhh, no. So much of the system libraries on both OS X and iOS are written in Objective-C and they aren't going anywhere. Also, all the new APIs of iOS 9 and OS X 10.11 are still written in both C and Objective-C with Swift bridge headers. Basically, it's the opposite of what you claim.

    I'd guess that we're about a year away from the point where the majority new code at Apple is written in Swift.

    Maybe at the application level, but not for system libraries.

  4. Re:No by Anonymous Coward · · Score: 2, Informative

    And VB was a hugely popular language for writing business apps and one of Microsoft's best selling products.

  5. That survey is problematic... by antiperimetaparalogo · · Score: 4, Informative

    If this year's survey of coders by Stack Overflow is anything to go by, it looks as if the language might have potential to really shake things up in a landscape which has been little changed since the 1990s

    "Most Loved"

    • Swift 77.6%
    • C++11 75.6%
    • Rust 73.8%
    • Go 72.5%
    • Clojure 71.0%
    • Scala 70.6%
    • F# 70.1%
    • Haskell 69.5%
    • C# 67.2%
    • Python 66.6%

    "Most Wanted"

    • Android 17.7%
    • Javascript 15.4%
    • Python 14.8%
    • Node.js 14.6%
    • AngularJS 13.2%
    • Java 10.5%
    • iOS 9.4%
    • Arduino / Raspberry Pi 8.5%
    • Swift 8.5%
    • C# 8.0%
    --
    Antisthenes: "Wisdom begins by examining the words/names." - excuse my English, i am (slightly...) better with my Greek!
  6. Objective-C is now legacy - but not quite dead by CraigCruden · · Score: 2

    Swift in its first year has become the preferred language for developing on the Apple platform. Objective-C is being "improved" but only as a bridge to support interoperability with improvements that are being incorporated into Swift.

    There is a lot of Objective-C code that will have to be maintained, and over time it will be replaced with Swift code... but it won't disappear overnight. In a year all new development is likely to be done in Swift, while Objective-C is just maintained.

    Eventually -- in many years time as Objective-C code is revisited it will be phased out.... but it will be a very long time-frame.

    If you are starting development on a new application - you would have to be very short-sighted to pick Objective-C as a starting point.

    1. Re:Objective-C is now legacy - but not quite dead by CraigCruden · · Score: 2

      The difference is that .NET was developed and designed as an applications language with little regard to systems programming -- where the market .NET was aimed at was not replacing the language that was used for systems programming but providing an applications framework (more as a reaction to java than anything else).

      Swift was designed from the ground up to be as performant as Objective-C and as a replacement language for the language that they actually write the APIs in. In essence Swift is a systems language as much as it is an applications language. Swift is designed to be AS performant as objective-c, which means their is little benefit to move forward with a less productive language.

      The difference is that up until only recently there has been very very little new / competitive options in the systems languages area.

  7. Swift is (shortly) everywhere, including Linux by SuperKendall · · Score: 3, Informative

    In the keynote they announced Swift being open source later this year, including releasing versions for Linux...

    Having done over a decade of backend work in the past, I think it would make a pretty good server language also. It's all about the libraries and frameworks that support what you are trying to do.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  8. Meh by tylersoze · · Score: 2

    I don't know, most long time iOS developers I know, including myself, aren't really jumping all over themselves to adopt Swift. I mean the writing is on the wall obviously, and Apple will eventually drop Objective-C down the road, so we'll have to eventually adopt it. That's the attitude I'm seeing among people I know. Personally I don't particularly like it that much and it seems to be solving problems that don't need a solution, like fucking optionals. That said, there are features of the language I like but I wish they had just continued to develop and refine Obj-C, honestly just getting rid of the bracket syntax and adding some of the features from Swift would satisfy me. Apple characterizing Swift as "Obj-C without the C" couldn't be more wrong. It's more like "C++ without the C" or "Obj-C without the Small Talk"

    Most of the talk about Swift seems to be coming from people that aren't iOS developers and don't really have any idea what they're talking about.

  9. Re:Frustrating type conversions by 0123456 · · Score: 5, Interesting

    That would probably have prevented the annoying bug I ran into a few years ago where someone copied a 64-bit time_t to a 32-bit int, did some arithmetic, and then copied it back to a 64-bit time_t, requiring us to update firmware at all customer sites to fix it. If they had to explicitly convert, they'd almost certainly have realized they were doing something wrong.

    That bug alone probably cost us more money than the time required for programmers to always explicitly convert types.

  10. Okay, poll... by Chris+Mattern · · Score: 2, Insightful

    How much did Apple pay for this article?

  11. Re:Yes, but it will be a while. by jblues · · Score: 2

    Nearly everything?

    Aren't most things currently running in "managed" (with a Virtual Machine, and garbage collection) environment these days? Swift is interesting, in that, like Objective-C it uses Automatic Reference Counting (ARC) for memory management, along with a syntax that is appealing to younger developers. ARC gives almost all of the benefits of garbage collection, at the same time as being compiled in, so it doesn't require CPU clicks at run-time. For mobile this (which is where everything is going) this gives superior performance and battery life. I'd say we're moving in this direction, not away.

    --
    If it acquires resources on instantiation like a duck, then its a shared_ptr<Duck>
  12. Re:Frustrating type conversions by jeremyp · · Score: 2

    Trust me, when I assign a double to an int, I know I lose the mantissa. .

    Since it's actually the exponent you lose (and maybe also some or all of the mantissa depending on what the value of the exponent was), I really think you need to start using a language that gently reminds you that converting from a double to an int is not necessarily a trivial exercise.

    --
    All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
  13. Re: No by spongman · · Score: 2

    No, objective-c is apple's VB - a shitty language that everyone was more-or-less forced to use long ago if they wanted to use their platform (cocoa/office).

    I'd say swift is more like apple's C# - a modern language that everyone (including mocrosoft) wishes every VB/objc developer would switch to. Asap.