Crystal is a general purpose object-oriented language designed and developed by Ary Borenszweig and Juan Wajnerman. [3] Crystal is statically typed and has Ruby-like syntax. The first official release of the language took place in June 2014. [4] [5] Initially, the language compiler was written in Ruby, until in 2013 it was rewritten in Crystal. [6] The language is under active development.
| Crystal | |
|---|---|
| Language class | multiparadigmal : object oriented |
| Appeared in | |
| Author | Ary borenszweig |
| Developer | Manas technology solutions |
| File extension | |
| Release | |
| Type system | Static |
| Influenced | Ruby , Go |
| License | Apache License 2.0 |
| Platform | IA-32 (i386), x86-64 |
| OS | Linux , macOS (Homebrew) [2] |
| Site | |
Content
Description
Despite the similarities in syntax, Crystal is much more efficient than Ruby in compiling to machine code using LLVM , sacrificing dynamic aspects of the language. According to the test results, Crystal shows similar performance with the C language. [7] [8] [9] The language uses the Boehm garbage collector , has a macro system, supports generics, as well as overloading methods and operators.
Crystal implements an interface for calling functions from binary libraries in C, C ++, etc., while the syntax for interacting with such libraries is maximally simplified, which makes it easy to create wrapper libraries, rather than writing all the code from scratch. Crystal also supports assembler inserts and direct pointer access - this is considered unsafe, but it is not forbidden, since it is necessary, in particular, for interacting with functions from external libraries.
Examples
Hello world!
The simplest spelling:
puts "Hello World!"
In an object oriented style:
class greeter
def initialize (@name)
end
def salute
"Hello # {@ name}!"
end
end
g = Greeter.new ("world")
puts g.salute
HTTP Server
require "http / server"
server = HTTP :: Server.new do | context | context.response.content_type = "text / plain" context.response.print "Hello world!" end
server.bind_tcp 8080 puts "Listening on http://127.0.0.1:8080" server.listen
Links
- ↑ Release 0.30.1 - 2019.
- ↑ InstallationGitBook
- ↑ crystal-lang / crystal . Github Date of treatment February 18, 2016.
- ↑ Crystal . crystal-lang.org. Date of treatment February 18, 2016.
- ↑ Why Crystal programming language? | Motion Express | Ruby, Rails, Crystal & developers' techniques . motion-express.com. Date of treatment February 18, 2016.
- ↑ Crystal . crystal-lang.org. Date of treatment February 18, 2016.
- ↑ kostya / benchmarks . Github Date of treatment February 18, 2016.
- ↑ kostya / crystal-benchmarks-game . Github Date of treatment February 18, 2016.
- ↑ smarr / are-we-fast-yet . Github Date of treatment February 18, 2016.
[one]
- ↑ Release 0.25.1 (English) . Github Date of treatment June 28, 2018.