Rust Helix: Build Native Ruby Extensions Without Fear

zw963 · July 07, 2017 · Last by wawayu replied at July 08, 2017 · 6789 hits

https://usehelix.com/getting_started

能 FQ 的也可以看对应的 Youtube 视频。

cool,那个 class 和 def 是用宏做的吗?

不知道,我只是把例子跑起来而已,话说,宏不是应该 ! 结尾才对吗?

ruby! 肯定是宏。

这个项目已经算是推倒重来一次了,第一次比较正式的介绍应该来自这篇 http://blog.skylight.io/introducing-helix/ 去年新加坡的红点 RubyConf 上 Godfray 还谈论了这个项目。

最开始这个项目是在 https://github.com/rustbridge 组织下的(里面还有一个 rust-nodejs 的 bridge 项目,但目前都已被清空了),然后,这个项目在几个月后,就太监了...

同时在发展的还有一个项目 https://github.com/d-unseductable/ruru 几个月断更之后,刚刚看到作者又在继续开发了。

再然后就是 usehelix.com 上线,Yehuda Katz 的公司全面接管项目,看上去也有了喜人的进展。

衷心看好这个项目,如果能够达成路线图的目标,一定会救赎 Ruby 和 Rails,底层通过高性能语言实现,Ruby 作为上层暴露的接口,就像 Python 在 TensorFlow 的作用一样。

感觉很不错

@jasl 这里 也有个例子,很简单,就是一个数数字的例子,启动10个线程。在每个线程中,从1数到500万。在所有10个线程结束后,打印“done”。 在 Ruby 中使用 FFI 调用 rust 的实现,那是 2 秒和 0.086 秒 的差距 ......

刚反应过来,Yehuda Katz 不就是 bundle 的作者么,rust 核心开发成员,rails 核心开发成员,rubinius 核心开发成员 ...... 还有好多,真正的大神啊!

Reply to zw963

rust 官网中讲的和 helix 没关系,helix 的野心相当大,他的目标是用 rust 代码在 ruby 层面和一般的 ruby 代码的行为完全保持一致,这个可以看下他官网的 roadmap#drop-in-replacement

Reply to jasl

详细看了下,确实酷!

@jasl , rust 1.8 开始支持交叉编译了。下面是一段文档:

Since Rust 1.8 you can install additional versions of the standard library for different targets using rustup/multirust.
      For example:
      $ rustup target add x86_64-unknown-linux-musl
       Which then allows for:
       $ cargo build --target x86_64-unknown-linux-musl

不知道这是不是意味着,如果知道目标部署机器的架构,例如:server 是 X86_64 架构,开发机也是, 我是否可以本地编译好 rust 库文件,直接部署到目标服务器开始使用?

如果可以实现,我想首要的好处,就是不需要在目标机器安装编译环境,虽然文件可能会大一点, 但是对于只在部分核心 (较少的地方) 的部分使用 rust 的项目,还是很有优势的。

Reply to zw963

Binary distribution

If you want to use Helix in a gem, and distribute it to users without requiring a Rust compiler, you will need to build binary distributions for your target environment.

We want to support a smooth workflow for specifying your target environments and getting the binaries for each of them. We are exploring both cross-compilation solutions, VM-based solutions, and some combination of the two.

一样在路线图里的~~

真希望有一天我也能达到你们这样的水平

You need to Sign in before reply, if you don't have an account, please Sign up first.