Common Lisp, Development, LISP

Hacking Lisp in the Cloud, Pt. 3

Cloud9 -- New website and 3rd gen browser-based IDEToday Cloud9 announced the release of their new IDE to all customers. They also released their new website. The hiccups in the beta were all pretty minor, and were resolved quickly after reporting the bugs. Now, everyone can enjoy all the awesome new features.

The Cloud9 IDE supports more than 40 programming languages, Common Lisp included. As I mentioned in my previous post about the Beta, there are all sorts of new features that support a cleaner Lisp development cycle over the previous version—including auto-completion, file outline of top-level definition forms, custom runners, split-screen views, and more, all built on top of an Ubuntu workspace with sudo privileges. They’ve also streamlined the interface, collaboration tools, terminal, and over-all performance of the IDE.

workspace There are so many new features to go through, it’s a little hard to know where to start. But let’s start with the custom runners, since you’ll definitely be wanting to run your Lisp software you write in your shiny new integrated, collaborative development and testing environment.

First of all, after you create a new workspace or migrate an old one to the new Cloud9, you’ll want to install SBCL, RLWRAP, and Quicklisp. You can install SBCL and RLWRAP from Apt, but if you want the latest and greatest version of SBCL, see SBCL: Getting Started and follow the instructions to install the binary release of the latest SBCL for Linux x86-64. You will need to run the install script with sudo.

Verify that SBCL and RLWRAP are installed correctly: in your terminal, run sudo rlwrap sbcl. If you get to the SBCL prompt, and you can evaluate an expression, you’re good to go. You can then proceed with installing Quicklisp as normal.

Writing a Runner is pretty simple. In the project directory tree, you’ll notice a little gear icon with an arrow. Click on this menu, and make sure “Show Hidden Files” is checked. Then from Run > Run With > New Runner, you can create a new Runner script from the built-in template. Save it as “SBCL.run” under .c9/runners/, and edit it to look like this:

{
    "cmd" : ["sudo", "rlwrap", "sbcl", "--load", "$file", "$args"],
    "info" : "Started SBCL :: $project_path$file_name",
    "env" : {},
    "selector" : "source.ext"
}

If you have a full ASDF project, you can create a Lisp load script to send to the Runner that adds your workspace folder to asdf:*central-registry*, loads it and all its dependencies with Quicklisp, and (say, in the case of a web-app), starts it for you. You can also add some sanity checks to this file, and output some status messages based on your app. Please note, the address and port to run your web-apps is 0.0.0.0:8080.

Armed with this load script, you can now create a new Run Configuration with Run > Run Configurations > New Run Configuration. This will open a new Runner tab where your terminal is, at the bottom of the screen. You can give this Run Configuration a name, enter a “command” to run, select the Runner you want to use, and set up any environment variables you might need. In the case of this Run Configuration, the Command should just be the name of your Lisp load script. Once you’re done all that, you can just press the Run button in the runner tab next to the fields you completed, and the Runner will drop you into the SBCL REPL. If it’s a web app, you can see it with the built-in browser preview. Select the Preview button on the main menu, and then Preview with Web Server menu item that pops down. Otherwise, you can interact with your application in the Runner REPL just like you normally would on your computer.

If you just want to run an individual file, you can set up the SBCL Runner as your project default. Then you can just hit “Run” on the main menu, and it will run the currently active file by loading it in SBCL.

Go ahead and create your own Runners now, to fit into your normal workflow! And don’t forget to explore some of the other cool new features, like auto-completion and the file outline of your top-level definition forms.

That’s all for now. As always, Happy Hacking!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s