Kalix: Tackling the Cloud to Edge Continuum - with Jones Bonér - Watch On-demand

Scala on Heroku

by Havoc Pennington

Bringing the Typesafe Stack to Heroku

We've been working with a team at Heroku to support the Typesafe Stack, including Scala, Akka, and Simple Build Tool on Heroku's Cedar platform. Today the service goes live.

Heroku introduces the new support over on their blog with an emphasis on telling newcomers to Scala about the Scala community.

Readers of this blog may be familiar with Scala and Akka already, but may not have tried out Heroku. You should! And we've built a handy sample app, "Web Words," in case you need something to deploy:

Following the instructions in the README, you can deploy Web Words to Heroku in a matter of minutes. It runs with the free pricing tier so there's no cost to try it.

Heroku could not be easier to use. A nice feature is that you can run any main() method, instead of uploading a .war file; giving you total control of your application. Heroku also offers an ecosystem of add-ons, allowing you to add hosted services such as RabbitMQ or MongoDB to your application with a single command. Both features are shown off in the Web Words sample app.

Adding "stage" to sbt

As part of the Heroku support, we developed a new Simple Build Tool plugin to generate a 'start script'. This plugin exports sbt's knowledge about your main class, your classpath, and so on into a shell script. Then you launch the app with that script. It's like `sbt run` except that it doesn't keep sbt itself in-memory. Find xsbt-start-script-plugin on GitHub. Once the start script is generated, on Heroku it goes in the Procfile; you can also use it to run an app by hand on your local machine.

The start script plugin is not necessary to use Scala on Heroku, but it does save you some work. It also introduces a convention, a task name `stage`, which we're defining to mean "prepare the project to be executed in-place." For xsbt-start-script-plugin, `stage` means to generate executable scripts to launch the app. But you could define it differently, or add your own steps to the task in addition to generating a script.

Heroku's Cedar platform has no knowledge of the start script plugin, it just runs `sbt stage` when it identifies an sbt project and does whatever `stage` has been defined to do.

An intro to Scala, Akka, and Play

By the way, if you missed Dreamforce 2011, I gave a talk introducing Scala, Akka, and Play to Java developers, and teased the upcoming Heroku support at the end of the talk. (Which is why we didn't post the talk until today.)

Here are the slides and a video from the talk.




Free e-book!

If the talk convinces you to learn more about Scala, one place to start is the PDF excerpt of Cay Horstmann's upcoming book Scala for the Impatient we're giving away on the Typesafe web site.

We look forward to seeing what you build with Scala and the Typesafe Stack on Heroku!


The Total Economic Impact™
Of Lightbend Akka

  • 139% ROI
  • 50% to 75% faster time-to-market
  • 20x increase in developer throughput
  • <6 months Akka pays for itself