The creator of Ruby, Yukihiro Matsumoto said that the language was made to make programmers happy. Imagine a language as elegant as Ruby and blazingly fast as C. If you already love Ruby, maybe it is time to start considering Crystal lang, the younger sibling of Ruby. It is a compiled language which is syntactically very similar to Ruby and designed for high throughput and performance.
- Native WebSocket support
- Compiles to efficient native code
- Statically typed => if any errors it will let you know at compile time.
- Less memory consumption
Web frameworks in Crystal
Applications developed using framework are easy to maintain and upgrade at a lower cost. This article lets you get familiar with some of the most popular frameworks of Crystal.
Install Crystal to get started.
Create our Crystal app
crystal init app sample-app
To know the true potential of Crystal, let’s familiarise with Kemal, most popular Crystal framework. It’s a Sinatra inspired framework.
In our app,
Open in an editor and add Kemal as a dependency in the shard.yml file.
To get dependencies, run
This will install Kemal.
This is similar to adding gems in gem file and bundle install in Rails.
In the file sample-app.cr created in the src directory, substitute the following
# Matches GET "http://host:port/"
get "/" do
In the …