📜 ⬆️ ⬇️

Crystal Programming Language

Reading the article Interviews with Eric Michaels-Aubert, RubyHero-2014 , stumbled upon the mention of the YaP Crystal.
"What kind of beast?" - I thought, and it was useful to look for information. What I found, I admit, impressed me.

Meet - Crystal


Creating the language, the authors set themselves the following goals:


The concise syntax of Ruby + C speed? As for me, it sounds good.

The first commit to the githaba repository was made on September 2, 2012. At the moment, the development of the language is at the stage of alpha version 0.7.1 - the syntax and standard library are subject to change.
')
Interestingly, in version 0.7.0, all IO by default became asynchronous. In Crystal, as in Go, you can use channels to tame multithreading. Here is how the use of channels looks like an example of calculating prime numbers (an example from the repository, ported with Go):
def generate(chan) i = 2 loop do chan.send(i) i += 1 end end def filter(in_chan, out_chan, prime) loop do i = in_chan.receive if i % prime != 0 out_chan.send(i) end end end def run_filter(in_chan, out_chan, prime) spawn { filter(in_chan, out_chan, prime) } end ch = Channel(Int32).new spawn { generate(ch) } 100.times do prime = ch.receive puts prime ch1 = Channel(Int32).new run_filter(ch, ch1, prime) ch = ch1 end 


In the repository you can find an impressive number of examples of using the language to solve various problems, including the implementation of red-black trees , ray tracing , the solution of the N-body problem , the neural network , the brainfuck interpreter . There is also an example of a simple http server.

On July 6th, the developers make a speech on the language at the Curry On conference in Prague.

Source: https://habr.com/ru/post/258083/


All Articles