Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: MRuby a cross platform scripting environment in a single, small binary (github.com/ixday)
1 point by IxDay 9 months ago | hide | past | favorite
Hey HN!

If you are a Golang/Infrastructure developer like me, you might also be struggling with Bash and Make. Well, I think I found a solution worth sharing! I repackaged mruby—a lightweight Ruby runtime for embedded systems—into a tool for writing cross-platform scripts and build pipelines.

While Make + Bash are the ecosystem default, they’re far from ideal: Bash lacks support for most data structures, handles strings poorly, and has many other shortcomings (a good list here: https://www.quora.com/What-are-the-disadvantages-of-the-Bash...). Make doesn’t include globbing for subdirectory traversal (you need to use find for that), is often misused as a task runner, and has its own limitations. On top of this, achieving cross-platform support is tricky (we’ve all run into bugs caused by GNU vs BSD coreutils flags).

Ruby + Rake seemed like a better fit, but - The Ruby ecosystem isn’t lightweight: Ruby + Rake + dependencies add up to ~24MB. - Installing Ruby on remote hosts or containers can be challenging. - It may conflict with system versions (macOS’s default Ruby, for instance). - It’s not self-contained (you need multiple files instead of a single binary).

This project offers a different approach: a repackaged mruby binary (just ~2.2MB with my dependencies) that bundles useful libraries into a single file. I included the following to meet my needs:

- CLI tools: Optparse for argument parsing, ANSI colors for better output. - Data handling: Built-in YAML/JSON support. - Networking: HTTP/HTTPS client/server capabilities. - Task management: A simplified version of Rake.

You can customize it (add or remove dependencies and repackage the binary) to fit your specific requirements.

I now use this as a replacement for tasks where Bash or Make would have been my first choice. The repository includes example scripts (e.g., using kubectl or vault) and a Golang project skeleton to show how it all works.

If you’re interested in my journey exploring alternatives, check out my blog post: https://platipy.notion.site/The-quest-for-the-optimal-script...

Feedback and contributions are welcome—I hope it helps with some of your challenges too!



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: