Hacker News new | ask | show | jobs
by samtheprogram 2102 days ago
I can echo this sentiment. I want to love Ruby, but when I work in project in it, I eventually get to point where I have trouble finding where something is defined, which wastes my time — and in general, to your point, it’s harder to find where anything that’s getting pulled into a file is defined. Unfortunately, this dynamism is a concept in Ruby that is part of the reason why it’s so great.

However, recently I started a project with Ruby, thanks to language servers. I’m hoping this solves that issue, but it’s too soon to say.

There’s still other issues with the require mechanism, and Ruby in general, and other languages to try, e.g. Elixir and Crystal. I haven’t been sold yet in terms of what Ruby excels at, and those languages are each different in their own right.

4 comments

This doesn’t answer all of your points but in terms of finding out where something is defined you can turn a method into a Proc and then ask it. Eg

  some_instance.method(:foo).source_location
There’s a similar method for source definition. Both are useful dealing with over use of meta-programming.
Elixir is much more explicit compared to Ruby in terms of "where is X?" and its compiler apparatus (and user-available hooks and tooling) is getting expanded in 1.11 which is landing soon -- but to be 100% objective, some libraries utilize macros where alias/import/require might be used, which obscures things sometimes.

The tooling still catches all dependencies and their sources though (via `mix xref ...`)

> However, recently I started a project with Ruby, thanks to language servers

What do u mean exactly?

Language servers provide generic autocomplete and other language-specific functionality (e.g. rename a method, find all references to a symbol within your project, find where a symbol is defined, etc) to any editor that supports them. The reference implementation is VSCode, so if you use VSCode you can definitely use language servers, but now that’s it’s picking up steam, support is getting added to other editors, e.g. see vim-coc.

The Ruby language server in question: https://solargraph.org/

Interesting. Do u know what Rubymine is using ? it's own in-house solution?
Come on, use Rubymine or any other smart editor to find definitions..
I've been using Ruby in IntelliJ for nearly a year now at my new job. Up until literally the very most recent version of it, this has definitely not been enough to be able find some methods.

Like, ... 'move' or 'read', or some other horribly overloaded function that is the one that I need to go and find the specific implementation of because it's busted.

You need more than just Rubymine in many cases.

And no, sometimes it's quite difficult to get the exact configuration required to get that code path to figure out what's wrong.

I was fairly unhappy with RubyMine 4-5 years ago, when I last worked in Ruby long-term. Glad to hear it’s gotten better. I’ll have to revisit it, especially if there’s a CE for RubyMine.

To GP: there weren’t at the time any other options for a Ruby “smart-editor” AFAIK. However, like I mentioned in my comment, I’m giving Solargraph [1], a Ruby language server, a try, which is equivalent.

1: https://solargraph.org/

Rubymine is fantastic most of the time. But when projects use too much DSLs and 'magic', nothing helps.