News for hackers. Stuff that matters.
Re:Applying the Gestalt Principles to Code by foreigner on Sunday May 05, 2019 @09:47AM (#19832778)
I've occasionally fantasized about a code editor that doesn't allow scrolling, so you're forced to break code up in to pieces that fit on a single screen. I think that would greatly improve readability.

That would also help with one of the main arguments against "visual" programming languages - they get too hard to read as programs get larger. Simply don't allow scrolling or zooming the source.

Re:Applying the Gestalt Principles to Code by zild3d on Sunday May 05, 2019 @12:51PM (#19833670)
The idea that visual programming languages get too hard to read as programs get larger doesn't really resonate with me.

Just like written code, you need to create higher level abstractions. In simulink for example, you might have 1 top level box called a "Radar". You drill down into that, and find lower level components like an RF transmitter, but still those are abstractions that you can drill down into [0]

Yes if you squeezed all low level implementation onto one screen it'd be hard to read, but same as if you put all low level c code in one giant file without any abstractions.

[0] https://www.mathworks.com/help/examples/simrf/win64/RadarSys...

Re:Applying the Gestalt Principles to Code by foreigner on Sunday May 05, 2019 @01:20PM (#19833806)
I agree! However often you see arguments against visual programming languages where they show a screenshot that looks like a giant mess with tons of stuff in it. My point is if the editor didn't allow scrolling or zooming that would force the developer to break things down in to components as you describe.
Re:Applying the Gestalt Principles to Code by scottLobster on Sunday May 05, 2019 @10:38AM (#19833005)
While I admire the intent, I can definitely see bad developers simply writing long functions in multiple "parts" to get around the system.

  public void shittyLongFunctionPart1(...) { //First line of screen 1
  ..
  ..
  shittyLongFunctionPart2(...);
  }//last line of screen 1

  public void shittyLongFunctionPart2(...) { //First line of   screen 2
  ..
  ..
  shittyLongFunctionPart3(...);
  }//last line of screen 2
Yet another example of culture trumping process. At the end of the day you need developers who give enough of a shit about their craft to write readable/testable/maintainable code. And that sucks because it seems relatively rare.
Re:Applying the Gestalt Principles to Code by aasasd on Sunday May 05, 2019 @01:29PM (#19833844)
Well, descriptive names are the first step, and I see they're already there.
Re:Applying the Gestalt Principles to Code by enriquto on Sunday May 05, 2019 @11:34AM (#19833297)
> I've occasionally fantasized about a code editor that doesn't allow scrolling, so you're forced to break code up

But this is easily hackable around. What you really want is a programming language that does not allow functions longer than 25 lines.

Re:Applying the Gestalt Principles to Code by foreigner on Sunday May 05, 2019 @11:40AM (#19833321)
Ha ha I guess you're right! I can't be bothered to switch to a different programming language just for this feature tho :-)

Anyway then you would get stuck policing exactly how long a "line" is, do comments count, etc...

Re:Applying the Gestalt Principles to Code by enriquto on Sunday May 05, 2019 @01:05PM (#19833728)
> Anyway then you would get stuck policing exactly how long a "line" is, do comments count, etc...

A line is 80 characters. Indent is 8 spaces. Comments do not count.

Re:Applying the Gestalt Principles to Code by foreigner on Sunday May 05, 2019 @01:21PM (#19833813)
Case in point, I prefer an indent of 4 spaces.
Re:Applying the Gestalt Principles to Code by enriquto on Sunday May 05, 2019 @02:12PM (#19834095)
It does not matter. However hard you "prefer" the value of pi to be 3, it will stay an irrational number. Eight-space tabs are a constant of the universe.
Re:Applying the Gestalt Principles to Code by indentit on Sunday May 05, 2019 @03:07PM (#19834392)
not in this universe they aren't - many popular applications indent 4 spaces by default when pressing the Tab key, and render physical tabs as four spaces, for example github ;) tabs of 8 space width are a legacy travesty that wastes space :)
Re:Applying the Gestalt Principles to Code by enriquto on Sunday May 05, 2019 @03:18PM (#19834449)
Ours is indeed a decadent universe that is slowly being corrupted by powerful forces of evil (such as the 4-space tab brain damage of github). But there are still beacons of light to guide us:

https://www.kernel.org/doc/html/latest/_sources/process/codi...

https://wiki.musl-libc.org/coding-style.html

https://www.freebsd.org/cgi/man.cgi?query=style&sektion=9

https://man.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man9...

Re:Applying the Gestalt Principles to Code by AlotOfReading on Sunday May 05, 2019 @01:59PM (#19834030)
That doesn't do anything to reduce the complexity of code, it just means you have a lot more functions to read and the actual logical units distributed across random sets of them to fit the arbitrary line limit. Some of the worst codebases I've ever seen had many small functions because the logical boundaries of the problem domain didn't match the logical boundaries of the source code.
Re:Applying the Gestalt Principles to Code by colordrops on Sunday May 05, 2019 @11:50AM (#19833383)
Are you programming on your phone in landscape mode?
Re:Applying the Gestalt Principles to Code by enriquto on Sunday May 05, 2019 @01:06PM (#19833733)
No. I use a terminal emulator with the default size it opens with.