Hacker News new | ask | show | jobs
by floppy-disk 723 days ago
While I write most of my scripts in Ruby and enjoy doing so, there is one gripe I have with it: its slow start-up time. On my machine, running an empty Ruby script takes about 100ms, compared to <10ms for Python, Perl, Lua, Bash.

One can mitigate the problem somewhat using the `--disable-gems` flag, but that's not a good general solution.

1 comments

100ms !!!! wtf? :)

[borg@cube] time ruby -e 'nil'

real 0m0.007s

Whoa, interesting... What version are you running? Here's my system:

  $ ruby -v
  ruby 3.3.1 (2024-04-23 revision c56cd86388) [x86_64-linux]

  $ time ruby -e ''

  real 0m0.122s
  user 0m0.102s
  sys 0m0.020s
I found an old Reddit thread also hinting at bad start-up times: https://old.reddit.com/r/ruby/comments/aqxepw/rubys_startup_....
Very old one :) Because its reliable. Version 1.8.7 here. I want controllable delays. I want controllable threads :) I want portability.

Of course, if you need more peformance, you need to go for newer stuff.

I’ll try this out sometime, but probably through docker

https://hub.docker.com/r/hublogix/minimal-ruby

Yeah.. old ruby have interesting build system. It first build miniruby with is single selfcontained binary having all core ruby functionality. Then, it is used to run some more .rb build scripts to finaly make fully functional ruby.

Actyally that miniruby is pretty usefull. For basic stuff. Also, its very easy to build static ruby containing all extra stuff you care about, like Win32 API for example.

I myself have custom ruby binary on Win32 (Cygwin) with GRX library added in, So I can do basic graph stuff directly from ruby :) That stuff is written in it:

http://borg.uu3.net/~borg/?gperf

> It first build miniruby with is single selfcontained binary having all core ruby functionality.

> For basic stuff. Also, its very easy to build static ruby containing all extra stuff you care about, like Win32 API for example.

Wow, this reminds me abit of MRuby. So I could basically ship a script with the self-contained ruby executable instead of having to force users to install Ruby on their machine? How can I get ahold of miniruby? Or is there any resource somewhere that I can dig into?