Starting a project with Crystal and Kemal

Massimiliano Bertinetti Blocked Unblock Follow Following Apr 16, 2017

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).

Installation

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

OS X

brew update

brew install crystal-lang --with-llvm

Debian / Ubuntu

curl https://dist.crystal-lang.org/apt/setup.sh | 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.