Rust 1.78 released. Borgo language that combines the strengths of Go and Rust

The general-purpose programming language Rust 1.78, founded by the Mozilla project but now developed under the auspices of the independent non-profit organization Rust Foundation, has been released. The language focuses on memory safety and provides the means to achieve high job parallelism while avoiding the use of a garbage collector and runtime (runtime is reduced to basic initialization and maintenance of the standard library).

Rust's memory handling methods save the developer from errors when manipulating pointers and protect against problems that arise due to low-level memory handling, such as accessing a memory area after it has been freed, dereferencing null pointers, buffer overruns, etc. To distribute libraries, provide builds and manage dependencies, the project develops the Cargo package manager. The crates.io repository is supported for hosting libraries.

Memory safety is provided in Rust at compile time through reference checking, keeping track of object ownership, keeping track of object lifetimes (scopes), and assessing the correctness of memory access during code execution. Rust also provides protection against integer overflows, requires mandatory initialization of variable values ​​before use, handles errors better in the standard library, applies the concept of immutable references and variables by default, offers strong static typing to minimize logical errors.

Main innovations:

  • A new attribute namespace "#[diagnostic]" has been proposed, providing a means to influence the error messages produced by the compiler. The first in the new space is the "#[diagnostic::on_unimplemented]" attribute, which can be used to customize the error messages thrown in a situation where you need to use a trait that is not implemented for the type. #[diagnostic::on_unimplemented( message = "My Message for `ImportantTrait<{A}>` is not implemented for `{Self}`", label = "My Label", note = "Note 1", note = "Note 2" )] trait ImportantTrait {} fn use_my_trait(_: impl ImportantTrait ) {} fn main() { use_my_trait(String::new()); } error[E32]: My Message for `ImportantTrait ` is not implemented for `String` —> src/main.rs:0277:32 | 12 | use_my_trait(String::new()); | ———— ^^^^^^^^^^^^^ My Label | | | required by a bound introduced by this call | = help: the trait `ImportantTrait ` is not implemented for `String` = note: Note 18 = note: Note 12
  • Pre-assert checks applied to unsafe functions can now be deferred until code generation, allowing these checks to be performed without the need to build the standard library in "#[cfg(debug_assertions)]" mode. To trigger checks, it is now sufficient to enable debug asserts for test or debug builds of your code.
  • The behavior of functions in the standard library that affect the alignment of pointers and slices is now predictable at runtime and depends on the input data. The function pointer::align_offset, which calculates the offset to align the pointer, now returns usize::MAX only if the operation fails. The functions slice::align_to and slice::align_to_mut both, which transform slices into a representation with an aligned middle slice and the original start and end slices, now always return the largest middle part.
  • The following were transferred to the stable category:
    • impl Read for &Stdin
    • Allow the use of a non-static (non-static) lifetime for some std::error::Error-related implementations.
    • Impl implementation allowed to use the ?Sized value.
    • impl From for io::Error
  • The Barrier::new() function has been stabilized to be used with the "const" attribute in any context instead of constants.
  • For target platforms x86_64-pc-windows-msvc, i686-pc-windows-msvc, x86_64-pc-windows-gnu, i686-pc-windows-gnu, x86_64-pc-windows-gnullvm and i686-pc-windows-gnullvm now requires at least Windows 10 version.
  • The third level of support has been implemented for the wasm32-wasip2, arm64ec-pc-windows-msvc, armv8r-none-eabihf and loongarch64-unknown-linux-musl platforms. The third level involves basic support, but without automated testing, publishing official builds, or checking whether the code can be built.
  • The second level of support for the target platform Add wasm32-wasip1 has been implemented. The second level of support involves an assembly guarantee.
  • The platform wasm32-wasi-preview1-threads has been renamed to wasm32-wasip1-threads.
  • The compiler has been switched to use LLVM 18. When using LLVM 18 for x86-32 and x86-64 architectures, the ABI associated with the u128 and i128 types has been changed.
  • In the Cargo pact manager, version 4 of lock files (lockfile v4) has been stabilized.
  • Cargo has a stabilized global cache with information about the latest data usage. The cache is hosted in $CARGO_HOME/.global-cache using SQLite and is updated automatically to reflect the latest changes to the index, crate file, code directory, git clone, and git checkout.

Additionally, the Borgo programming language tries to be more expressive than the Go language, but less complex than the Rust language. Borgo combines the best features of Go and Rust, making up for the shortcomings of each language. For example, Go is simple and straightforward, but does not provide advanced type safety features. The Rust language provides tools for safe programming, but is overcomplicated. The project is being developed by Marco Sampellegrini, author of The Simple Haskell Handbook and developer of the Quad CI continuous integration system.

Rust 1.78 released. Borgo language that combines the strengths of Go and Rust

Borgo uses static typing, Go-like types, and Rust-like syntax. Semicolons are optional at the end of lines in Borgo code. Borgo code is compiled into a Go representation that is fully compatible with existing Go packages. The compiler code is written in Rust and is distributed under the ISC license. use fmt enum NetworkState { Loading, Failed(int), Success(T), } struct Response { title: string, duration: int, } fn main() { let res = Response { title: “Hello world”, duration: 0, } let state = NetworkState.Success(res) let msg = match state { NetworkState.Loading => “still loading”, NetworkState.Failed(code) => fmt.Sprintf(“Got error code: %d”, code), NetworkState.Success (res) => res.title, } fmt.Println(msg) }

Source: opennet.ru

Add a comment