Crystal 1.0 programming language available

The Crystal 1.0 programming language has been released. The release is noted as the first significant release, which summed up the results of 8 years of work and marked the stabilization of the language and the readiness for use in working projects. The 1.x branch will be backwards compatible and guaranteed that there will be no changes to the language and standard library that will negatively affect the assembly and operation of existing code.

Releases of 1.0.y will include only minor fixes, while 1.x.0 versions will introduce new functionality and significant changes while maintaining code compatibility. New ideas and potentially incompatible changes will be developed in a separate branch, which will later form the basis for the Crystal 2.0 release. Some Crystal 1.0 features are declared preliminary and, despite being present in the 1.0 branch, are not covered by official support. These features include multithreading, platform support, and Windows, use on systems with ARM processors.

Recall that the developers of Crystal 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:

  • In tuples, indexed access to elements of different types is allowed, since the compiler knows what type each element is. For example: tuple = {1, "hello", 'x'} v = tuple[0..1] # will return {1, "hello"} typeof(v) # => Tuple(Int32, String)
  • String and character literals are not allowed to use surrogate abbreviations in Unicode escape sequences, such as "\uD834". To encode arbitrary values, use the "\x" notation.
  • The standard library has removed a large portion of definitions, macros and methods that were previously deprecated. Including Set, StaticArray#[], YAML.new, HTTP::Request, HTTP::WebSocket,Hash#delete_if, Process#kill, etc. methods.
  • The getter and property macros now require the return type to be specified.
  • The default rounding method has been changed to TIES_EVEN ("banker's rounding", to the nearest integer, and for borderline situations to the nearest even number). The RoundingMode parameter has been added to Number#round, allowing you to select the rounding method. Available methods include: TIES_EVEN, TIES_AWAY, TO_ZERO, TO_POSITIVE, TO_NEGATIVE.
  • In collections, Enumerable#flat_map and Iterator#flat_map work with elements of mixed types.
  • Serialization of Enum sequences now uses underscore string representation.
  • The types defined in the XML module have been moved from using a struct to a class.
  • For security reasons, decoding of cookie names, as well as encoding and decoding of cookie values, has been discontinued (recoding is now the responsibility of frameworks and applications). The HTTP::Cookies.from_headers method has been split into two variants for servers and clients.

Source: opennet.ru

Buy reliable hosting for sites with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster