News for hackers. Stuff that matters.
Re:What I learned in 2017 writing Go by haberman on Wednesday January 03, 2018 @01:49PM (#16063814)
While I tend to agree with this, I think a counterargument is: long functions mean more local variables that are in scope. This makes it harder to understand the interaction between different variables at different scopes. A separate function introduces a separate namespace, and all the data flow in and out has to be explicit, through function parameters/returns.
Re:What I learned in 2017 writing Go by Waterluvian on Wednesday January 03, 2018 @04:41PM (#16065470)
I would love an IDE that unrolls subroutine calls inline as a view mode.
Re:What I learned in 2017 writing Go by meken on Thursday January 04, 2018 @12:56AM (#16068359)
I'm working on this very thing right now as a side-project. It unrolls functions, if statements, for/while loops, etc and uses jupyter notebooks to do so AND allows you to interact with the result. Kind of like an interactive log.

It's early days but I'm making progress! https://github.com/ebanner/pynt

Re:What I learned in 2017 writing Go by WaxProlix on Wednesday January 03, 2018 @05:30PM (#16065949)
Peek definition does this, sort of. Definitely exists in VS and VS Code, and probably in the JetBrains things.
Re:What I learned in 2017 writing Go by dec0dedab0de on Wednesday January 03, 2018 @04:53PM (#16065596)
That is really interesting. They would have to be made to stand out somehow, but it might be helpful. I can only imagine what some library heavy code would look like.
Re:What I learned in 2017 writing Go by vram22 on Wednesday January 03, 2018 @02:52PM (#16064436)
Yes, agreed about the counter-argument. See my nearby comment here:

https://news.ycombinator.com/item?id=16064412

I think the important thing is that modularity (breaking up longer functions into shorter ones) helps, but only if not done blindly. One has to spend some time doing it, since there are many possible ways it can be done, and some of them will be better than others. So it can pay off in the long term, but only if one is willing to put in the effort and time, and be ready to throw away some not-so-good attempts. I've done this sometimes and seen that it does help.

Re:What I learned in 2017 writing Go by jeremiep on Wednesday January 03, 2018 @05:16PM (#16065799)
That's not always true, the best cases for inlining one-use functions is when you don't introduce new local variables.

I've seen 1k LoCs functions that were incredibly easy to understand, and 10 liners that were complete gibberish messes.

I do however agree that declaring new variables every 10 lines over hundreds of lines would be hell to follow.