Planck 2

2017-06-05 Doudo.♪

Planck now supports Linux!

This capability owes its roots to Lucas Stadler who a started things off with a truly massive contribution which converted the bulk of the Objective C in Planck to portable C. With this effort, Lucas essentially got Planck running for the first time on Linux. Incredible!

Others who have helped with contributions to Planck 2 include Jonathan Leonard , Belaf , Ivan Kryvoruchko , and António Monteiro .

With these changes, Planck is now fairly portable. It can compile with either Clang or GCC, and works properly on a range of Linux distributions. It has even been built and run on the Raspberry Pi !

It is able to target both 32-bit and 64-bit boxes. The 32-bit capability is interesting in that it could provide a way to put a fast, lightweight ClojureScript REPL on older lower-end computers. I could see this being useful for children's educational outreach organizations like LoudounCodes .

If you'd like to build Planck on your favorite Linux disto it can be as simple as running script/build , but first check out the Building wiki page. It is essentially a cheat sheet with instructions for getting the build tooling and library dependencies set up on different distributions. Additionally, the Planck build tree has several Vagrant-based build environments that can be spun up to build Planck on different distributions.

Planck is still being distributed in binary form for macOS via Homebrew. For macOS it is still as simple as brew install planck . My hope is that we can get Linux binaries set up for the native distribution mechanism for the various popular Linux distros.

Some of the new features in Planck 2 were covered inPlanck Road Ahead.

Technical Background

Planck's implementation has always been splitroughly in two, with ClojureScript handling most of the REPL logic, and the native side handling most of the interaction with the OS. The main difference with Planck 2 is that the native half is now in C.

Interestingly, we took advantage of this split: For a while, the ClojureScript portion of Planck was simultaneously used for both the Objective C and C native portions. Planck releases 1.15 through 1.17 were made with the Objective C code, while the C version worked but was still being fully fleshed out until we could confidently ditch the Objective C.

In some sense, the ability to do all of this goes back to when David Nolen suggested that we take Ambly's native JavaScriptCore integration, and convert it fromObjective C to C. (Since Planck internally uses the Ambly JavaScriptCore interface and runtime bootstrapping code, this was key to allowing Planck to be converted to C.)

Some of the challenges with the C port involved threading. One is that Planck 2 lacks a good async event triggering mechanism and just employs threads to achieve the same for now. A tougher issue was handling subtleties around JavaScriptCore and threading on Linux, in particular with SIGUSR2 —that issue and related forms took nearly half a year to finally resolve. As they say, persistence pays off.

Planck 2 is faster in some areas relative to 1.17. I think this is perhaps because we are able to use lower-level constructs directly in C, and this is also simply because we have optimized some things since 1.17.

Another issue that was nice resolved in Planck 2 is the ability to run shell scripts that produce lots of output. Try as we might, we never succeeded in getting this to work properly with the Objective C process API being used in 1.17. Now, Planck 2 uses select and breezes though tons of output.

Some other things, like Socket REPL support were much easier to do in C than Objective C . I think the reason here is that UNIX has a fairly straightforward API for TCP.

It has been a long road to ensuring the quality of Planck 2 relative to 1.17. It has had gone through several alphas, 6 betas, and 1 RC. (Planck has entered the mode where you definitely don't want to release breaking changes, if at all possible.) Thanks to all who tested these interim releases!

During that time Lumo came into existence and had two releases! I highly recommend making use of Lumo as well—it is cross-platform, fast , supports many of the same features with Planck, and sits atop V8 and Node—you can make use of NPM libraries with Lumo, something Planck cannot do.

The very first Planck issue was for Linux . I suppose one follow on question will be " Windows? ". Well, it works now, in the Windows Linux subsystem. But, porting to Windows should be feasible. JavaScriptCore works on Windows, and Planck comprises some fairly portable C code at this point. I would suspect that the places where POSIX calls are used for threading, and other low-level facilities would need to be ported to Windows API calls.