Release of the Crystal programming language 1.2

The release of the Crystal 1.2 programming language has been published, the developers of which are trying to combine the convenience of developing in the Ruby language with the high application performance inherent in the C language. The syntax of Crystal is close to, but not completely compatible with, Ruby, despite the fact that some ruby ​​programs run without reworking. The compiler code is written in Crystal and distributed under the Apache 2.0 license.

The language uses static type checking, implemented without the need to explicitly specify the types of variables and method arguments in the code. Crystal programs are compiled into executable files, with macro evaluation and code generation at compile time. In Crystal programs, it is allowed to connect bindings written in C language. Parallelization of code execution is carried out using the "spawn" keyword, which allows you to run a background task in asynchronous mode, without blocking the main thread, in the form of lightweight threads called fibers (Fiber).

The standard library provides a large set of generic functions, including tools for handling CSV, YAML, and JSON, components for building HTTP servers, and WebSocket support. During the development process, it is convenient to use the β€œcrystal play” command, which generates a web interface (localhost:8080 by default) for interactive code execution in the Crystal language.

Major changes:

  • Added the ability to assign a subclass of a generic class to an element of the parent class. class Foo(T); end class Bar(T) < Foo(T); end x = Foo x = Bar
  • Macros can now use the underscore character to ignore a value in a "for" loop. {% for _, v, i in {1 => 2, 3 => 4, 5 => 6} %} p {{v + i}} {% end %}
  • Added "file_exists?" method to macros to check if the file exists.
  • The standard library implements support for 128-bit integers.
  • Added Indexable::Mutable(T) module with implementation of advanced operations for collections such as BitArray and Deque. ba = BitArray.new(10) # ba = BitArray[0000000000] ba[0] = true # ba = BitArray[1000000000] ba.rotate!(-1) # ba = BitArray[0100000000]
  • Added XML::Node#namespace_definition method to extract specific namespace from XML.
  • The IO#write_utf8 and URI.encode methods have been deprecated and IO#write_string and URI.encode_path should be used instead.
  • Support for the 32-bit x86 architecture has been moved to the second level (off-the-shelf packages are no longer generated). The transition to the first level of support for the ARM64 architecture is being prepared.
  • Work continued to provide full support for the Windows platform. Added support for Windows sockets.
  • For macOS, a universal package has been added that works both on devices with x86 processors and on equipment with an Apple M1 chip.

Source: opennet.ru

Add a comment