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

Implement ripper #2377

Closed
Rotonen opened this issue Jun 7, 2013 · 12 comments
Closed

Implement ripper #2377

Rotonen opened this issue Jun 7, 2013 · 12 comments

Comments

@Rotonen
Copy link

Rotonen commented Jun 7, 2013

http://www.ruby-doc.org/stdlib-1.9.3/libdoc/ripper/rdoc/Ripper.html

Currently not implemented.

@dbussink
Copy link
Contributor

dbussink commented Jun 7, 2013

Do you know what depends on Ripper? I've taken a look but it heavily depends on MRI internals so supporting it would probably be impossible. Maybe we can make sure that the dependency gets changes, since I doubt it would really need ripper.

@hassan
Copy link

hassan commented Jun 7, 2013

code_analyzer (https://github.com/flyerhzm/code_analyzer.git - extracted from rails_best_practices gem) requires Ripper, but I haven't investigated further yet.

@brainopia
Copy link
Contributor

whitequark/parser#21 – there is a mention of code analyzer here, saying it's trivial to port the library to Parser gem which is supported across all major ruby platforms.

@dbussink
Copy link
Contributor

dbussink commented Jun 7, 2013

Since we can't really solve this as Rubinius, I'm closing this issue. Hopefully other projects can use better alternatives like whitequark/parser.

@dbussink dbussink closed this as completed Jun 7, 2013
@yorickpeterse
Copy link
Contributor

Although Ripper is part of the Ruby standard library it's more of an internal API than something you can reliably use in your own Gems. The API is generally pretty bad, the AST it generates is borderline insane in a lot of cases, it lacks location information for certain (commonly used) nodes and the documentation isn't exactly stellar either.

Ripper is essentially a very thing Ruby layer on top of the Bison parser used by MRI. As with many parts of MRI it may look good on the outside and actually work, but the moment you start digging around you'll immediately regret that decision.

If you have a need for a Ruby parser I highly recommend that you use parser instead. Although it's still a fairly young project it's already a million times better than Ripper. To name some examples: the AST is consistent/sane, it can extract comments (and associate them with the corresponding AST nodes) and has an actual Ruby-esque API.

I've dealt with Ripper for little over a year now trying to write a linter and many times I was on the verge of losing my sanity due to Ripper. @whitequark is a very smart developer who probably knows more about all of this than he probably would want to. Seriously, use his stuff instead of Ripper.

@badosu
Copy link
Contributor

badosu commented Jun 17, 2013

Unfortunately cane (https://github.com/square/cane) uses ripper too

guilhermesimoes added a commit to whitesmith/rubycritic that referenced this issue Jul 4, 2014
Unfortunately, to count the number of methods, I'm using Ripper [1], a
Ruby script parser. Currently, Rubinius does not implement Ripper [2] so
I should probably:

1. Either use this feature only when the user is on some Ruby other than
Rubinius. This would allow using RubyCritic on Rubinius, but it would be
lacking a feature.

2. Or even better, switch from Ripper to Parser [3] and support all
features in all Rubies.

[1]: http://ruby-doc.org/stdlib-2.1.2/libdoc/ripper/rdoc/Ripper.html

[2]: rubinius/rubinius#2377

[3]: whitequark/parser#21
@saizai
Copy link

saizai commented Jun 8, 2015

https://github.com/railsbp/rails_best_practices relies on ripper.

@brixen
Copy link
Member

brixen commented Jun 8, 2015

@saizai perhaps send a PR to convert to parser. /c @whitequark

@saizai
Copy link

saizai commented Jun 13, 2015

@brixen They're choosing not to. See e.g. flyerhzm/rails_best_practices#140 flyerhzm/rails_best_practices#75

@brixen
Copy link
Member

brixen commented Jun 14, 2015

@saizai looks like Rubocop uses parser https://github.com/bbatsov/rubocop/blob/master/rubocop.gemspec#L42, I guess they can duke it out.

I'm happy to hear arguments for how supporting rails_best_practices adds value to Rubinius and justifies spending effort to support a very poor MRI API (ripper) when a better alternative (parser) already exists and is used by a (partial, at least, and arguable more successful) competitor of rails_best_practices. These decisions are hard to make and I'd like to know how to make them better. From my perspective, almost anything I can spend time on improving in Rubinius would be more important and valuable for its users than spending time on ripper.

@saizai
Copy link

saizai commented Jun 14, 2015 via email

@yorickpeterse
Copy link
Contributor

Having spent significant time using Ripper and looking into the internals I strongly oppose supporting it. From a user perspective https://github.com/whitequark/parser is superior and more portable (it works across all Rubies). JRuby recently added support for Ripper IIRC but it took them several years to get it done (I remember asking them about it at least 2+ years ago).

The closest thing to a parser "standard" is the parser Gem (see above) itself. It's updated very frequently, compatible from Ruby 1.8 until the latest available version, has a consistent API and works across the 3 main implementations. If RubySpec was any indication of how difficult it is to standardize things I highly doubt Ripper will ever be specified properly.

Maybe one day we'll have it, but until then there are far more important things we need to sort out first.

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

8 participants