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
66 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
66 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
66 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
66 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
66 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
66 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

apple transfer google photos 1

Apple Launches Service for Transferring iCloud Photos and Videos to Google Photos

Wednesday March 3, 2021 12:04 pm PST by
Apple this week introduced a new service that's designed to make it quick and easy for iCloud users to transfer their stored photos and videos to Google Photos. As outlined in an Apple support document, you can go to Apple's privacy website and sign in to see the "Transfer a copy of your data" option. If you select this and go through all the steps, Apple will transfer your iCloud photos and ...
rosetta 2

Rosetta May Be Removed From M1 Macs in Some Regions on macOS 11.3

Tuesday March 2, 2021 5:20 pm PST by
Installing the upcoming macOS 11.3 software update on an M1 Mac may result in Rosetta 2 being removed in one or more regions around the world. In the third beta of macOS 11.3 seeded to developers for testing today, MacRumors contributor Steve Moser uncovered new strings in the beta's code indicating that "Rosetta will be removed upon installing this update." Another new string reads "Rosetta ...
Screen Shot 2021 03 03 at 11

MagSafe Charging Port for iPhone Appears in Apple Patent

Wednesday March 3, 2021 1:30 am PST by
In a newly granted patent, Apple envisions a type of connectivity port using an iteration of its magnetic MagSafe charger to charge an iPhone, potentially paving the way for a future without Lightning. Submitted to the United States Patent and Trademark Office on Tuesday (via Patently Apple), the patent outlines a three-pinned MagSafe charger, similar to the ones found in older MacBook...
Oled iPads and MackBook Pro

OLED 10.9-Inch iPad Rumored for Early 2022, 12.9-Inch iPad Pro and 16-Inch MacBook Pro Could Follow

Thursday March 4, 2021 8:37 pm PST by
Earlier today, DigiTimes shared a preview of an upcoming report claiming that Apple is working on both iPad and Mac notebook models with OLED displays that could launch starting in 2022. The full report from DigiTimes is now available, and it includes several new alleged details about Apple's plans. According to the report, the first of these devices to adopt an OLED display is likely to be...
OLED iPad Pro and MacBook Pro

iPad and MacBook Models With OLED Displays Rumored to Launch in 2022

Thursday March 4, 2021 8:19 am PST by
Apple plans to release new iPad and MacBook models with OLED displays in 2022, according to industry sources cited by Taiwanese supply chain publication DigiTimes. The information was shared in the site's paywalled "Before Going to Press" section, so there are no further details yet, but the full report should be released by tomorrow. Apple has gradually increased its adoption of OLED...
iPad mini pro feature

Sketchy Rumor Claims 'iPad Mini Pro' Launching in Second Half of 2021

Wednesday March 3, 2021 3:04 am PST by
Apple is expected to launch a sixth-generation iPad mini in the first half of 2021, possibly as soon as this March, based on long-standing rumors. However, a new rumor out of Asia that has gained traction in the last 24 hours suggests an "iPad mini Pro" will arrive in the second half of this year. According to a post on Korean blog Naver, whose rumor track record is unknown, the device...
maxresdefault

What's on Your iPhone Home Screen?

Thursday March 4, 2021 10:31 am PST by
Over on our YouTube channel, MacRumors videographer Dan has a new video up where he shares his Home Screen, wallpaper, and all of his current favorite widgets. Subscribe to the MacRumors YouTube channel for more videos. Check out Dan's video to see his setup, and then comment below and show us your own Home Screens. It's always fun to see other peoples' Home Screens, and with widgets and...
apple pencil 3 leak

New Apple Pencil Allegedly Leaks With Glossy Finish and Redesigned Tip

Wednesday March 3, 2021 6:17 am PST by
Images supposedly depicting a third-generation Apple Pencil have been shared on Twitter by the leaker known as "Mr. White." The purported new Apple Pencil appears to share a very similar design to the current, second-generation Apple Pencil, which is shorter than the previous version and charges inductively on the side of an iPad. The updated Apple Pencil appears to have a glossy...
apple watch ecg wrist

Apple Watch ECG Feature Gets Approved in Australia

Wednesday March 3, 2021 2:07 am PST by
The Australian government has approved ECG functionality on the Apple Watch, giving Apple the all-clear to launch the feature for Apple Watch users in the country, according to a regulatory document first spotted by The 8-Bit. Earlier last month, the Apple Watch's irregular heart rhythm notification received approval in Australia, although ECG did not. Irregular heart rhythm is a feature...
PIA23764 RoverNamePlateonMars web

NASA Mars Perseverance Rover Uses Same PowerPC Chipset Found in 1998 G3 iMac

Tuesday March 2, 2021 3:21 am PST by
NASA's Perseverance rover, which recently made history landing on the surface of Mars, is powered by the same processor used in an iMac more than 23 years old. Image Credit: NASA As reported by NewScientist (via Gizmodo), the rover includes the PowerPC 750 processor, the same chip used in the G3 iMac in 1998. The main chipset is the same; however, there are differences between the...