Slashdot Mirror


7 Swift 2 Enhancements iOS Devs Will Love

snydeq writes: InfoWorld's Paul Solt outlines how Apple has made good on Swift's emphasis on performance, approachability, and ease in its latest update, offering up seven worthwhile enhancements to Swift 2, along with code samples. 'Many of the enhancements to Swift, through both the Swift 2.0 update and subsequent Swift 2.1 update, have made the language more explicit and intentional, and in turns, Swift 2 code will be safer and easier to maintain for years to come (especially now that Swift is open source). New language constructs (keywords) in Swift 2 improve the readability of control flow — the order in which lines of code are executed. Thanks to these new keywords, collaborating on Swift code will be much more productive and efficient.'

2 of 123 comments (clear)

  1. Re:Next year by Dutch+Gun · · Score: -1, Troll

    I read the first item ("guard" keyword) a couple of times, and I'm still having trouble figuring out what it does that a simple "if" statement doesn't do. It is just syntactic sugar for the if statement, but used to indicate precondition checks? I feel like I'm missing something obvious.

    Defer keyword... interesting idea. C++ has destructors, but in many cases, if the object isn't already wrapped up, it's a lot of boilerplate code to do so. Still, for most of the daily work I do, I'm not dealing with raw handles, so I'm much better served with simple destructors. It would be pretty handy if I were writing a lot of C-style code - could replace a lot of those ugly goto statements used to do end-of-function cleanup.

    do...repeat. Sigh... figure this stuff out before version 1 of the language guys. One of C/C++'s strengths is that it's an incredibly stable language. Code written 25 years ago still compiles just fine today. Breaking changes at version 2 doesn't bode well for future stability.

    Apple has also revamped all of the Objective-C APIs that required NS_OPTIONS values to use the new OptionSetType. This causes breaking code changes, but continues to move Swift’s syntax forward along with the APIs that it supports.

    Well, maybe Apple can get away with this. Mmmm... koolaid...

    --
    Irony: Agile development has too much intertia to be abandoned now.
  2. Swift is making Rust obsolete already! by Anonymous Coward · · Score: 0, Troll

    The most critical thing to understand about Swift is that it's rendering Rust completely obsolete.

    Rust was trying to fill the niche between C and C++ on one side, and C# and Java on the other. Rust wants to be low-level, but it also tries to be high-level, too, and without the VM baggage that Java and C# bring.

    But now Swift has come along, and it fits much better than Rust does. Unlike Rust, Swift is a developer-friendly language. It's not there to force an ever-changing "right way" on programmers, like Rust tends to. For example, Rust's supporters tell you that "inheritance is bad, you should use composition" even when the tool you need is inheritance, and if you question them they essentially tell you to fuck off. Swift, on the other hand, provides real OO, and it's a pleasure to use.

    Now that Swift is open source and is going cross platform, the few benefits of Rust are dwindling away to nothing. It's even more important to note that Apple is backing Swift, while Mozilla is backing Rust. As anyone who follows the industry knows, Apple is wildly successful and innovative, with a bright future ahead of it. Mozilla, on the other hand, has been struggling lately. Users are rapidly fleeing Firefox, the only real product Mozilla has these days. Mozilla has also had its share of internal turmoil, especially with how the best CEO Mozilla ever had was forced out merely because of his beliefs about marriage, of all things. I have much more faith in an Apple-sponsored language being around in 5 or 10 years than I do in Mozilla itself surviving that long.

    Mozilla, if they have any sense, would strongly consider dumping Rust in favor of Swift. Swift is the language they need for their Servo browser engine, even if they don't realize it yet. Swift is the future, and Rust is a failure.