« All posts

racing · software · open-source

Lucky Crystal#

December 3, 2017

In the ever changing landscape of web frameworks, there is a new kid on the block: Lucky. Lucky is written in Crystal, a statically typed programming language heavily inspired by Ruby's syntax, which claims to be

Fast as C, slick as Ruby

For this blog however, being as fast as C is mostly irrelevant, I'm sure it'd be plenty fine running in Ruby as well. What I rather value is developer productivity, or "getting something done in half an hour before going to bed". On that end, the Lucky + Crystal combination performed pretty well and I got a rewrite of this website shipped in a few hours of work.

Type safe html

What I find super interesting about Lucky is the way it deals with the task of rendering html. While the plethora of templating engines like ERB, Twig or Crystal's ECR are easy to work with and simple enough to understand, there's something about using plain Crystal code to markup html. The following gist is an example method from this blogs source code:

As you can see it was trivial to extract methods to render reoccuring or more complex parts of the layout. It's just code. Also the compiler will complain if we produce invalid code, so we cannot forget to close tags. That's kind of a big deal to me.

I look forward to spending more time in Lucky and Crystal, they both get a thumbs up for now!