Starting a project with Crystal and Kemal

April 16th 2017
Author profile picture


Open protocol suite for sending payments across different ledgers

crystal / kemal code in Atom

How I came to Crystal

Hello guys. I was looking for a new programming language with which to start my freelance computer programmer work. Looking around I found Crystal and I love the readable syntax, similar to Ruby. Reading the documentation you read the objectives that led to the creation of this language:

Crystal is a programming language with the following goals:

  • Have a syntax similar to Ruby (but compatibility with it is not a goal).
  • Be statically type-checked, but without having to specify the type of variables or method arguments.
  • Be able to call C code by writing bindings to it in Crystal.
  • Have compile-time evaluation and generation of code, to avoid boilerplate code. Compile to efficient native code.

OK. Looks good!

I searched among the resources to see if there were sufficient materials that should make it immediately usable (I have to report lack of standard documentation, but actually the language is in alpha stage). For me it was enough to continue.

How I came to Kemal

I think Kemal is the standard the facto web framework for Crystal. Serdar Dogruyol is a kind and helpful person and I love all the community on Gitter (both Crystal and Kemal have a channel).


Actually Crystal don’t work on Windows. So you have to use a Mac or a Linux based system.


brew update
brew install crystal-lang --with-llvm

Debian / Ubuntu

curl | sudo bash
sudo apt-get install crystal

For other distros check the official documentation.

The Workflow

Crystal is a compiled language, so it’s helpful to have a tool like Sentry that build your crystal application, watches files, and rebuilds app on file changes.

I chose Atom as IDE, with a couple of packages: Crystal-tools and Crystal.

The Project

I want to create a simple dynamic website, with Bootstrap layout and dynamic content, something of everyday use for a freelancer.

  • Create the project
  • Integration of sentry
  • Integration of layouts
  • Authorization for backend
  • Dynamic Content (pages, news….)

OK. Lets start!

A note: In the following code $ is the command prompt and the square brackets indicate a text chosen by you to replace the present one.

You should create your application first. Go to the desired location then:

$ crystal init app [APP_NAME]
$ cd [APP_NAME]

Install Sentry in your project:

$ curl -fsSLo- | ruby

open the project in your choosed editor,

go to .gitignore and modify as follow:


(here we remove sentry and the executables from source control)

then add kemal to the shard.yml file as a dependency.

    github: kemalcr/kemal
    branch: master

and then

$ shards update

and substitute [APP_NAME].cr with the following:

require "kemal"

get "/" do
  "Hello World!"

then start sentry:

$ ./sentry

you see something like:

🤖 Your SentryBot is vigilant. beep-boop…
🤖 watching file: ./src/prova/
🤖 watching file: ./src/
🤖 compiling prova…
🤖 starting prova…
[development] Kemal is ready to lead at

go to the browser and check that everything is ok.

Enough for today.

Next time we work to make this skeleton app a working app.

See ya



The Noonification banner

Subscribe to get your daily round-up of top tech stories!