[RUBY] About the programming language Crystal


First of all, what is Crystal! However, to put it simply, it is a programming language designed to run programs at execution speed similar to C language using ruby syntax. This time, I wrote an article with the hope of briefly introducing the appeal of this crystal.

Check execution speed

First of all, if you do not have crystal installed, please install it from official site according to your environment. 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. If you execute this like ruby, the execution speed will be as follows.

time crystal test.cr
→ Hello world!
→ crystal test.cr  0.85s user 0.27s system 134% cpu 0.833 total

This time, if you compile test.cr (convert all the contents of the file to a state that can be read by the personal computer at once) and then 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, it can be seen that the former was 0.85 seconds, while the latter was 0.00 seconds, which is at least 10 times faster.

The above is also described in this site. If you want to know more, I think you should see this as well.

Recommended Posts

About the programming language Crystal
About the language to be learned
About the method
About the package
Recommended programming language
Output about the method # 2
Popular programming language ranking
About the StringBuilder class
Commentary: About the interface
About the asset pipeline
About the function double-java
Popular programming language ranking
About the length method
About the Kernel module
About the authenticate method.
About the ancestors method
All about Java programming
[Output] About the database
About the [ruby] operator
About the to_s method.
About the handling of Null
About specifying the JAXRS path
Output about the method Part 1
A note about the scope
About the description of Docker-compose.yml
About the File :: Stat class
About the same and equivalent
About the Android life cycle
About the explanation about functional type
[Programming language] User name list
Consideration about the times method
The times may come? Aspect Oriented Programming, What is the AspectJ Language?
About the basics of Android development
[Rails] About the Punk List function
About the equals () and hashcode () methods
About the symbol <%%> in Rails erb
About the information sharing app band
Programming with ruby (on the way)
A murmur about the utility class
About the role of the initialize method
Open source programming language zig summary
Summary about the introduction of Device
About the log level of java.util.logging.Logger