< 返回版块

Jancd 发表于 2022-04-21 00:06

Tags:rust,news

Ruby yjit 用 Rust 重写的 PR 已经提交

之前 matz 说自己更喜欢 zig,但尊重社区的决定引入 Rust 。

引入 Rust 的 价值主张:

  • Rust 类型系统将及早发现更多错误,有助于防止新错误
  • 更容易管理 YJIT 日益增长的复杂性
  • 更容易维护代码库,更少的“footguns”
  • 对新手来说更容易,因为编译器会捕获更多错误
  • 更好的性能,因为可以实现更复杂的优化
  • 更容易添加对新平台的支持(这会增加复杂性)
  • Rust 拥有成熟且易于安装的工具,例如源代码格式化程序和编辑器插件
  • Rust 作为一个编程语言社区,背后有着极大的热情。这可能会转化为对 YJIT 和 Ruby 的更多热情。

YJIT 的新 Rust 版本与 C 版本达到了同等水平,因为它通过了所有 CRuby 测试,能够运行所有 YJIT 基准测试,并且执行类似于 C 版本(因为它以相同的方式工作并且大部分生成相同的机器代码)。甚至加入了一些设计改进,例如更细粒度的常量失效机制,预计这将对 Ruby on Rails 应用程序产生重大影响。

https://github.com/ruby/ruby/pull/5826

之前的讨论 https://bugs.ruby-lang.org/issues/18481

使用 Rust 和 React 创建富文本编辑器

在 Fiberplane,作者最近遇到了一个有趣的挑战:他们的库超出了我们用于富文本编辑器的库。他们曾经使用 Slate.js —— 一个很好的编辑器,但是当实现我们自己的富文本原语进行协作编辑时,发现我们自己他们的原语和 Slate 的数据模型之间的脱节在某种程度上是一个障碍。所以决定 使用 Rust 和 React 创建富文本编辑器。

原文阅读:https://fiberplane.dev/blog/creating-a-rich-text-editor-using-rust-and-react/

MnemOS 首次发布

MnemOS v0.1.0 版本发布,它一个小型的通用操作系统,用Rust编写。MnemOS是为受限硬件设计的,包括微控制器。

目前,Adafruit Feather nRF52840 Express是唯一支持的内核硬件平台。对其他目标和架构的支持正在计划中。

内核代码仓库:https://github.com/jamesmunns/pellegrino

详情请看:https://jamesmunns.com/blog/mnemos-initial-release/

fast_fp 项目

fast_fp 提供了一组原始类型,支持对许多操作进行快速数学编译器优化。这些优化允许编译器通过放宽 IEEE 754 浮点运算的一些要求来潜在地生成更快的代码。

使用示例:

use fast_fp::{FF32, ff32};

// Construct instances of the fast type from std's type using the convenience
// wrapper `ff32` (or `ff64`)
let four = ff32(4.0);

// or using the `From`/`Into` trait
let five: FF32 = 5.0.into();

assert_eq!(four + five, ff32(9.0));

// Most ops are also implemented to work with std's floats too (including PartialEq).
// This makes working with literals easier.
assert_eq!(five + 6.0, 11.0);
assert_eq!(five * 2.0, 10.0);

// Functions can be made generic to accept std or fast types using `num-traits`
use num_traits::real::Real;
fn square<T: Real>(num: T) -> T {
    num * num
}
assert_eq!(square(3.0_f32), 9.0);
assert_eq!(square(five), 25.0);

// If the nalgebra feature (with version suffix) is enabled, interop with
// nalgebra is supported
# #[cfg(feature = "nalgebra_v029")]
use nalgebra_v029 as na;
# #[cfg(feature = "nalgebra_v029")]
assert_eq!(na::Matrix3::repeat(four).sum(), 36.0);

项目地址:https://github.com/standard-ai/fast_fp


From 日报小组 @Jancd

社区学习交流平台订阅:

评论区

写评论

还没有评论

1 共 0 条评论, 1 页