Release of Rust 1.78 and Introduction of Borgo, a Language Merging Go and Rust’s Best Features

Published general purpose programming language release Rust 1.78, founded by the Mozilla project, but now developed under the auspices of the independent non-profit organization Rust Foundation. The language focuses on memory safety and provides a means to achieve high task parallelism without using garbage collector And runtime (runtime boils down to basic initialization and maintenance of the standard library).

Rust's memory management techniques free the developer from pointer manipulation errors and protect against problems arising from low-level memory manipulation, such as after-free accesses, null pointer dereferences, buffer overruns, and the like. A package manager is being developed to distribute libraries, ensure assembly and manage dependencies by the project. Cargo. A repository is supported to host libraries crates.io.

Advertisement

Memory safety is enforced in Rust at compile time through reference checking, object ownership tracking, object lifetime (scoping) consideration, and memory access evaluation at runtime. Rust also provides protection against integer overflows, requires that variable values ​​be initialized before use, has better error handling in the standard library, uses the concept of immutable references and variables by default, and offers strong static typing to minimize logical errors.

Basic innovations:

  • Suggested a new “#(diagnostic)” attribute namespace that provides 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‹A› {} fn use_my_trait(_: impl ImportantTrait‹i32›) {} fn main() { use_my_trait(String::new()); } error(E0277): My Message for `ImportantTrait‹i32›` is not implemented for `String` --> src/main.rs:12:18 |
    12 | use_my_trait(String::new()); | ------------ ^^^^^^^^^^^^^ My Label | | | required by a bound introduced by this call | = help: the trait `ImportantTrait‹i32›` is not implemented for `String` = note: Note 1 = note: Note 2
  • 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:
  • Function Barrier::new() stabilized for use 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 converted to use LLVM 18. When using LLVM 18 for x86-32 and x86-64 architectures changed ABI associated with types u128 and i128.
  • Cargo is stabilized in the pact manager 4 version lock files (lockfile v4).
  • Stabilized in Cargo 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, you can note the programming language Borgo, which 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 develops Marco Sampellegrinibook author “The Simple Haskell Handbook” and continuous integration system developer Quad CI.

Advertisement

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 distributed by under license from ISC.

use fmt
enum NetworkState‹T› { 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)
}

Thanks for reading:

Advertisement