← Back to context

Comment by anemic

14 years ago

I've been waiting this for a long time. There's also TinyRB (http://code.macournoyer.com/tinyrb/) but it's too small subset of ruby to be useful and seems abandoned.

But my first impressions are not very positive (stripped x86_64 executables with -Os):

  -rwxr-xr-x 1 user group 708480 Apr 20 11:27 mrbc
  -rwxr-xr-x 1 user group 713056 Apr 20 11:27 mruby
  -rwxr-xr-x 1 user group 712128 Apr 20 11:27 mrubysample

compared to lua-5.2.0:

  -rwxr-xr-x 1 user group 147864 Apr 20 11:28 lua
  -rwxr-xr-x 1 user group  99168 Apr 20 11:28 luac

I'm not a big fan of lua as a language but it has been the only option to do scripting on small embedded systems. I've manged to compile size-optimized version of lua on arm to the size of about 80kb but mruby just might be too big for my embedded usage.

Honestly, I'm pretty impressed it's only 7-10 times the size. Ruby is a comparatively huge language, and the compiled size will more likely get smaller than larger from here.

Lua "cheats" by leaving out regular expressions and including a lightweight (but still powerful) matching facility.

  • Plus, no unicode support. This needs lots of code to support properly. Does mruby include it?

Why aren't you a fan of lua? From what I've seen, it looks great.

  • Just a quick list of annoying things:

      - comments start with --
      - no bitwise operations in language
      - default numeric data type is floating-point. it's possible to change it to
        integer but it raises uncertainty with compatibility of external libraries
      - OOP in lua is quite programmer-specific: everyone seems to have their own
        best practises
    

    Of course lua has good features too, like coroutines and good C API. Squirrel (http://squirrel-lang.org/) also seems like a nicer alternative to lua but it requires a C++ compiler.

    IMHO lua's best asset is the small and fast VM. I wish there would be other good, modern languages that target it.

    • for the comments: that's a matter of taste, IMHO.

      for bitwise ops: look at 5.2, it has it now. 32-bit operations.

      floating point arithmetic: in practice, I haven't seen it as a problem as soon as I stay within the 32-bit range - then the numbers can be represented exactly, so the abstraction works well.

      OOP: can't say for it, I did not do it much.

      For the "fast" - check luajit (http://luajit.org/) - it is near-native speed while remaining reasonably slow.

      And the FFI in luajit is simply fantastic. Take a look at https://github.com/justincormack/ljsyscall which binds the syscalls.

      The annoyance that I'd thought of is that the array indexing starts with one, not zero - this brings some headaches during the index calculations. But this also forces to rethink the logic to use more of iterators, and abstract away from the indices. So, after all, it is not that big of a deal.

      2 replies →

    •     -- Comment syntax is that a big deal?
          - bit wise: LuaJIT?
          - Just like in Python and Javascript, what's the issue?
            Doubles do just fine as integers if you code so that 
            you always wind up with other integers.
          - OOP - This I agree is a community fragmentation issue.

      2 replies →

    • What? No mention of indexing starting at 1, not 0? :)

      I just started doing some Lua coding. So far nothing really off-putting, just a need to watch for habits picked up form other languages.

      Biggest complaint is the lack of metaprogramming (e.g eval).

    • Agree strongly about the floating point being a problem. I much prefer languages like Erlang, Python, and Ruby where the default numeric type is arbitrary precision integers.

    • I see, thank you. None of this sounds like a show-stopper to me, but it's good to have a more complete view of a language I'm not intimately familiar with.

      1 reply →