Building a chat app with Kemal and Crystal

By Vagmi Mudumbai

Elevator Pitch

Crystal is a statically typed language heavily inspired from Ruby. Kemal is a Sinatra like HTTP library that also supports web sockets. We will be building a Redis backed chat application with Crystal and talk about some of the features of crystal and its performance benefits.

Description

One of the biggest focus areas of the next version of Ruby is performance. Crystal is a statically typed language that draws heavy inspiration from Ruby. While the language is still alpha some of the ideas that Crystal presents may pave the way forward for the next version of Ruby. Crystal applications compile down to static executables requiring no runtime components that make it ideal for building micro services that can be easily deployed with docker. My previous talk about Crystal covered the basics of the language. This talk will focus on building a practical application with Crystal. We will be covering

  • A quick overview of Crystal
  • Introducing Kemal
  • A demo of the chat application
  • A walk through of the code base
  • A look at how we implemented
    • authentication
    • http routes
    • views
    • static files
    • websocket messaging
    • modelling with Redis
    • building a docker container of your executable

The goal of this talk is to see what it takes to build and deploy a crystal based microservice into production.

Notes

We at TarkaLabs have been very excited about Crystal. We haven’t got the heart to put anything on production with Crystal as the creators themselves are labelling it as alpha. However, we find it to be very promising and have been experimenting with it by rewriting some of the microservices in our product to Crystal. The results so far have been very promising in terms of both performance aspects and lexical aspects such as brevity, expression etc.

I think that languages like Crystal can be a good playground for new Ruby features as it is not tethered down with existing implementations and pesky worries like backwards compatibility that existing language designers have to worry about.