fabián cañas



I have not found Xcode's Playgrounds useful. I desperately want them to be good, and I'm still excited about their future. I spent years working in interactive environments like MATLAB, Mathematica, and R. Beyond a REPL, the kind of notebook-style development those environments afford are excellent for exploring algorithms and data. They truly make play out of programming, mathematics, modeling, even prototyping.

Playgrounds seem to be useful for doing basic demonstrations of the Swift language. They are also suitable for exploring algorithms, or the type system and generics. But nearly every time I've tried to do real work, I've failed to use Playgrounds productively.

I think playgrounds could be a fantastic interactive environment some day. They may never be as powerfully interactive as MATLAB or Mathematica. They may never have the scientific and engineering packages those environments have. But they don't have to.

I want Playgrounds to work for me because I like writing software component-by-component in minimally necessary environments. That usually means writing libraries with well-defined interfaces that drive a minimal harness application that exercises and demonstrates the functionality of the library. But that approach brings with it a certain overhead — libraries and a harness application. If the component isn't going to be reusable, those artifacts are mere side-effects of my development with little value on their own. Playgrounds appeal to me because they may some day be the place I write all code before integrating it into an application. No more harness applications.

In the mean time, Playgrounds fall short.

I tried to use Playgrounds to prototype some tricky code for RandomRun. The app requires some fairly elaborate route processing and route drawing. Apple's Maps framework appears to load but does not work in Playgrounds. So I made a harness app.

On another project I needed to write custom CoreImage kernels. I was excited to relive days from years ago being incredibly productive writing image processing code in MATLAB. But CoreImage doesn't work in Playgrounds. So I made a harness app.

On top of this, Playgrounds get incredibly slow as they grow.

But I'm not giving up yet. I'm excited to see what future releases bring.

I hope to be able to load external frameworks into Playgrounds soon. It could lead to an explosion of cool uses for Playgrounds. They could be used as powerful notebook environments with tons of third-party libraries like MATLAB and Mathematica (not to mention diving into new vendor-provided libraries). With an inline testing framework, Test Driven Development could be pushed to the extreme with a local, focused suite of unit tests executing every time you change a line of code. Or maybe Playgrounds could become the de facto medium for demonstrating and trying out third-party libraries.

I would also expect that loading external resources (images, videos, sounds, etc) into Playgrounds will become easier. Currently, it's possible but an unfortunately complicated, manual process. The only way I'm aware you can add resources is to put files directly into the Playground's bundle. Playgrounds ought to have support for asset catalogs like apps do. It would also be great if Playgrounds could fetch, save, and load data freely between the network and file system.

Playgrounds offer a teasing glimpse of an accessible direct-manipulation computing platform might look like. But it hasn't delivered yet.