Crystal programming language
While reading the Interview with Eric Michels-Aubert, RubyHero-2014 , I came across the mention of Crystal Yap .
"What kind of beast?" - I thought and climbed to look for information. What I found, I admit, was impressed.
Creating a language, the authors set themselves the following goals:
Ruby syntax conciseness + C speed? It sounds good to me.
The first commit to the github repository was made on September 2, 2012. At the moment, the development of the language is at the alpha stage of version 0.7.1 - the syntax and standard library are subject to change.
Interestingly, in version 0.7.0, all IOs became asynchronous by default. In Crystal, as in Go, you can use channels to tame multithreading. Here is how the use of channels looks on the example of calculating prime numbers (an example from the repository, ported from Go):
In the repository you can find an impressive number of examples of using the language to solve a variety of problems, including the implementation of red-black trees , ray tracing , solving the N-body problem , a neural network , and a brainfuck interpreter . There is also an example of a simple http server.
On July 6th, developers make a presentation on the language at the Curry On conference in Prague.
"What kind of beast?" - I thought and climbed to look for information. What I found, I admit, was impressed.
Meet Crystal
Creating a language, the authors set themselves the following goals:
- have the most Ruby syntax
- have type inference
- call C code by writing binders
- be able to execute code and code generation at the compilation stage
- compile it all into native code
Ruby syntax conciseness + C speed? It sounds good to me.
The first commit to the github repository was made on September 2, 2012. At the moment, the development of the language is at the alpha stage of version 0.7.1 - the syntax and standard library are subject to change.
Interestingly, in version 0.7.0, all IOs became asynchronous by default. In Crystal, as in Go, you can use channels to tame multithreading. Here is how the use of channels looks on the example of calculating prime numbers (an example from the repository, ported from 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 a variety of problems, including the implementation of red-black trees , ray tracing , solving the N-body problem , a neural network , and a brainfuck interpreter . There is also an example of a simple http server.
On July 6th, developers make a presentation on the language at the Curry On conference in Prague.