News for hackers. Stuff that matters.
Re:Ruby Is Defined by Terrible Tools by boardwaalk on Wednesday July 08, 2015 @12:45PM (#9852885)
This is pretty specific, but Ruby has pretty terrible support for parsing Ruby. Libraries are either unmaintained or broken or for old versions. Python is great for parsing ('import ast'), compiling ('compile(...)') and executing ('exec(...)'). So it's much easier to write code generators, write linters and autocompletion tools and such.
Re:Ruby Is Defined by Terrible Tools by cremno on Wednesday July 08, 2015 @01:02PM (#9853029)
>but Ruby has pretty terrible support for parsing Ruby

https://github.com/whitequark/parser

Neither unmaintained, broken nor just for old versions. It has some really minor incompatibilities though:

https://github.com/whitequark/parser#known-issues

The same person also wrote a Python parser because apparently the ast module doesn't provide precise location information of tokens:

https://github.com/m-labs/pythonparser

Re:Ruby Is Defined by Terrible Tools by cheald on Wednesday July 08, 2015 @05:19PM (#9854671)
It's fine in MRI.

    > seq = RubyVM::InstructionSequence.compile("a = 1 + 2")
     => <RubyVM::InstructionSequence:<compiled>@<compiled>>

     > puts seq.disasm
    == disasm: <RubyVM::InstructionSequence:<compiled>@<compiled>>==========
    local table (size: 2, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
    [ 2] a
    0000 trace            1                                               (   1)
    0002 putobject_OP_INT2FIX_O_1_C_
    0003 putobject        2
    0005 opt_plus         <callinfo!mid:+, argc:1, ARGS_SIMPLE>
    0007 dup
    0008 setlocal_OP__WC__0 2
    0010 leave
     => nil

    > seq.eval
     => 3
Re:Ruby Is Defined by Terrible Tools by graffitici on Wednesday July 08, 2015 @01:19PM (#9853171)
I had looked into the 'ast' module a little while back, and I do agree that it's pretty neat. The main use I've seen it type checking, or adding language level features (that would typically be done by macros in LISP).

I am not aware of many tools written using 'ast', that don't try to extend the language in some way. Any thoughts there?