Swift for Data Science!

Ray Yamamoto Hilton
Eliiza-AI
2 min readApr 13, 2018

--

I have had the dubiously enlightening experience of using some terrible languages over the years, but in the last few, I’ve had the pleasure of learning Swift.

While I originally learnt Swift for iOS development, it has since been liberated from the Xcode and the Apple ecosystem and is able to run on Linux (and probably anywhere else LLVM can).

Like many people, I tend to be biased towards languages I already know when facing a new domain (*cough* react native *cough*) and so half-jokingly suggested we should try and use Swift for data science, rather than the incumbent Python.

And then, at the TensorFlow Dev Summit 2018, Chris Lattner (Author of LLVM, Clang and Swift) — announced Swift for TensorFlow — A first-class integration of TensorFlow APIs and concepts into Swift. Not only that, but there is also upstream work to add better dynamic language interop to Swift, so that using Python from within Swift is as seamless as possible.

So, feeling my personal bias had been validated, I started having a look for what equivalents for standard Python data science libraries (matlibplot, numpy, scipy, pandas, scikit-learn) there are for Swift.

  • Nifty (demo) — is a general-purpose numerical computing library for the Swift programming language, made with performance and ease-of-use in mind.
  • Surge — A Swift library that uses the Accelerate framework to provide high-performance functions for matrix math, digital signal processing, and image manipulation.
  • Swift-AI — Swift AI is a high-performance deep learning library written entirely in Swift.
  • swix (homepage) — Swift matrix and machine learning library

Have yet to find an equivalent for Pandas or Matlibplot, but I’m sure it’s just a matter of time.

--

--