First of all, what is Crystal? However, to put it simply, it is a programming language designed to run programs at a speed similar to C using the ruby syntax. This time, I’m hoping to briefly introduce the charm of this crystal.
Check execution speed
First of all, if you do not include crystal, please install it according to the environment from official site. After that, create a crystal folder in a suitable place. Next, create test.cr in the crystal folder and edit the contents as follows.
puts "Hello World!"
As you can see, it is a program that displays characters. When this is executed like ruby, the execution speed is as follows.
time crystal test.cr → Hello world! → crystal test.cr 0.85s user 0.27s system 134% cpu 0.833 total
Next, compile test.cr (convert the contents of the file into a state that can be read by the computer at one time) and execute it. The result will be as follows.
crystal build test.cr --release time ./test → Hello world! → ./test 0.00s user 0.00s system 2% cpu 0.263 total
By comparison, the former is 0.85 seconds, while the latter is 0.00 seconds, which is at least 10 times faster.
So far, it is also described in this site If you want to know more, I would like you to see this as well.