Apple's Swift not so swift after all

Programming language doesn't fare as well as Objective-C in some benchmarks, but Swift's easier syntax gets a thumbs-up

Apple cited speed as a key attribute of its Swift programming language when it was introduced last week. But developers who have independently run tests on the new language have found it lacking in performance in some instances.

Apple claimed that Swift outperforms Python when it comes to handling complex object stores and RC4 encryption. So Mac software builder Splasm Software decided to run benchmarks on the language to gauge how well Swift handles tight-looped and scalar data types and arrays.

Without leveraging optimizations in Apple's Xcode tool set, Splasm found that Swift was between six and 40 times slower than Objective-C, Splasm official Keith Gugliotto said. "What we were curious about was for the things that we do in-house, which is a lot of array work and a lot of working with these types of data, was Swift going to be as fast as Objective-C? In our tests, it wasn't."

Even after turning on the optimizations, Splasm found that Swift ran 10 to 20 percent slower than the original test numbers in some cases and 10 to 20 percent faster in other cases. But Swift was still slower than Objective-C. In another test, detailed on the Stack Overflow site for developers, a tester in Finland found that performance was slow when implementing an algorithm in Swift, with C++ and Python vastly outperforming Apple's fledgling language.

Gugliotto cautioned, however, that Splasm's benchmarks do not necessarily represent real-time application usage. "There's a heckuva lot more reasons to use a programming language than its performance," he said. "As long as the performance is relatively acceptable, if the language provides modern [capabilities] and at least allows you to develop quickly relative to other languages, that's a strong case for continuing to use it."

Gugliotto expects Swift's easier syntax will serve as enticement for its adoption, particularly among programmers who are not adept at building with the C language, which has served as a precursor to using Objective-C.

Swift features modern language capabilities, including closures, generics, multiple return types, and namespaces. The language is likely to live alongside Objective-C for years to come, Gugliotto said. "At some point Apple might pull the plug on Objective-C, and at that point we'll make the switch to Swift. [By then], I'm sure performance will be just fine."

This story, "Apple's Swift not so swift after all," was originally published at InfoWorld.com. Get the first word on what the important tech news really means with the InfoWorld Tech Watch blog. For the latest developments in business technology news, follow InfoWorld.com on Twitter.

Recommended
Join the discussion
Be the first to comment on this article. Our Commenting Policies