News for hackers. Stuff that matters.
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by ivanjermakov on Tuesday December 20, 2022 @02:52PM (#34071490)
I've tried to migrate to something more lightweight like (neo)?vim, Helix, emacs; but regardless of how good their syntax awareness/LSP support is, it's always inferior to JetBrains IDEs.

Simple example: (any language, e.g. Rust) rename a function across multiple files and undo it. Let me know how you'd do it in your editor of choice.

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by mikojan on Tuesday December 20, 2022 @03:19PM (#34071905)
Go, command line:

  $ gorename -from '"my-package".myFunc' -to myRenamedFunc
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by tommica on Tuesday December 20, 2022 @03:51PM (#34072358)
That's amazing!
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by nomel on Tuesday December 20, 2022 @04:14PM (#34072670)
I would say that’s a fairly trivial example. How about renaming a method? Or, moving a class to a different file?
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by 8ytecoder on Tuesday December 20, 2022 @07:33PM (#34075083)
Or reordering parameters.
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by likely_harrison on Tuesday December 20, 2022 @11:53PM (#34076822)
gofmt can do that! What I’m still looking for is an easy way to bubble up go contexts, adding as first pagans. Perhaps IntelliJ is useful here?
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by wruza on Wednesday December 21, 2022 @10:25PM (#34089392)
All this fiddling ends when you get a team and a vcs.
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by nx7487 on Tuesday December 20, 2022 @03:12PM (#34071811)
sed -i "s/function_name/function_name2/g" $FILES && git restore $FILES

Edit: Not claiming this is better, just saying what I get by with. I have never used an IDE in my career so far, or any autocomplete or code modification features.

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by eitland on Tuesday December 20, 2022 @03:17PM (#34071874)
It cannot differentiate between a field in a class and a variable in a method, or even a word in a comment, can it?
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by P5fRxh5kUvp2th on Tuesday December 20, 2022 @03:20PM (#34071913)
add the c and it will prompt so you can make the determination yourself.
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by monkpit on Tuesday December 20, 2022 @08:36PM (#34075590)
So, no
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by P5fRxh5kUvp2th on Wednesday December 21, 2022 @04:10AM (#34078345)
People get so hung up on this, but it's literally the shallowest sort of refactoring. If you're choosing your tools strictly for this you're doing yourself a disservice.
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by eitland on Wednesday December 21, 2022 @05:41AM (#34078961)
It is also the simplest refactoring, and my point is no command line tricks I have can seen can even reliably do this.

Refactoring support in modern IDEs goes far beyond renaming public fields and methods.

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by P5fRxh5kUvp2th on Wednesday December 21, 2022 @06:14AM (#34079181)
I've had this exact conversation so many times over the years.

In truth, you just don't know the tools that well. And that's ok, but as someone who does and regularly does these things in both IDE's and in vim, you're wrong.

But I'm not going to bother trying to convince you, the same way I'm not going to try and convince you that my gf of 11 years is pretty awesome. I don't need you to get better to know that you're wrong.

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by eitland on Wednesday December 21, 2022 @10:05AM (#34081575)
Good for you. 17 years since I met my gf here.

And I started on vim a long time before IntelliJ :-)

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by casey2 on Tuesday December 20, 2022 @03:52PM (#34072373)
Sam could do all that since the 80s. So ~40 years.
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by ajuc on Tuesday December 20, 2022 @05:05PM (#34073358)
It can with a proper regex. Mostly. Depending on the language, your patience, and the amount of false positives you are comfortable with.

I did sth like that (I had bash scripts for common programming "refactorings" and "queries" like "print all classes and methods where this variable is used"). I couldn't use a modern IDE cause we were programming on a legacy linux server through ssh for licencing reasons.

And the (C++) code was written by a guy that learnt C++ and OOP on the job and it showed. Class hierarchies were sometimes 8 levels deep and class variables were reused for different purposes to "save effort on serializing them" :)

So if the user interactions were in the same order and with the same text prompts - a class would inherit them and add some new ones. Even if the old class was just accidentally asking the user similar questions :) So OR_PalNr could mean shelf number in base class and Printer number in descendant, because both times the user was asked to "scan the barcode", while the callstack was a mix of methods from both classes :)

Fun times.

BTW nowadays I mostly work with IntelliJ, but sometimes a script is still the best way to understand the code. For example grepping the git blame output is often very useful. It's never 100% reliable, but it's often good enough.

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by eitland on Wednesday December 21, 2022 @02:07AM (#34077562)
First:

> BTW nowadays I mostly work with IntelliJ, but sometimes a script is still the best way to understand the code. For example grepping the git blame output is often very useful. It's never 100% reliable, but it's often good enough.

I see we are on the same page : )

> It can with a proper regex. Mostly. Depending on the language, your patience, and the amount of false positives you are comfortable with.

For everyone else: in any of the three big Java IDEs, and in a number of other cases, you don't need much patience or tolerance for false positives, at least if your code isn't too unreasonable (with any sufficiently expressive language you can of course always fool it by somehow accessing things dynamically).

> I did sth like that (I had bash scripts for common programming "refactorings" and "queries" like "print all classes and methods where this variable is used"). I couldn't use a modern IDE cause we were programming on a legacy linux server through ssh for licencing reasons.

This is awesome!

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by geysersam on Tuesday December 20, 2022 @03:19PM (#34071909)
Sure, but if function_name is a subword of another_function_name, this would break things :/
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by knighthack on Thursday December 22, 2022 @08:01PM (#34101097)
Why would you want to avoid autocomplete?

And what language do you code in?

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by askvictor on Tuesday December 20, 2022 @03:43PM (#34072240)
Having recently moved from IntelliJ to VS Code, I still miss a few things in the IntelliJ platform (it's overall layout is cleaner, important things are easy to get to), but VSCode has (last I checked) far superior remote debugging support, and is otherwise similar enough once you get past the muscle-memory.
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by fredophile on Tuesday December 20, 2022 @05:31PM (#34073668)
As someone who uses visual studio almost every day I'd say it isn't complete on its own. I can't navigate around a vanilla install that doesn't have visual assist installed as well anymore. If you want a cheaper alternative, workspace whiz is also decent.
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by theshadowmonkey on Saturday December 31, 2022 @11:30PM (#34203618)
Big thing I miss working on VS code and IntelliJ interchangeably. Local history of your changes. Huge differentiator while working on a lot of changes.
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by jansan on Tuesday December 20, 2022 @03:58PM (#34072446)
I have been using IntelliJ IDEs since the early 2000s. Currently I am using WebStorm's (IntelliJ's small JS brother), and the local history feature in combination with the outstanding diff view are just one reason why I could not work without it.
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by theshadowmonkey on Saturday December 31, 2022 @11:32PM (#34203633)
Local history is a game changer. And live templates. The one I use is using a template to automatically put in console log with the context of where(line num and function name) when I type a shortcut like cl
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by quanticle on Tuesday December 20, 2022 @04:17PM (#34072714)
JetBrains' IDEs are great for the languages which they explicitly support, but are often hilariously bad for the languages that are supported with plugins or extensions. For example, the Clojure plugin for IntelliJ, Cursive, doesn't have great macro support, and, one day just stopped being able to run unit tests. Or rather, it'd pretend to run the tests, give a nice green bar, green checkmark and everything, but the tests wouldn't actually have been run. I found this behavior the hard way, when I almost committed a bug. I'd run the test suite, saw that it was green, and thought that the code I'd written had passed all of the checks. It was only during some happenstance manual testing that I noticed "impossible" behavior (i.e. the code behaving in a way that I'd explicitly checked for in tests). Immediately suspicious, I reran all the tests from a REPL on the command line, and saw a whole bunch of failures that Cursive hadn't reported.

Since then, I've been using CIDER on emacs to do Clojure development, and I haven't had any issues.

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by ivanb on Wednesday December 21, 2022 @06:34AM (#34079309)
Cursive is manufactured by Ideogram Limited, not JetBrains.
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by stackbutterflow on Tuesday December 20, 2022 @04:23PM (#34072792)
That's the go-to example whenever IDEs are discussed on HN but I...almost never do that?

I don't think I can count on two hands the number of times I have to do that in a year. As for undoing it I don't think I've ever done it at all. Anyway it doesn't matter because vim + CoC can do it. And for undoing it I guess I simply rename it back to the original name. Actually I just tried and yeah, it works.

One of these day I'd like to sit with a JetBrains user and see how they work. I'm sure it's a great IDE but so far I haven't heard about anything life changing.

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by mehphp on Tuesday December 20, 2022 @04:46PM (#34073111)
This has been my take as well. I can drill-down into third-party packages, rename stuff across files, and use the debugger.

I'm not saying JetBrains isn't fantastic, their products certainly are, but the examples given as to why I should switch are less than convincing. Just use whatever works for you.

It's similar to the flak I get for using an iPhone instead of Android. "You can't customize it!"... I don't want to.. I just want it to make phone calls and browse the web.

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by aussiesnack on Tuesday December 20, 2022 @04:53PM (#34073193)
When I used IntelliJ, for the languages it understood best (then Java and Kotlin), it felt very little like editing text. The sense was much more like interacting directly with an AST. I rarely had to use standard 'text' editing features (oriented around word/sentence/para entities). This was an emergent affordance from all the many language-oriented facilities (all available via keyboard shortcuts) offered, rather than one specific feature.

I actually don't use IntelliJ now for reasons not germane here. I'm on neovim, mostly with Rust and javascript/typescript). This is great in many ways but the ergonomics of editing, even with LSP integration, are much more like editing text, which is more distant from my mental model of the code.

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by worldsavior on Tuesday December 20, 2022 @06:07PM (#34074125)
Or you don't see the potential, or you're not comfortable, or you don't have energy for this. If you did get the hang of it (vim for example), you would probably use it in some kind of way.
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by 8ytecoder on Tuesday December 20, 2022 @07:30PM (#34075037)
There are definitely two kinds of coders - once that think through everything or at least when it comes to names, method definitions and such they just know what they want. Then there are people like me who is never satisfied with the name or the parameters or the order in which they are passed or the name of the parameters or how the function is structured and want to split it further...etc. So I'm constantly reaching for the refactoring tools of IntelliJ.

OR, as you said, since I have mostly used IDEs all my life, I've learnt to leverage these tools and so I don't always aim to write something to perfection the very first time. Instead I use my IDE as a whiteboard and see where it goes.

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by mattmanser on Wednesday December 21, 2022 @05:32PM (#34087284)
I do it all the time. That's the thing, once you can do it without hassle, you do it. Regular scenarios:

1. Refactoring

2. You are experimentally coding and changing names of methods and variables as you realize you need to split stuff up

3. One of your colleagues can't name stuff for shit

The IDE I use makes it so easy it's just a thing I do without even thinking about it.

Another great thing is just highlighting some code and with a simple keypress extracting that code to a new method, with the right return type, params, etc. all done automatically. Not quite right? Highlighted the wrong rows? Press ctrl-z.

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by kryptn on Tuesday December 20, 2022 @04:44PM (#34073075)
Rust in vscode with rust-analyzer: Select the symbol, cmd+shift+p to get the command palette, type rename and select 'rename symbol'. Or right click and pick rename symbol.

You can undo/redo with cmd+z or cmd+shift+z.

replace cmd with ctrl on linux or windows.

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by gamjQZnHT53AMa on Tuesday December 20, 2022 @08:11PM (#34075402)
F2 is also the shortcut in vscode
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by patrick451 on Tuesday December 20, 2022 @05:40PM (#34073793)
First, I almost never do this, so whether I can or not isn't really a selling point. That said, emacs+lsp-mode handles this just fine, at least for c++.
Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by sad-vscode-user on Wednesday December 21, 2022 @01:11AM (#34077281)
Switched this year to VSCode and the quality of most LSPs for VSCode is surprisingly good. Regarding your example: Just rename again. I can tell countless examples of Webstorm failing hard compared to VSCode.

So, from the technical point of view I would say VSCode is equally good.

What I miss most is the UX. Once you get used to the Jetbrains IDEs, their usability is really awesome.

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by abareplace on Wednesday December 21, 2022 @01:31AM (#34077384)
* enter the current and the new names,

* turn on the Match whole word and Match case modes,

* review the found occurrences;

* press the Replace button.

https://www.abareplace.com/blog/blog_rename_method/

Disclaimer: I wrote this program.

Re:Ask HN: Programs that saved you 100 hours? (2022 edition) by michaelcampbell on Wednesday December 21, 2022 @11:49AM (#34083058)
yeah, I'm an emacs person and I still use it for a lot of things, but I also am a proud paying customer of the entire Idea suite; I use PyCharm, RubyMine, IntelliJ and DataGrip on a regular basis.

And worth every penny, for me.