Comment by troupo

1 year ago

> I find cli tools like find/fd/grep/rg are useful because I rarely need to find only the definition of a function, but rather other call sites too, to find out how it is being used

And find/grep are very bad and limited tools for this compared to what an IDE will give you

Kind of? Text search will also find commented out usage, docu, changelog, and my .org file with refactoring ideas from last month. (For better or worse.) It will also show when a class with the same method names exists elsewhere - which you want to know about if the naming is good. To find usage of a method called "update", LSP results will be better, but... that was kind of the point? That you don't name your methods "update" if they are important semantically.

And rg also works in projects with multiple programming languages (e.g. you're using a method from JS and want to find its Rust implementation in the webassembly module) and across project folders (instead of pointing you to a read-only copy of an installed module). But, if you spend 95% of your time in a single codebase with a single language... YMMV.

  • > Text search will also find commented out usage, docu, changelog, and my .org file with refactoring ideas from last month

    Yes, when searching across the entire project for text an instant fuzzy search is an invaluable tool.

    > It will also show when a class with the same method names exists elsewhere

    Oh, this is a great example when a code-aware tool is better. I also ave a rant-ish about LSP at the end.

    So, let's say you have several methods called `update` across your codebase. As per original comment, "I rarely need to find only the definition of a function, but rather other call sites too".

    With text-search you will find all those other methods, and all the call sites for those methods. And not just in the working code, but across all tests as well. So you have to manually go through the search results and figure out whether a call to update is the one you're looking for.

    In an IDE it's just a shortcut:

    - go to definition https://www.jetbrains.com/help/idea/navigating-through-the-s...

    - go to implementation https://www.jetbrains.com/help/idea/navigating-through-the-s...

    - Find usages https://www.jetbrains.com/help/idea/find-highlight-usages.ht... perhaps even inline https://www.jetbrains.com/help/idea/find-highlight-usages.ht...

    - find the full caller hierarchy https://www.jetbrains.com/help/idea/viewing-structure-and-hi...

    And so on.

    Oh, you want to know where all the methods called `updated` are defined to go and scream at someone?

    - Search for symbols https://www.jetbrains.com/help/idea/searching-everywhere.htm...

    Of course all that is also integrated with things like refactoring. So if you rename a method, you don't have to painstakingly manually search for all invocations of that method. Or if you rename a parameter to that method, or... See the several dozen possibilities here: https://www.jetbrains.com/help/idea/refactoring-source-code....

    ----

    Here comes the rant.

    The whole "text searching is enough, the compiler will pint to me the errors I've made" fashion has held back tool development by several decades. It's telling that LSP (which has barely 5-10% of IDEA's functionality) has taken this world by storm. Suddenly the languages and the editors that lacked even the basic quality of life improvements when working with code got a glimpse of what is possible.

    Welcome to the very early beginning of the 21st century. Perhaps in 20 more years you will finally let go of the notion that painstakingly doing a computer's job is not in any way or form productive or indicative of a great programmer somehow [1]. And that to work with code you really want tools that are capable of working with code.

    After all, somehow, you reach for Excel/Numbers/Google Sheets to work with spreadsheets, for Photoshop/numerous alternatives to edit photos etc. You don't reach for some generic vaguely-adjacent tool to do the job.

    [1] I keep telling this story: About 5 years back I saw several people switch from vi/emacs to PHPStorm/IDEA after watching me zipping through code (including jumping from Symfony configs to code and back) while they spent often minutes doing fuzzy searching through the codebase we were working at the time: a huge legacy monolith we were slowly refactoring and splitting up.

    • I'm glad you mentioned IDEA, so I didn't have to. People rave about LSP and it's great that it exists, but IDEA has been doing more advanced code navigation for years (decades?).

    • You seem weirdly angry that some other people like to work in a different way than you like to work. People like different things. You still get to like your thing.

      7 replies →