swift.pngApple today announced that its Swift benchmark suite is open source, just over two months after making its Swift programming language open sourced as promised at the 2015 Worldwide Developers Conference.

Apple's Swift benchmarking suite is designed to track Swift performance with 75 benchmarks that cover multiple important Swift workloads, libraries with commonly needed benchmarking functions, drivers for running benchmarks and displaying performance metrics, and a utility for comparing benchmark metrics across multiple versions of Swift. The Swift benchmark suite is available on GitHub.

Introduced in 2014 and launched alongside iOS 8 and OS X, Swift is Apple's programming language built for iOS, OS X, watchOS, and tvOS, designed to work with Cocoa and Cocoa Touch frameworks along with Objective-C while also being widely accessible. In 2015, Apple debuted Swift 2 with new features like advanced error handling and syntax enhancements.

Top Rated Comments

GenesisST Avatar
73 months ago
From what I heard the only app that's written in Swift by Apple is the calculator app. So, I think it'll be decade before it really catches on like you said.
Well, you don't rewrite an app because there's a new language, Maybe calc was chosen as a proof of concept.

At my company, all apps are obj-c and will remain so for the foreseeable future.

Maybe new UI could be written in swift, for the hell of it. Maybe it's like what they say about going black... :-)

Keep in mind that this C++ guy accepted to move a legacy app to ARC about a year or so ago. (I don't regret that at all now!)
Score: 2 Votes (Like | Disagree)
ghost187 Avatar
73 months ago
Well, you don't rewrite an app because there's a new language, Maybe calc was chosen as a proof of concept.

At my company, all apps are obj-c and will remain so for the foreseeable future.

Maybe new UI could be written in swift, for the hell of it. Maybe it's like what they say about going black... :)

Keep in mind that this C++ guy accepted to move a legacy app to ARC about a year or so ago. (I don't regret that at all now!)
Well from what I hear, coding with Swift takes considerably less time, and developers have nothing but good things to say about it.
Score: 1 Votes (Like | Disagree)
akac Avatar
73 months ago
All of our new code is Swift. Now we have a huge app - so its going to be a long time before we are anywhere close to most of it being Swift. But I've been doing all new code since about 6 months ago in Swift, and my other engineers only the last 2-3 months. Swift makes so many things better, we'd love to sit down and convert existing code to Swift…but there is little point unless we hit upon a good reason.
Score: 1 Votes (Like | Disagree)
Krevnik Avatar
73 months ago
It's not as bad as with Java. For example there are nice structs, which Java doesn't have IIRC. But I don't like the casting required everywhere:

<snip>

So all these good Swift things kinda get in the way and I don't like how the code looks, either.
These are all signs that you are trying to bend the language to a particular way of doing things rather than actually doing things in the language. A couple things to point out in the code you wrote:
- Using C-style enumeration rather than the range enumerator, and not specifying a type for "i", which would help with the casting behavior. Swift defaults to the default int size of the platform if you don't.
- Using a buffer rather than just letting the array size itself appropriately to fit the content (pre-sizing is a minor optimization).
- Should be using Character or UnicodeScalar instead of UInt8. Swift doesn't assume that you are in ASCII-land, which is part of your trouble. Since you are writing code to fill a character buffer, but not actually using characters, but ASCII.
- Instead of enumerating the array, you create an unsafe pointer and do another C-style loop. This is the worst way to iterate through an array you already have.
- Why even use a buffer like this when a String can be sliced up and converted into the UnicodeScalars if you need the underlying value. You can also create slices of arrays if you want to only pass around a piece of an array (circular buffers for example).
- While UnicodeScalar and Character are somewhat incomplete if you need the ability to do math on the underlying value, you can always add them as operators to make the code doing the manipulation cleaner rather than keeping values that don't represent what you are actually working with.

For grins, I wrote up a version of the sample code you wrote using UnicodeScalar. Either way it is a bit contrived as the real solution will depend on how these things interact with the rest of the program. It also avoids extending array (which it should) for printing the hex values, which does require a few steps to get it right.


func +<T:UnsignedIntegerType>(lhs: UnicodeScalar, rhs: T) -> UnicodeScalar {
return UnicodeScalar(lhs.value + UInt32(rhs.toUIntMax()))
}

func printArrayAsHexValues(buffer: [UnicodeScalar]) {
for element in buffer {
print(String(format: "%@ = 0x%X", String(element), element.value))
}
}

var startChar = UnicodeScalar(65)
var characterBuffer:[UnicodeScalar] = []
for offset : UInt32 in 0...9 { // Range is inclusive
characterBuffer.append(startChar + offset)
}

printArrayAsHexValues(characterBuffer)


This code has the advantage of being easier to read, clearer behavior, and the customizations are actually reusable. Again, this isn't really code I'd actually write in Swift in practice, since I'd either be using an integer buffer for raw data (possibly an NSMutableData if on Apple platforms), and a string for a character buffer.

One of the other issues with Swift is that the standard library is woefully tiny. You basically have to marshal out to a framework, and AppKit/UIKit/GCD are first class citizens, while the POSIX APIs are very much not.

But the code you wrote suggests someone with a strong C background, possibly spending a lot of time in low level code, and not having spent much time with Obj-C, Python, C# or other modern languages used in app and tool development.

Honestly, swift is something you need to dig into, and unfortunately, if you are doing so off an Apple platform, the frameworks just aren't there to support a rich experience. And even if you are on an Apple platform, AppKit and UIKit prevent certain features of Swift from being used to their full potential because you can get more functional programming styles done in Swift, but then things like CoreData rip you back into the world of reference types of multi threading hell that results.

As for the comment of the GP that comments about efficient coding techniques, those are the same techniques that create crashes, security holes and other fun. All for the opportunity to maybe outsmart the compiler, when in many cases, bugs I've run into are because someone tried to outsmart the compiler, and got bit later because it forced the compiler into undefined parts of the C spec, or it actually prevented the optimizer from finding an even faster optimization because mucking with the pointers turned the whole process into something opaque.
Score: 1 Votes (Like | Disagree)
badNameErr Avatar
73 months ago
2) mixing languages in an existing project makes it too complex
What problems are you encountering with this?
Mixing ObjC/Swift in the same project works great even with my huge decade+ old OSX code bases!
Score: 1 Votes (Like | Disagree)
CFreymarc Avatar
73 months ago
Introduced in 2014 ('https://www.macrumors.com/2014/06/02/apple-ios-8-sdk/') and launched alongside iOS 8 and OS X, Swift is Apple's programming language built for iOS, OS X, watchOS, and tvOS, designed to work with Cocoa and Cocoa Touch frameworks along with Objective-C while also being widely accessible. In 2015, Apple debuted Swift 2 ('https://www.macrumors.com/2015/06/08/apple-announces-swift-2-open-source/') with new features like advanced error handling and syntax enhancements.

Article Link: Apple Open Sources Swift Benchmark Suite ('https://www.macrumors.com/2016/02/08/apple-open-sources-swift-benchmark-suite/')
I'd like to see an adoption graph of Swift since its release. For example, how many app submitted to the store are written in Swift vs. Objective-C on a month-to-month trend. I somehow feel an Apple employee is reading this with that exact graph in an other window on their desktop they wish they could release.

First, they announce it out of the blue at WWDC 2014. Then real quite the first year with many complaining about a buggy compiler. Then WWDC 2015, it goes open source to a rumored very soft acceptance. Now the benchmark tools are open source.

I'm still running into a lot of firms with a "No Swift" development policy because:

1) many say it is an immature language
2) mixing languages in an existing project makes it too complex
3) a catch-22 of few with Swift experience but few willing to commission projects in the language

This reminds me of the early Java days in the 90's where it took almost ten years for it to really take off in the industry.

One place I'm seeing Swift adopted well is in Frameworks development where many new APIs are written in Swift. Then these Frameworks integrate into apps written in Swift or Objective-C.
Score: 1 Votes (Like | Disagree)

Top Stories

calculatorapp

iOS 11 Bug: Typing 1+2+3 Quickly in the Calculator App Won't Get You 6

Tuesday October 24, 2017 2:03 pm PDT by
A bug in the built-in Calculator app in iOS 11 is getting some major attention this week, despite the fact that it's been around since iOS 11 was in beta testing. At issue is a calculator animation that causes some symbols to be ignored when calculations are entered in rapid succession. You can try it for yourself: Type 1+2+3 and then the equals sign into the Calculator app quickly. Due to...
gradiente iphone white

Brazilian Electronics Company Revives Long-Running iPhone Trademark Dispute

Tuesday May 19, 2020 1:06 pm PDT by
Apple has been involved in a long-running iPhone trademark dispute in Brazil, which was revived today by IGB Electronica, a Brazilian consumer electronics company that originally registered the "iPhone" name in 2000. IGB Electronica fought a multi-year battle with Apple in an attempt to get exclusive rights to the "iPhone" trademark, but ultimately lost, and now the case has been brought to...
iPhone 13 Dummy Thumbnail 2

Full iPhone 13 Feature Breakdown: Everything Rumors Say We Can Expect

Tuesday August 31, 2021 7:50 am PDT by
With the launch of Apple's iPhone 13 lineup believed to be just a few weeks away, we have compiled all of the coherent rumors from our coverage over the past year to build a full picture of the features and upgrades coming to the company's new smartphones. For clarity, only explicit improvements, upgrades, and new features compared to the iPhone 12 lineup are listed. It is worth noting that...
original iphone

Phil Schiller Says iPhone Was 'Earth-Shattering' Ten Years Ago and Remains 'Unmatched' Today

Monday January 9, 2017 7:15 am PST by
To commemorate the tenth anniversary of the iPhone, Apple marketing chief Phil Schiller sat down with tech journalist Steven Levy for a wide-ranging interview about the smartphone's past, present, and future. The report first reflects upon the iPhone's lack of support for third-party apps in its first year. The argument inside Apple was split between whether the iPhone should be a closed...
iPhone 13 Dummy Thumbnail 2

Kuo: iPhone 13 to Feature LEO Satellite Communications to Make Calls and Texts Without Cellular Coverage

Sunday August 29, 2021 7:39 am PDT by
The iPhone 13 will feature low earth orbit (LEO) satellite communication connectivity to allow users to make calls and send messages in areas without 4G or 5G coverage, according to the reliable analyst Ming-Chi Kuo. In a note to investors, seen by MacRumors, Kuo explained that the iPhone 13 lineup will feature hardware that is able to connect to LEO satellites. If enabled with the relevant...
maxresdefault

New MacBook Pro Models Coming at WWDC, Suggests Leaker

Monday May 24, 2021 1:27 pm PDT by
New MacBook Pro models are coming at WWDC, according to leaker Jon Prosser who has a mixed track record when it comes to predicting Apple's plans. Subscribe to the MacRumors YouTube channel for more videos. Prosser provided no additional information, but there are new 14 and 16-inch MacBook Pro models in the works. The new MacBook Pros will feature the most radical redesign to the MacBook Pro ...
omg lightning cable comparison

Security Researcher Develops Lightning Cable With Hidden Chip to Steal Passwords

Thursday September 2, 2021 6:59 am PDT by
A normal-looking Lightning cable that can used to steal data like passwords and send it to a hacker has been developed, Vice reports. The "OMG Cable" compared to Apple's Lightning to USB cable. The "OMG Cable" works exactly like a normal Lightning to USB cable and can log keystrokes from connected Mac keyboards, iPads, and iPhones, and then send this data to a bad actor who could be over a...
iphone 12 colors 2021

iPhone 12 Colors: Deciding on The Right Color

Thursday November 5, 2020 8:35 am PST by
The iPhone 12 and iPhone 12 Pro arrived last October in a range of color options, with entirely new hues available on both devices, as well as some popular classics. The 12 and 12 Pro have different color choices, so if you have your heart set on a particular shade, you might not be able to get your preferred model in that color. iPhone 12 mini and iPhone 12 The iPhone 12 mini and iPhone 12...
Top Stories 75 Thumbnail

Top Stories: Last-Minute iPhone 13 Rumors, Apple Announces App Store Changes, and More

Saturday September 4, 2021 6:00 am PDT by
The finish line is in sight! Apple's annual iPhone event is likely just a week or so away and all eyes will be on the company as it unveils the next version of its most popular product line. With any luck, we'll also see the next-generation Apple Watch and perhaps even some new AirPods. Other news this week saw Apple making some more changes to its App Store policies in response to a...
M1X MBP Feature

Leaker: Upcoming MacBook Pro to See Price Hike Over Current Model, Equal Performance Across 14 and 16-Inch Sizes

Tuesday August 24, 2021 5:28 am PDT by
The upcoming 14-inch MacBook Pro is set to be more expensive than the current 13-inch MacBook Pro and both the 14 and 16-inch models will offer the same performance, according to the leaker known as "Dylandkt." The leaker shared the information on Twitter, explaining that both of the upcoming MacBook Pro models, expected to come in 14 and 16-inch sizes, will feature the same performance due...