Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are you manually rebuilding it or are you generating the code from the mruby project? #1

Open
shehackedyou opened this issue Jan 24, 2024 · 5 comments

Comments

@shehackedyou
Copy link

Just curious about your strategy because I have gotten close to rewriting a lot of Ruby in Go but then realized I should have generated the code from the original C project.

Recently I have considered using purego package to include libruby

Do you still have to essentially implement each major data type?

@elct9620
Copy link
Owner

I'm not sure about what you need to use Ruby.

This project is still experimental to re-implement mruby in pure Go.

The reason is:

  • To bind a C library in Go is not easy to build an executable
  • Convert between Go and Ruby types has an extra cost

However, you need to consider that the mruby is not 100% the same as CRuby, the mruby is lightweight and can be easily embedded into other applications. You can image mruby is more like Lua.

This project has a lot of different designs with mruby. For example, I use Go's type to replace mrb_value that mruby and Go shared the same data type. This is inspired by Shopify/go-lua.

@shehackedyou
Copy link
Author

I got it working by embedding downloading the latest and embedding it then running it when needed as a memfd. You can have the output as a hash that already exists projects that let you convert that hash to Go structs.

But I totally agree this method is not great. I was looking at the new project purego which helps you remove cgo from your codebase, which there are several reasons why that is ideal and Ill assume you know them.

I do get mruby is smaller and honestly is a better goal. I already started using ruby to configure vagrant like VMs. I like using it as a configuration language, but mruby is even better.

I will look at the go-lua, I have been interested in specifically those projects because I do think they serve as a guide to do the addition. And obviously mruby would be a better configuration language.

I would like to find ways to help if possible, I have a lexer and parser for ruby already built. I even have a basic VM but the classes are not complete.

@elct9620
Copy link
Owner

The parser isn't the priority feature for this project. I plan to use mrbc until the mruby virtual machine gets completed support written in go.

Giving some PR to this project is welcome. However, this project still needs many re-designed from mruby. (e.g. use Go's GC, and type, how the extension works, etc.) It will cause many times rewrites to adjust the design can fit Go's language feature.

By the way, Ruby 3 adds prism to generate the parser which is my best option to make this project compile Ruby code.

@shehackedyou
Copy link
Author

shehackedyou commented Jan 29, 2024 via email

@elct9620
Copy link
Owner

Currently, my works depend on features/ which I use to verify that Ruby code can work as expected (may not fully correct) I think you can start from it or add something and try to make it work.

I didn't have any plans for now because it is still my toy project. My work will try to rewrite mruby's C code to Go if possible. And use more cleaner way if Go provides related language features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants