Studying a brand new programming language can open your thoughts in methods you by no means thought potential. Identical to studying a brand new human language like Spanish or Mandarin, you be taught to assume with completely different phrases and buildings.
You faucet into the cultures and communities of the audio system and learn the way they see the world. It’s enriching, to say the least.
The neat factor about programming languages is that the primary one you be taught is at all times the toughest. When you perceive fundamental buildings like if-clauses and for-loops, you’ll see them popping up in lots of new languages you may be taught.
Get your tickets for TNW València in March!
The guts of tech is coming to the center of the Mediterranean
And, in contrast to human languages, new programming languages are a lot quicker to be taught. They’re extra logical and have much less phrases — or, ought to I say, instructions.
It follows that the majority programmers and knowledge scientists grasp a couple of programming language.
They may have a primary or favourite one. However most software program builders I do know use at the very least 5 languages on a weekly foundation, if you happen to depend scripting languages in.
Most programmers additionally attempt to be taught a brand new language from time to time.
It comes with the job. Coding means staying curious.
The case for Crystal
Crystal, as per its commercial, is a language that’s quick like C and slick like Ruby.
The half about its slickness is true. It’s compiled and statically typed, which comes with its personal benefits and drawbacks. Above all, nevertheless, it’s similar to Ruby in its fashion.
Personally I’ve by no means written a bigger undertaking in Ruby. However as a reasonably skilled Python developer, Crystal code nonetheless seems crystal clear!
Right here’s an instance of a recursive loop that calculates factorials:

The command places sounds a bit bizarre to individuals who aren’t accustomed to Ruby. It’s mainly a bad-taste model of print in different languages. There are some delicate variations between places and print however we gained’t dive into these right here.
Aside from that, this instance seems fairly pythonic, proper?
It’s comparable for if-clauses:

Aside from the humorous places expression that non-Ruby-natives aren’t used to, that is once more very readable.
Usually talking, the syntax of Crystal is obvious, even when coping with bigger and extra difficult issues.
Static typing
Crystal is statically typed, however you will have seen there weren’t many kind identifiers within the examples above. That’s as a result of Crystal solely requires you to specify the kind of a variable if it’s ambiguous.
This observe, in fact, helps programmers be extra productive.
Macros
Statically typed languages are typically finicky round macros. Crystal, nevertheless, has a approach with them.
As proven on this instance, you should use a Crystal macro to alter a bit of code at compile time by static reasoning, primarily based on the contents of one other piece of that very same code. Attempt to do that in C++ and also you’ll both fail or want 500+ strains of code.
Or don’t you, you genius? Let me know if I’m flawed…
This does include some caveats as a result of, because the saying goes, with nice energy comes nice duty. Static typing often reduces some hazard, however insanely highly effective issues (like those that Crystal permits) considerably undo this safeguarding.
No Nil-errors
Talking of security, Crystal does have further safeguards elsewhere. Nil is a separate kind for the Crystal compiler. So if you happen to’re making an attempt to entry a technique or container that seems to be nil, the compiler will warn you. This may lead to a failure of compilation, however at the very least you get to repair the error earlier than you run a doubtlessly massive code.
No extra dependency hell
Should you’ve ever dealt with a big drawback in Python, you most likely know what dependency hell seems like.
One Python module may rely on one other few, and when you’ve imported all of the modules you want, you understand that completely different module variations aren’t suitable. Now it’s a must to work out which variations to make use of to make every part match collectively, and all of this will take hours when your undertaking is of a sure dimension.
In Crystal, these modules are referred to as shards, they usually get compiled into your binary executable by way of static linking. I might go into element about this, however let’s reduce the story quick: Dependency administration is far, a lot simpler this manner.
The massive downside: Crystal is tiny
Crystal had a second in 2017 when it jumped from place 60 to 32 on the TIOBE index inside only a month. The explanations for this meteoric rise are laborious to say, however it’s fairly seemingly that the creators of Crystal did appreciable advertising on the time and acquired Ruby programmers curious.
Nonetheless, Crystal’s second of fame didn’t final very lengthy. On the time of writing this text, Crystal is nowhere near the highest 50 programming languages on the TIOBE index.
Due to its early rise in reputation, some individuals hoped it might see comparable ranges of recognition as Rust.
This, nevertheless, hasn’t materialized.
Programmers have expressed frustration about pattern initiatives or code bases. Additionally, the documentation appears a little bit bit incomplete. This turned new programmers off in droves.
And due to this, the Crystal neighborhood is so small that you just’ll have to attend some time to get assist if you happen to’re operating into issues. There simply aren’t so many solutions on StackOverflow, GitHub, and the likes.
The opposite downside: Crystal isn’t as speedy as promised
The creators of Crystal needed the language to be as quick as C.
This is perhaps true in remoted instances. Nonetheless, more often than not, Crystal takes about twice as lengthy to execute as C does.
It’s not unusual for programming languages (or tech corporations, for that matter) to have overblown mission statements. And, to be truthful, half as quick as C continues to be fairly quick.
However, Crystal considerably under-delivers vis-à-vis its authentic promise. It’s so manifestly apparent that I can’t blame the common developer for feeling disenchanted.
Well-known final phrases: Crystal is for knowledgeable programmers solely
I like exploring new programming languages, however I favor well-documented languages with a big and supportive neighborhood. Many programmers really feel comparable.
Crystal has had its shot at mainstream attraction, however general it has failed in the previous couple of years.
This doesn’t imply that there aren’t some attention-grabbing use instances for Crystal. It is perhaps an attention-grabbing possibility for individuals working with blockchain expertise. You possibly can create a reasonably highly effective cryptocurrency with Crystal.
That being stated, except the documentation, advertising, and common neighborhood assist for Crystal improves, it gained’t be a fantastic possibility for the common blockchain developer both.
If you wish to play with a language like Crystal, you’d higher deliver some expertise. As a result of if you’re confronted with an issue, there is perhaps no one there that can assist you.
This text was written by Ari Joury and was initially printed on Medium. You possibly can learn it right here.