Why Crystal programming language?


Crystal is a new programming language started in 2012. The creators listed several features:

  • Ruby-like Syntax
  • Static Type
  • Compiled
  • Self-hosted

Also, the purpose of this language is simple:

  • Syntax is as friendly as Ruby
  • Performance is as great as C

There are more features listed on the official website. However, I believe the only reason that Crystal will prosper is its syntax.

How does it look like

First thing first, the syntax resembles Ruby and is 99% look alike. The following example of initializing an http server is offered by the official:

require "http/server"

server = HTTP::Server.new(8080) do |request|
  HTTP::Response.ok "text/plain", "Hello world! The time is #{Time.now}"
end

puts "Listening on https://0.0.0.0:8080"
server.listen

Which makes the learning curve for Ruby or Python developers less deep. However, since it is compiled, Crystal is a great alternative for those who want to design low-level products like operation systems or efficient softwares.

Aestehetics of Syntax

Why syntax matters? It comes from a fundemental question: Why do we need another general-purposed programming language? Go is known for its simplicity over C, R is known for its ability to analyze data, Haskell is known for its functional programming style, and so on. Nothing makes Crystal sepecial. Also, even though many developers argue that Crystal have a lot of modern features, many other programming languages already have those features.

It is not unique, but the only thing that it stands out is its syntax, or style. No other compiled languages look like Crystal.

Style is important. DHH, the creator of Rails, falls in love with Ruby because of its elegant syntax. This simple fact tells us that there is an aesthetic in programming languages. If DHH is not in love with Ruby, Rails might not be born at that time.

Need for Performance & Productivity

The problem with Ruby is that it is too dynamic to be compiled, which drags down the performance. In this case, softwares which require high performance are not keen to adopt Ruby as their programming languages. Compiled languages like Java, C, or Go will be a better choice.

A recent discussion on Hacker News points out that Go-lang is getting popular in China because of its blazingly fast performance as a web service. I believe this is a requirement noy only in China and will be around the world. Just like when Rails became popular, Rails is famous for its productivity and is good for startups to quickly build up their MVP.

The startup trends will not vanish, and more and more companies require a better and quicker way to evolve their business models. As for web services, they need productive frameworks like Rails. I believe this is the point where Crystal comes in. Since performance is becoming an obvious issue in many large-scale services, it would be better to have a programming language that is both productive and efficient.

Crystal is promising

I really love the development strategy of Crystal. Erik in PolyConf 2015 gives a talk in which Crystal has several advantages to grow faster than many of its predecessors:

No new syntax

Already stated, it is Ruby-like.

No new documentations

Like Matz copied its documentations from Perl, creators of Crystal copied documentations from Ruby.

Standard Library

In 1995 when many popular programming languages come out, many standard libraries are not or are not able to be implemented. Crystal is modern, and has no such problems.

Conclusion

With all the advantages above, I believe Crystal will have its own place on the list of programming languages. However, syntax matters, and Ruby has already cultivated a whole bunch of developers waiting for a fast and efficient programming language. Personally I am looking forward to its prosperity.