Did you know? Programmers convert coffee to code.

If you like my articles, sponsor me a coffee.

At the other end of the link I post some results of my other hobbies, like playing bass. It is worth checking it out ;)

Going Crystal

As a good developer, you should learn a new programming language to broaden your knowledge and keep your skills at a competitive level — at least if you’re interested in having a good and exciting job until you retire.

In 2018, I made up my mind to learn Crystal.

Development of the language began in 2011. This means, the project isn’t new but most of us never heard of it yet. Why is it, that it gains momentum now?

Ruby is around for some time, and who writes Ruby knows how easy it is to get your ideas down as code. But as a downside, it isn’t as fast as dynamically typed, interpreted languages and for some use cases you have to consider different approaches or languages. And Crystal aims to solve this problem. The C symbolizes the C programming language which is fast — but hard to write. I can remember my first semester at the university where we learned C (and this was the first programming language I ever learned). It was a bit horrible and I didn’t dig deep enough to see all its capabilities.

Besides Ruby and C, Crystal tries to get the best from the current pool of programming languages like Python, Elixir or Go.

Core features

It is compiled to a binary file (yes, a single binary containing all code inclusive dependencies).

Speed. Comparing to interpreted languages, Crystal has a speed boost. It can be a viable alternative to C/C++ or Rust.

Static typing ensures that each variable has its possible type at compile time — this can save you a production headache if you try to add a string with a number.

nil-related errors are impossible. The compiler checks if you want to reference a possible Nil object — and requires you to check it. No more NullPointerException! And this is something I’m looking for nowadays because I am really fed up with NPEs.

It has web frameworks which provide the speed benefits of the core language. Amber is the most popular one, but Kamal is emerging too. Anyhow, you can choose to have your web applications running on Crystal too — faster.

Crystal is written in Crystal. And this proves the power of the language: the compiler itself is written in the programming language you want to compile. No need for an extra layer complexity, introducing a new programming language. If you know Crystal, you’re good to go to help out the project.

Everything is an object — and you can change the code just like with Groovy. Pure OO concepts help developers to dig in fast and use the already learned approaches. Sometimes you need new methods for classes of the standard library. This requires you too don’t mess up anything but gives you great power.

Fibers provide you parallelism and get you out of the callback/promise hell you may know from Ruby or JavaScript. And you don’t have to write complex code to achieve parallel/async code.


Every rose has its thorn.

To provide such speed you have to compile the code on the target machine. Yes, you’ve read right. Because Crystal doesn’t have a virtual machine (Java, Elixir) and is not interpreted at runtime (Python, Ruby) you need to compile it on your target machine. However, this ensures that your code and its dependencies compile on the target platform.

No support for Windows — yet. Who else wants to run Crystal on a computer having Windows installed? Yes, you’re right, nobody. Well, I do because my company notebook has Win10, and I like to play with Crystal on the train (not Rails) and a native support would be nice. But there are workarounds — fortunately.

No Go-style parallelism — yet. Again a topic the developers of the language are working at. If they’re finished, you get real parallelism and you can leave the GIL behind.

No REPL. I have no idea if they will find a way to get a working REPL one day but it is damn difficult to write one with a statically typed language.


Even though the downsides, I believe in the community, and these missing features will be implemented soon enough to gain a bigger space among developers.

Stay tuned for more articles. I’m diving deep into this topic for some time and will share my insights with you here.

Share the knowledge!

Senior developer, consultant, author, mentor, apprentice. I love to share my knowledge and insights what I achieve through my daily work which is not trivial -- at least not for me.

Click Here to Leave a Comment Below

%d bloggers like this: