Learning a new programming language can open your mind in ways you never thought possible. Just like learning Spanish or French, for example. You get in touch with the cultures and communities of the speakers of that language and learn how they see the world. What could be more enriching than that?

The nice thing about programming languages is that the first one you learn is always the hardest. Once you understand basic structures like if-clauses and for-loops, you’ll see them pop up in many new languages you may learn.

New programming languages are much faster to learn. They are more logical and contain fewer words – or commands. It follows that most programmers and data scientists know more than one programming language.

They may have a main or favorite one. But most software developers use at least five languages a week, if you count scripting languages. Most programmers also try to learn a new language from time to time. It’s work-related. Programming means being curious and constantly absorbing new knowledge. Today we have chosen to present you the advantages and disadvantages of Crystal, shared by The Next Web.

The case for Crystal
Crystal, as per its advertisement, is a language that’s fast like C and slick like Ruby. The part about its slickness is true. It’s compiled and statically typed, which comes with its own advantages and disadvantages. Above all, however, it’s very similar to Ruby in its style.

Static typing
Crystal is statically typed, but you may have noticed there weren’t many type identifiers in the examples above. That’s because Crystal only requires you to specify the type of a variable if it’s ambiguous. This practice, of course, helps programmers be more productive.

Statically typed languages tend to be finicky around macros. Crystal, however, has a way with them. You can use a Crystal macro to change a piece of code at compile time through static reasoning, based on the contents of another piece of that same code. Try to do this in C++ and you’ll either fail or need 500+ lines of code.

Static typing usually reduces some danger, but insanely powerful things (like the ones that Crystal allows) somewhat undo this safeguarding.

No Nil-errors
Speaking of safety, Crystal does have additional safeguards elsewhere. Nil is a separate type for the Crystal compiler. So if you’re trying to access a method or container that turns out to be nil, the compiler will warn you. This might result in a failure of compilation, but at least you get to fix the error before you run a potentially large code.

The big drawback: Crystal is tiny
Crystal had a moment in 2017 when it jumped from place 60 to 32 on the TIOBE index within just a month. The reasons for this meteoric rise are hard to say, but it’s quite likely that the creators of Crystal did considerable marketing at the time and got Ruby programmers curious.
However, Crystal’s moment of fame didn’t last very long. Crystal is nowhere close to the top 50 programming languages on the TIOBE index.

Because of its early rise in popularity, some people hoped it could see similar levels of popularity as Rust. This, however, hasn’t materialized.

The Crystal community is so small that you’ll have to wait a while to get help if you’re running into problems. There just aren’t so many answers on StackOverflow, GitHub, and the likes.

The other drawback: Crystal isn’t as speedy as promised
The creators of Crystal wanted the language to be as fast as C. However, most of the time, Crystal takes about twice as long to execute as C does.

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , ,
Editor @ DevStyleR