百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

rubex

> 编程语言
开源

rubex - 一个类似 Ruby 的语言,用于编写 Ruby C 扩展。

452 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

rubex - 一个类似 Ruby 的语言,用于编写 Ruby C 扩展。

Rubex

Rubex is a Ruby-like language for writing Ruby C extensions.

Rubex is a language that makes writing CRuby C extensions as simple as writing Ruby. It does this by providing a syntax that is the perfect blend of the elegance of Ruby and the power of C. Rubex compiles to C and implicitly interfaces with the Ruby VM in a manner that is completely transparent to the programmer.

Rubex keeps you happy even when writing C extensions.

Status

Table of Contents

  • Quick Introduction
  • Installation
  • Usage
  • Tutorial
  • Syntax
  • Roadmap
  • Acknowledgements

Quick Introduction

Consider this Ruby code for computing a fibonnaci series and returning it in an Array:

ruby
class Fibonnaci
  def compute(n)
    i = 1, prev = 1, current = 1, temp
    arr = []

    while i 
#include 

void Init_a ();
static VALUE Fibonnaci_compute (int argc,VALUE* argv,VALUE self);

static VALUE Fibonnaci_compute (int argc,VALUE* argv,VALUE self)
{
  int n,i,prev,current,temp;
  VALUE arr;

  if (argc = 2.3.0

Install with:

gem install rubex


# Usage

Installing the gem will also install the `rubex` binary. You can now write a Rubex file (with a `.rubex` file extension) and compile it into C code using the following commands.

## Commands

#### Generate

Create all the necessary files for the C extension.

rubex generate file_name.rubex

Options -f, [--force] # replace existing files and directories -d, [--dir=DIR] # specify a directory for generating files -i, [--install] # automatically run install command after generating Makefile -g, [--debug] # enable debugging symbols when compiling with GCC


#### Install

Run the `make` utility on generated files.

rubex install path/to/generated/directory


#### Help

Describe available commands or one specific command

rubex help [COMMAND]


## Manual Usage
If you want to manually generate the files, you can do that with:

rubex file_name.rubex


This will produce the translated C code and an `extconf.rb` file inside a directory called `file_name`. CD into the directory, and run the `extconf.rb` file with:

ruby extconf.rb


This will produce a `Makefile`. Run `make` to compile the generated C file and generate a `.so` shared object file that can be used in any Ruby script.

# Tutorial

Give yourself 5 min and go through the [TUTORIAL](TUTORIAL.md). Convert a part of your C extension to Rubex and see the jump in cleanliness and productivity for yourself.

# Syntax

Read the full Rubex reference in [REFERENCE](REFERENCE.md).

# Differences with Ruby

Although Rubex tries its best to support the Ruby syntax as much as possible, in some cases it is not feasible or necessary to provide full support. Following is a list of differences between Ruby and Rubex syntax:

* All methods in Rubex (including `require` calls) must use round brackets for arguments.
* No support Ruby blocks.
* No support for class variables.
* All methods and functions in Rubex must use the `return` statement for returning values.

# Roadmap

See the [CONTRIBUTING](CONTRIBUTING.md) and the GitHub issue tracker for future features.

# Acknowledgements

* The Ruby Association (Japan) for providing the initial funding for this project through the Ruby Association Grant 2016.
* Koichi Sasada (@ko1), Kenta Murata (@mrkn) and Naotoshi Seo (@sonots) for their support and mentorship throughout this project.
* Fukuoka Ruby Award 2017.
* Tokyo Institute of Technology.

Issues· 29 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubyc-extensionlanguageruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言