Apple’s new Swift programming language tested: performs multiple times faster than Objective-C

Apple’s new Swift programming language tested: performs multiple times faster than Objective-C
Apple took the wraps off a brand new programming language at its WWDC 2014 conference, and it promised a much faster performance and a modern, streamlined syntax over the currently used Objective-C. And while that would sound like a dream to developers, Apple did not reveal much about the upcoming Swift language and actual compile performance tests.

In fact, we’ve seen early tests show how Swift is actually outperformed by Objective-C on many popular benchmarks. Luckily, we’re still in the beta phases of its development, and knowing the Apple way of doing things, we can expect the improvements to show fully only in the final one.

Now, however, the latest, optimized builds of Swift got tested, and while the early tests showed it was in fact slower than Objective-C on many occasions, these new results show a shockingly different picture. We’re seeing improvements of multiple times in sort operations, and it seems the magic stems from LLVM and Clang compiler optimizations.

Right below, you’d find the tables showing how the performance of Swift evolved to its current state in the latest optimized version, and how it compares to Objective-C. Take a look below.


source: Jesse Quires

FEATURED VIDEO

24 Comments

1. vincelongman

Posts: 5677; Member since: Feb 10, 2013

Wait isn't Objective-C already one of the fastest languages? I'm not a programer, sorry if wrong Anyway good job Apple! Cant wait to see their Metal API as well

2. JakeLee

Posts: 1021; Member since: Nov 02, 2013

Obj-C isn't bad, enabling OOP without bloating as much as C++.

10. sgodsell

Posts: 7190; Member since: Mar 16, 2013

Its not that Obj-C is bad. Its just that it is very limiting and not future proof. Apple swift is going to make all new apps for iOS and OSX be agnostic, and not be tied to any specific hardware. Something that Android has done from day one, and which helped it to grow to the state that its at today. The problem with compiling anything is you are locking it into a specific architecture. For low end hardware you can get a lot of speed by compiling it natively. But now you have lost portability. Apple had to do something like Android and using a virtual machine. Because even Google's Chromebooks are going to be able to run Android apps in the next month or two. So from phones, to tablets, to desktops, to notebooks. This is what even Microsoft is going to try with Windows 9. We all know that Apple phones and tablets can use the same apps, because they happen to use the same hardware architecture. But other Macbooks, or in general all the other Intel hardware can't run iOS apps. So Apple decided to use the same virtual machine route as Android. I remember Apple cutting up Android all the time in regards to it using a virtual machine. Look how the tables have turned. With the mobile processors getting faster and faster all the time, and with 64bit processing. Gone are the days that people have to worry about things running slow or laggy. Android hasn't been that way for years.

13. superduper

Posts: 151; Member since: Oct 20, 2013

Wait, what? Swift is a virtual machine? Even a quick glance at Wikipedia would show up some basic errors in your post.

16. sgodsell

Posts: 7190; Member since: Mar 16, 2013

Yes go to the Wiki.http://en.wikipedia.org/wiki/Swift_(programming_language) Notice the part about iOS and OSX. So Einstein how will an iPhone app running with Apples ARM A7 or newer A8 run the same apps on osX or vise versa? Just in case you didn't know osX runs on Intel processors and the iPhones are using ARM. They are NOT binary compatible processors. So Apple Swift is using a low level Virtual Machine (LLVM), just like Android. The only difference is Android was this way from day one.

17. superduper

Posts: 151; Member since: Oct 20, 2013

How is Apple's LLVM, released in 2003, copying VM-based Android, released in 2008? And why does Apple need to run a touch-based app developed for iOS on a desktop environment like OS X? You need to read up on language levels, frameworks, and APIs. OS X and iOS already share large amounts of code, but they are ultimately developed for two different purposes. This is not going to change just because Swift was released last June.

21. JakeLee

Posts: 1021; Member since: Nov 02, 2013

Well, he mistook that 'vm' part from 'llvm' for virtual machine. How can someone be so ignorant?

22. sgodsell

Posts: 7190; Member since: Mar 16, 2013

Now I can see why so many on here complain about you. Low Level Virtual Machine (LLVM). from the Apple Swift wiki follow the LLVM link.http://en.wikipedia.org/wiki/LLVM The LLVM compiler infrastructure project (formerly Low Level Virtual Machine) is a compiler infrastructure designed as a set of reusable libraries with well-defined interfaces. It is written in C++ and is designed for compile-time, link-time, run-time, and "idle-time" optimization of programs written in arbitrary programming languages. Originally implemented for C and C++, the language-agnostic design (and the success) of LLVM has since spawned a wide variety of front ends: languages with compilers that use LLVM include ActionScript, Ada, D, Fortran, OpenGL Shading Language, Haskell, Java bytecode, Julia, Objective-C, Swift, Python, Ruby, Rust, Scala,[3] and C#.[4][5] Notice the parts where Java, Objective-C, and Swift all use LLVM. Also how are you suppose to write an app for OS X and have it run on both OS X and iPhone? None of you answered me how that will work? Did you also notice the part about runtime? So we have two winners here showing their ignorance to the public. JakeLee and Superduper. Real Winners.

19. JakeLee

Posts: 1021; Member since: Nov 02, 2013

So much BS in a single post. VM sucks, especially Java. That's why 90% of top Android apps are written in C/C++ completely ditching Java.

4. dickwyn

Posts: 621; Member since: May 07, 2012

yeah objective-c is quite fast but the problem with swift and objective-c is that it's and apple kind of thing and with swift, developers will be locked down to the iOS platform due to the platform specific APIs like metal. Again, to iOS only devs, swift is an awesome new tool for them but for cross platform devs moving from java, objective-c and c# it really isn't that good of a idea.

6. Finalflash

Posts: 4063; Member since: Jul 23, 2013

That and we need more information about what is actually being tested and being tested on. The fluctuation from one table to the next is way too much and the only similar tables are 2 and 4. Assuming it is a linear progression from one table to the next time wise, they would have to be changing significant portions of the compiler from one table to the next until the 4th iteration where they decided to go back to iteration 2 for some reason even though 3rd iteration was faster. Looks weird, need more info.

20. 0xFFFF

Posts: 3806; Member since: Apr 16, 2014

"That and we need more information about what is actually being tested and being tested on." Exactly. The performance of the sorting methods that are being tested depends greatly on how array copies are made / not made during recursion. There is also lazy evaluation to take into consideration. My guess is that Apple cooked all their benchmarks and picked things that were faster in Swift due to various optimizations or faster in Swift due to a well implemented library being called (RC4).

15. superduper

Posts: 151; Member since: Oct 20, 2013

Swift is no more locked down than Obj-C is today for OS X/iOS development. Or C# and .NET for MS development.

7. LetsBeHonest

Posts: 1548; Member since: Jun 04, 2013

Yeah it is fast. And this will be awesome for all those Apple devices if this deliver what promised. Since iDevices are limited numbers (which is in a way good) and developers like to catch whatever Apple throws at them i can see this can be success for Apple

11. sgodsell

Posts: 7190; Member since: Mar 16, 2013

Apple had to go the virtual machine route. Because they created a locked down ecosystem that is tied to their specific Arm CPU's. Not good for growth or future proofing. Android can run on anything because from day one has used a VM, not to mention can run on notebooks, tablets, phones, watches, desktops, and more. Microsoft and Windows 9 is going to do the same thing when it arrives next year. Apple would be left behind if they didn't go the VM route. This will also allow them to run future iOS apps on macbooks or their Intel hardware as well.

24. Ppietra

Posts: 2; Member since: Aug 23, 2014

there will be no virtual machine. Nothing has changed and Apple has no problem with its CPU. Apple would have no big problem making apps run on both platforms. A lot of the code is compatible, the tools are the same, etc

3. kalloud

Posts: 155; Member since: Jun 21, 2012

What about the new art Java runtime in Android L?

5. JakeLee

Posts: 1021; Member since: Nov 02, 2013

Same crap as Dalvik.

9. JohnMilisis

Posts: 23; Member since: May 04, 2014

I m using ART on my nexus 5 and I see an overall improvement in any situation. Better battery life, faster experience etc.

12. sgodsell

Posts: 7190; Member since: Mar 16, 2013

Same crap eh? So why is Apple using a Virtual Machine like Google's Android then? Why because Apple made a bad decision in the past to lock itself into its specific ARM hardware. Can you run iOS apps on anything but Apples ARM hardware? Oh wait for it. That a big fat NO. Android has been running for years on all kinds of ARM CPUs, MIPS, and x86. Androids biggest saving grace that helped to future proof it was to make it agnostic, and NOT be tied to any specific hardware. Now Apple is trying to be like Google's Android. So Apple can run future iOS apps using Apple's swift on not only phones, tablets, but their macbooks and other hardware as well. Android can already do this today. JakeLee you can cut up Google all you want. But there is NO denying that Apple is once again going follow in Google's footsteps and use a Virtual Machine. Just like Android. So same crap. I guess it is the same crap as Android ;-)

18. Ashoaib

Posts: 3276; Member since: Nov 15, 2013

thats all what jakelee can say... android is crap, art is crap... bla bla... but apple is not crap even if they copy the same concept of android

23. Ppietra

Posts: 2; Member since: Aug 23, 2014

Where does it say that Apple will be using a Virtual Machine like Android? Do you say it because of LLVM? LLVM is a compiler not a virtual machine, you don’t run applications on it, though virtual machines might use it to compile applications from JAVA code - just in time compiler! LLVM has been Objective-C preferred compiler for the last 3 years and Apple has been using LLVM since 2005 Swift applications will be like Objective-C applications, they will be compiled with LLVM and run like all other applications till now. Apple doesn’t need a virtual machine if it wishes to make applications run on both platforms. It only needs to make all APIs compatible. After that it can package compiled code to run on its devices, just like it did when it changed from PowerPC processors to Intel processors. Objective-C and Apple’s tools already make it relatively easy to compile to different processors.

8. LetsBeHonest

Posts: 1548; Member since: Jun 04, 2013

It said to run android twice as fast than dalvik did. Also bring cross-platform support for ARM, x86, MIPS. And brings better garbage collection,better ram management, better graphics,64bit support, and backward compatibility with old apps they says no changes needed for existing apps . To me it seems like google did a sweet job with art. We can expect great performance improvement with Android L update

14. sgodsell

Posts: 7190; Member since: Mar 16, 2013

BTW Android has already had cross-platform support from day one, and supported a multitude of ARM processors, MIPS, and x86 for quite some time. I still have my Motorola Razr I which runs on a Intel Atom processor. That was back in 2012.

Latest Stories

This copy is for your personal, non-commercial use only. You can order presentation-ready copies for distribution to your colleagues, clients or customers at https://www.parsintl.com/phonearena or use the Reprints & Permissions tool that appears at the bottom of each web page. Visit https://www.parsintl.com/ for samples and additional information.