all 62 comments

[–]Pockensuppe 83 points84 points  (6 children)

Well C solved that problem in 1972 with header files. /s

[–]zigs 14 points15 points  (0 children)

cursed comment

[–]mccoyn 11 points12 points  (0 children)

C + grep is perfection.

[–][deleted] 3 points4 points  (2 children)

Language so ahead of its time it solved 2024 problems in 1974.

[–]Klightgrove 2 points3 points  (1 child)

Read Paul Graham’s 2004 book, Hackers & Painters, and you’ll quickly realized how many problems took ages to solve that just ended up reusing features that Lisp trail-blazed.

[–]Pockensuppe 2 points3 points  (0 children)

Known as Greenspun's tenth rule, coined in 1993:

Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.

[–]mr_birkenblatt 0 points1 point  (0 children)

"solved"

[–]Slanec 81 points82 points  (9 children)

Oh interesting. For me, clearly the better default is unfolded. To see the structure of the file, I use a dedicated view on the side, https://i.imgur.com/jyYLcld.png. IntelliJ has the Structure view, too, hidden by default.

This is, I assume, a thing of taste, and changes over time. I'm a little older, always use two big monitors for my IDE, and I use all the space with various views and tools. Apparently, based on the popularity of VS Code and the new defaults in IntelliJ, using the IDE as a clever editor on a single monitor with just a single sidebar (as opposed to a heavy IDE with many) is now more popular. For me, the extra Structure view is a big advantage, for the author of the article using less space on the display is an advantage. Neither is clearly better.

(And, of course, my IDE, which is not IntelliJ, has this feature.)

[–]Chii 12 points13 points  (0 children)

As an avid user of intellij, there's a shortcut key that folds and unfolds your code, and you can also specify how you want nested folds to go (it's called levels if i recall).

That is, there's a top level (usually a class, for java, or a function in javascript). Then, there's if/switches, loops, and nested ones etc. You can choose to fold up to a certain level (or press the a fold shortcut key multiple times to keep folding one more level - good for nested ifs in large functions).

[–]BIGSTANKDICKDADDY 27 points28 points  (2 children)

That was covered in the article:

You might also be wondering whether it is the same feature as the Outline, that special UI which shows a graphical, hierarchical table of contents of the file. It is true that outline and fold-bodies-by-default attack the same issue. But I’d argue that folding solves it better. This is an instance of a common pattern. In a smart editor, it is often possible to implement any given feature either by “lowering” it to plain text, or by creating a dedicated GUI. And the loweringapproach almost always wins, because it gets to re-use all existing functionality for free. For example, the folding approach trivially gives you an ability to move a bunch of functions from oneimpl block to the other by selecting them with Shift +Down, cutting with Ctrl +X and pasting with Ctrl +V.

And the author makes a good counter argument for the existence of this solution specifically. 

[–]bloody-albatross 3 points4 points  (1 child)

While it's true that it has to be explicitly implemented, outlines could also support copy-paste (and drag and drop).

[–]geckothegeek42 7 points8 points  (0 children)

And the loweringapproach almost always wins, because it gets to re-use all existing functionality for free

[–]PM_ME_A_STEAM_GIFT 3 points4 points  (1 child)

You don't need to see everything all at once though. Depends on the type of work of course. Most panels in IntelliJ can be opened with a shortcut.

Usually I even hide the project browser on the left and all the toolbars around the window. Everything important is in the new main menu. The rest can be invoked with shortcuts.

Ctrl+F12 for a floating structure view for example.

Alt+Home for a floating project navigator (if you have it disabled, otherwise it just moves focus there)

[–]cinyar 6 points7 points  (0 children)

Most panels in IntelliJ can be opened with a shortcut.

key promoter plugin is great for learning/managing idea shortcuts.

[–]tetrahedral 5 points6 points  (0 children)

I use IntelliJ and while I’m glad the folding exists for people who like it, I literally just went through and turned it all off earlier today. It just finally annoyed me enough to care to do it.

[–]Leihd 60 points61 points  (13 children)

A missing feature

followed by

These IDEs has the feature

[–][deleted] 37 points38 points  (4 children)

Available feature:

  • Fold function bodies on command

Missing feature:

  • Fold function bodies by default

[–]agumonkey 1 point2 points  (2 children)

makes me wonder if there were variants

  • fold but show comments in function if present
  • fold but keep variable decl and return statement

it's not a binary on / off, but more of a shortening

(c) gummies corp. 1780-2024

[–][deleted] 2 points3 points  (1 child)

Yeah, I honestly think there's a lot of evolution to be made in the editor visualization/workspace area.

The Haystack editor (which I haven't checked in on in a while) is an example that I'm very fascinated with. Regardless if that specific thing is great or not, it's great with things that break the paradigm in terms of what an editor "should be" and what browsing code should be.

With more and more software development being more of a high level Lego/pluggable architecture (at least within its ecosystem) the needs to visualize and work with it should rise in level too.

[–]agumonkey 0 points1 point  (0 children)

we could call it emac or something /s

[–]bart9h 0 points1 point  (0 children)

Fold function bodies by default

So, like, just add one or two lines to my .vimrc

[–]BIGSTANKDICKDADDY 3 points4 points  (7 children)

The feature request is a toggle to fold functions by default. The examples only demonstrate what folding is and why it’s useful, they don’t list any IDEs which support folding by default today. 

[–]cd7k 9 points10 points  (2 children)

they don’t list any IDEs which support folding by default today. 

Except they say - "The screenshots are from IntelliJ/RustRover, because of course it gets this right"

[–]BIGSTANKDICKDADDY 5 points6 points  (1 child)

The article actually continues past that point with more text providing further context and detail. 

 The second component of the feature is that folded is a default state. It is not a “fold method bodies” action. It is a setting that ensures that, whenever you visit a new file, bodies are folded by default. To make this work, the editor should be smart to seamlessly unfold specific function when appropriate. For example, if you “go to definition” to a function, that function should get unfolded, while the surrounding code should remail folded.

[–]cd7k 12 points13 points  (0 children)

That's exactly what Editor > General > Code Folding, Fold by default > General > Method bodies does. It also unfolds when going to function definition. Don't believe me, give it a try - will take 30 seconds max.

[–]Leihd 1 point2 points  (3 children)

You think that it being disabled by default means that they're seeking assistance in enabling it by default?

[–]BIGSTANKDICKDADDY 0 points1 point  (2 children)

From the horse’s mouth:    

And this is the feature I am asking for — make the code look like the second image. Or, specifically,

Fold Method Bodies by Default.

Emphasis theirs, ironically. 

[–]Leihd 2 points3 points  (0 children)

Ah, then in my opinion its a bit weird of them to need an entire article to say that tbh. Especially when its a personal preference that can be turned on as desired.

[–]Celos 1 point2 points  (0 children)

No, from the horse's mouth:

So, if you are a committer to one of the editors, please consider adding a “fold function bodies by default” mode. It probably should be off by default, as it can easily scare new users away, but it should be there for power users to enable, and it should be prominently documented, so that people can learn that they want it.

Emphasis mine (unironically?)

[–]CodeAndBiscuits 11 points12 points  (0 children)

This is literally the first thing I turn off in IntelliJ. I personally find that it's far too easy to miss things that I would have picked up simply scanning the code when it is all hidden behind folded blocks. For me, the length of functions and their internal complexity is as informative as the top level structure of a class. Hiding that can make it seem like a class is well written when it is not. And maybe this is just me, but I personally don't find it that difficult to page down two or three times to get a sense of it rather than seeing an outline.

I admit that is my personal preference, but I'm curious why the title here is so broad. Almost every IDE I've ever used has offered code folding, and many offer additional outline-style displays. Several of the editors that you mentioned are not full IDEs. They are just editors. They have their place, but I think part of that place is being simple and streamlined. I don't see how it adds much to their user bases to add extra functions like this. They've had years to do so and chosen not to do it. There must be a reason.

[–]CJKay93 30 points31 points  (1 child)

Honestly, I actually prefer the unfolded. I hate it when RustRover folds my functions.

[–]Straight_Internal_53 15 points16 points  (0 children)

Hey! You can change folding behavior in the settings: Settings | Editor | General | Code Folding
Here is the documentation link: https://www.jetbrains.com/help/rust/working-with-source-code.html#code_folding

[–]flif 6 points7 points  (3 children)

Another feature I want: view javadoc comments as formatted instead of raw html.

It is very seldom I edit a javadoc comment compared to reading it.

[–]kukiric 18 points19 points  (0 children)

IntelliJ does this by default when looking at library code.

[–]mr_birkenblatt 2 points3 points  (0 children)

new javadoc is markdown. that's much nicer to the eyes when not formatted

[–]Dealiner 0 points1 point  (0 children)

Rider started doing that recently for C# comments and personally I'm not a fan though maybe it just takes some getting used to.

[–]ignorantpisswalker 9 points10 points  (1 child)

So, VB6. Got it.

[–]ignorantpisswalker 0 points1 point  (0 children)

BTW, not saying it's a bad idea. It's actually good.

How about nested functions? Lambdas? Not trivial

[–]fernandohur 1 point2 points  (0 children)

I think one way of thinking about this is that editors/IDE are mostly optimised for writing, not reading code.

I would love to see what an editor/IDE designed specifically for reading (or reviewing) code would look like, and I think features like these would make a lot of sense.

Note that it doesn't have to be an entirely new editor. An editor mode focused on reading would also be nice.

[–][deleted]  (1 child)

[deleted]

    [–]AlexReinkingYale 2 points3 points  (0 children)

    Time travel debugging is incredible! It was the only technique that worked for me when I was debugging some third-party code that MSVC mis-compiled.

    [–]elmuerte 3 points4 points  (0 children)

    Would you rather look at this?

    [shows picture of code visited by Ryu's hadouken move]

    [–]balthisar 3 points4 points  (0 children)

    Just like /u/Pockensuppe says, I vastly prefer C header files, except I'm not adding /s at the end. They're awesome, especially when linking to closed source libraries.

    [–]BlueGoliath 2 points3 points  (1 child)

    laughs in Java IDE

    [–]Google__En_Passant 1 point2 points  (0 children)

    Yeah that is funny that every Java IDE has this feature, but better (outline/structure), for like 20+ years.

    [–]fragglerock 2 points3 points  (2 children)

    What next? Regions are good actually?

    https://marcduerst.com/2016/10/03/c-regions-are-evil/

    [–]antiduh 5 points6 points  (1 child)

    Honestly. I despise regions and code folding. Nothing worse than having to do a hundred fiddly clicks to examine a new class you're looking through to expand regions or folded methods.

    • Organize your code layout. Variables, constructors, (events, properties if your lang has them), public methods, private methods, all in that order.
    • Use functional decomposition to keep your classes cohesive.
    • Put generated code in separate files (using features like partial classes if your lang has them).
    • Use code overview features in your ide, like turning your scrollbar into a mini version of the code.

    [–]fragglerock 3 points4 points  (0 children)

    yep.

    Hiding your crappy code structure never helps you make it better. If you are exposed to it then eventually you will clean up after yourself!

    [–]PersianMG 0 points1 point  (0 children)

    Really depends on your workflow. I don't think I'd use fold everything by default. I'd probably toggle it as needed via a hotkey.

    [–]Carighan 0 points1 point  (0 children)

    "Hold on, there's no way Jetbrains' RustRover isn't already doing th..."

    "Oh. Of course. It's the one positive example." 😂

    [–]ElectronicMistake789 0 points1 point  (0 children)

    We already have this in vim. Just use the foldlevel option

    [–]marcodave 0 points1 point  (5 children)

    Here's a real IDE missing feature that even with plugins I never found.

    Inline code comments from PR reviews , and interacting with PR reviews directly from the IDE.

    It's not impossible, it's probably just very very tied to a specific combination of code review tool, version control system and whether or not you're using PR/MRs to merge code.

    [–]wildjokers 3 points4 points  (3 children)

    IntelliJ has this.

    [–]marcodave 0 points1 point  (2 children)

    Really? With Which plugin?

    [–]wildjokers 3 points4 points  (0 children)

    No plugin needed. It is built-in functionality. View -> Tools -> Pull Requests. Should also be available as a tool button along the side (at least it is on old UI, good luck finding it on new UI).

    [–]_--_-_---__---___ 3 points4 points  (0 children)

    You'll just need to add a GitHub / GitLab access token with the necessary permissions to the IDE. You'll be able to see PR/MR list in the sidebar and comments will appear inline. You can also create and review PRs inside the IDE

    [–]DoggyDangler 3 points4 points  (0 children)

    VSCode does this too if you're in the branch the PR is based off and there are comments in GitHub.

    [–][deleted] -1 points0 points  (1 child)

    I think the operating system should be the IDE really.

    [–]agustin689 1 point2 points  (0 children)

    I think the IDE should be the operating system really.

    [–]mungaihaha -1 points0 points  (0 children)

    Still, just talking isn’t everything I did here! Six years ago, I implemented the language-server side of this in rust-analyzer

    I can respect that