When I wrote my srly script I thought on doing it in Swift, but at the end I decided to go with a well known scripting language, Ruby.

After Ayaka’s talk in the Swift Summit I was really excited about writing some script in Swift, and I ported the original srly.rb script to Swift.

When porting the code to Swift I wanted to use the native Cocoa APIs to modify the original PLIST so the script could remove the links successfully downloaded. I was struggling a little at the begging because I wanted to write swifty code, but the fact that Swift arrays and dictionaries are structs was preventing me to accomplish that simple thing. At the end I’m using the Foundation NSArray and NSDictionary because of its reference semantics that allow me to mutate the dictionary and save it to disk.

I have to say that I’m really happy with the result and really excited to continue writing scripts in Swift. Having the convenience of the language and the power of Cocoa to write scripts it’s very cool. I hope that the rest of the community realizes that and that the creation of little gems for swift scripting starts to grow quickly.

srly.swift on GitHub