The code of Sorbet, a static type-checking system for Ruby, has been opened.

Stripe, a company specializing in developing online payment platforms, opened the source code of the project Sorbet, which has prepared a static type checking system for the Ruby language. The code is written in C++ and is distributed under the Apache 2.0 license.

Type information in the code can be computed dynamically, as well as specified in the form of simple annotations, which can be indicated in the code using the sig method (for example, "sig {params(x: Integer).returns(String)}") or placed in separate files with an rbi extension. It is possible to perform both initial static code analysis without its execution, and checking as the code runs (included by adding "require 'sorbet-runtime'" to the code).

There is an option for gradual migration of projects to use Sorbet — the code can contain both annotated typed blocks and untyped sections that are not covered by checks. Notable features also include very high performance and the ability to scale for codebases containing millions of lines of code.

The project includes a core for static type checking,
a toolkit for creating new projects using Sorbet, a toolkit for gradual migration of existing projects to use Sorbet, runtime with a domain-specific language for writing type annotations, and repository predefined type definitions for various Ruby gems.

Initially, Sorbet was developed for checking Stripe's internal projects, most of which are written in Ruby, and was open-sourced after a year and a half of development and deployment. Before the code was opened, beta testing was conducted with the participation of over 30 companies. At its current stage, Sorbet supports running most standard Ruby projects, though there may be occasional incompatibilities.

Source: opennet.ru

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