Have you heard about Crystal Programming Language? It’s been over 3 years since we saw its first version, but if you’re not familiar with it, it’s a statically typed, compiled language with a very Ruby-esque syntax.

This has at least three implications:

With static types, we are more likely to catch some errors before shipping our code (yes, I’m looking at you NoMethodError for nil:NilClass 🙄) Compiled applications should run almost as fast and efficient as those written in low-level languages like C Writing Crystal is supposed to be as easy as writing Ruby

And it actually seems to deliver all of those features. Types interference usually works really smoothly, so you often don’t even have to worry about explicitly specifying what you need. The compiler catches all uninitialized objects before you even have a chance to run your code. Execution time is within the same order of magnitude as low-level languages, and memory usage is much lower than Ruby.

So should we just drop whatever we’re using and rewrite everything to Crystal? Well, probably not (yet), but let’s talk about it now.

What does it mean to be production-ready?

When creating a new application there are a lot of things to consider before choosing a technology stack:

We want our language to be fast to write, and easy to maintain.

We’d also like it to have a big ecosystem with mature frameworks which won’t break after the first update.

Finally, we can’t forget about tools that surround the language and make development easier. Syntax highlighting, linters, deployment tools etc.

Once we have all of the above, we can call a technology “production-ready”. So is Crystal production-ready yet?

Let’s go through that list one-by-one.

Crystal is fast to write, but it keeps on changing

High development speed is basically guaranteed here. With Ruby-inspired syntax it’s obviously really easy to write new code. Basically, if you love Ruby you’ll love Crystal as well. But what about its maintainability?

Right now, the latest released version of Crystal is 0.24.1. Whether we like it or not, it’s officially still in a pre-release phase. The language is still evolving and there are some breaking changes from time to time — most of them, however, are quite easy to introduce into an existing project. Those changes are usually a simple class renaming or new method parameters, but even those may become cumbersome in complex applications.

Since it’s still a beta release we should expect some bugs, which would require us to update. To avoid spending weeks on rewriting your code, it may be wise to keep your Crystal projects small for now.

Let’s start with something small, then move on to bigger things. Like maybe a death star or something? But you wouldn’t build a death star with pre-release tools, will you? — Photo by Daniel Cheung on Unsplash

There are many shards, but is the ultimate one already there?

Shards are to Crystal what gems are to Ruby. Little (or not so little) libraries which you can easily reuse in your code. Do you want to build a web application? You’ve already got kemal, lucky or amber to help you. Maybe you’re writing tests and need to do some extra stubbing? You can already find some standard stuff like webmock.cr or timecop.cr. Want some background processing? Worry not, sidekiq.cr got you covered.

All the Shard above have one thing in common. They are suspiciously similar to what we have in Ruby. If you noticed the cr in some names, it usually indicates Ruby-inspired shards, so it’s really straightforward to use them when coming from Ruby.

We can probably agree that one of the most important gems was Rails. It helped with community growth and made Ruby a lot more popular in production use. And if you are a Rubyist you may try to apply duck typing to Crystal — since it looks and behaves like Ruby, therefore it is Ruby, and it needs its own Rails. Or does it?

Since Rails already does its job quite well do we really need something similar? What if instead of trying to mimic Ruby we went a step further and looked for something that Crystal can do what Ruby couldn’t? Since it’s faster there may be possible applications in machine learning, low-level system tooling, high-performance computation, or graphics processing. Have you seen all the “Crystal intros” which do a basic Web API and compare the code with Sinatra? 🙈 Maybe, instead of solving what‘s already been solved let’s create something new, something we’ve always wanted to try, but Ruby just couldn’t cut it.

If you need some inspiration look at the existing shards and browse through an Awesome Crystal list.

You can write with your favorite tools, but then it gets rough

If we look at the Awesome Crystal list I’ve linked above, we can see plugins for any reasonable editor we may use. There are syntax highlighters and linters for Vim, Emacs, Atom, Visual Studio Code or Sublime. We can easily manage Crystal versions with asdf or crenv, and there is an ansible playbook and a heroku buildpack for your remote setup.

But what if we actually want to move past web applications and create some desktop app or a command line tool? In that case we’d like to distribute our application as a single, self-contained executable. And Crystal compiler can statically link required libraries, but it has problems doing this on macOS. And since Crystal is not yet Windows-compatible, our potential reach is quite limited. But Windows support has been already discussed for a long time and seems to be a heavily worked-on feature recently, so those issues may soon become a history.

So… is Crystal production-ready or not?

Even though we’ve looked at different aspects of what makes software production-ready it’s still hard to give a specific answer 😳

Crystal might not have a clearly defined future yet, but it’s definitely a solid project with good development pace. While using it as a “new Ruby” to build web applications may be a dead end, there are a lot of other possible projects you can create with it. And yes, we’re even talking about building production grade software now.

Maybe just try to keep it small enough to account for possible syntax changes until Crystal 1.0 is out. Now is a great time to contribute to the community, create a new shard for others or help with language development itself.

If you enjoyed this post, please hit the clap button below 👏👏👏

You can also follow us on Facebook, Twitter and LinkedIn.