1

Right now, viewing code on Stack Overflow is quite inconvenient as it's displayed in a small text box where lines don't wrap.

I hope a "code zoom" feature can be added - similar to the one available in Discourse forums.

It makes a huge difference - and really I think we deserve to view code in a more human-oriented way by now in 2023.

Here's an example from Late Night Software forums (hover mouse over the code block to see the 'code zoom' icon in the upper right corner):

https://forum.latenightsw.com/t/myriad-tables-questions/389/180?u=leo_r

enter image description here

enter image description here

7
  • 2
    I'm not sure exactly how, and I don't have time to try right now, but it is very likely possible to write a Tampermonkey userscript that would add that feature. If you do build a userscript that does that, consider posting it over on stackapps (a SE site dedicated to user-created userscripts and apps)
    – cocomac
    Commented Feb 16, 2023 at 8:23
  • 3
    I would not call anything Discourse does (sorry Jeff) an example for Stack Overflow. I mean it's 2023, and each and every Discourse site still blinks three times in my browser before showing the content I want to see, after downloading about 6 MB of JavaScript, taking over 500ms to render a page.
    – CodeCaster
    Commented Feb 16, 2023 at 9:58
  • 2
    Your comment confuses me, @CodeCaster. In what year was that behavior ever acceptable? Or were you just reminding us all that it is 2023? I guess that's helpful; sometimes, in the first few months of the new year, I forget what year it is and say/write the wrong one.
    – Cody Gray Mod
    Commented Feb 16, 2023 at 9:59
  • @Cody heh. I just wanted to mention that, so people could calculate that they've had 9 (is it 9 already?) years to fix the reading experience.
    – CodeCaster
    Commented Feb 16, 2023 at 10:02
  • 2
    "... is quite inconvenient as it's displayed in a small text box where lines don't wrap" Line-wrapped code? is that even a thing?
    – Kevin B
    Commented Feb 16, 2023 at 23:09
  • @KevinB "...Line-wrapped code? is that even a thing?" unless i misunderstand what you mean, yes - it's a standard behavior of any code editor (or text editor for that matter)
    – Leo Braun
    Commented Feb 17, 2023 at 1:19
  • 3
    I never turn line-wrap on (menu Document"Line Wrapping" in Geany). It is even more confusing. Especially if there is indentation involved, but not only then. Commented Feb 17, 2023 at 1:40

1 Answer 1

1

How would this make "a huge difference"? As you can see here, that example code snippet would be perfectly readable if posted on Stack Overflow now, save for two extremely long lines, the contents of which aren't really even important to understanding what the code does:

use AppleScript version "2.5"
use scripting additions

use script "Myriad Tables Lib" version "1.0.13"
set tableData to {}
set theNames to {"Harry", "Warren", "Glenn", "Zak", "Clint", "Clark", "Harry", "Warren", "Glenn", "Zak", "Clint", "Clark"}

repeat 5 times
    set thisRow to {}
    repeat 8 times
        set the end of thisRow to some item of theNames
    end repeat
    set the end of tableData to thisRow
end repeat

set columnHeadings to {"1-left, left", "2-right,right", "3-center, center", "4-natural, natural", "5-left,right", "6-right,Left", "7-right,center", "8-center,right"}
set columnWidth to 125
set newTable to ¬
    make new table with data tableData ¬
        column headings columnHeadings

modify columns in table newTable ¬
    columns list {1} ¬
    head alignment align left ¬
    entry alignment align left ¬
    column width columnWidth ¬
    
modify columns in table newTable ¬
    columns list {2} ¬
    head alignment align right ¬
    entry alignment align right ¬
    column width columnWidth ¬
    
modify columns in table newTable ¬
    columns list {3} ¬
    head alignment align center ¬
    entry alignment align center ¬
    column width columnWidth ¬
    
modify columns in table newTable ¬
    columns list {4} ¬
    head alignment align natural ¬
    entry alignment align natural ¬
    column width columnWidth ¬
    
modify columns in table newTable ¬
    columns list {5} ¬
    head alignment align left ¬
    entry alignment align right ¬
    column width columnWidth ¬
    
modify columns in table newTable ¬
    columns list {6} ¬
    head alignment align right ¬
    entry alignment align left ¬
    column width columnWidth ¬
    
modify columns in table newTable ¬
    columns list {7} ¬
    head alignment align right ¬
    entry alignment align center ¬
    column width columnWidth ¬
    
modify columns in table newTable ¬
    columns list {8} ¬
    head alignment align center ¬
    entry alignment align right ¬
    column width columnWidth ¬
    
set tableResult to display table newTable

Besides being of dubious utility, this type of "zoom" has a severe disadvantage: it makes it impossible to read the code in context with the surrounding explanation.

This seems like it would be somewhere between "useless" and "a severe hindrance". Just write the code using sane line lengths. I can easily fit 80 characters on a line in Stack Overflow's code blocks without the need for any vertical scrolling:

MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM

Personally, when I write code in the "real world", I limit line lengths to 100 characters (rather than the traditional 80 characters), but for expository code snippets (as should be posted here), even 80 characters seems more than sufficient.

9
  • 1
    FYI, I need to scroll to see your the end of your line full of Ms (because I'm using a 175% zoom level on SO by default). Although, funnily enough, with both 150% and 200% zoom level, I don't need to scroll (150% because it's small enough, and with 200% the side panel with HNQ & co disappears, which leaves more space for questions & answers).
    – Dada
    Commented Feb 16, 2023 at 9:39
  • @Dada For what it's worth, Stack Overflow (and the entire Stack Exchange network) does not officially support such zoom levels. In fact, no zooming is supported; the site is designed to be viewed only with a 100% zoom. At other zoom levels, many things are subject to breaking.
    – Cody Gray Mod
    Commented Feb 16, 2023 at 9:43
  • 3
    Interesting, I didn't know that. It's pretty exhausting for me to read SO without zooming, and I'd be surprised if I was the only one, so I find it surprising that SO doesn't support zooming...
    – Dada
    Commented Feb 16, 2023 at 9:53
  • 3
    The argument of the "severe disadvantage" is a bit flawed IMO, you only (need to) read the "surrounding explanation" once, maybe twice... And if that explanation is continuously needed to understand/follow the Code, maybe it should be placed as Comment(s) in the Code... Or the User could always open 2 Tabs on the same Page, or even 2 Browser Instances, one for the "standard view" with Question + Answer(s) + Code Block(s), and one for the specific Code Block in Popup or Full Screen...
    – chivracq
    Commented Feb 16, 2023 at 10:48
  • 2
    @CodyGray It's unfortunate that the site does not support some pretty basic accessibility. And I'll point out that on my 4K monitor, with my browser occupying one corner (effectively 1080p and full-screen), I have a horizontal scroll bar. And I don't zoom.
    – sweenish
    Commented Feb 16, 2023 at 18:29
  • 1
    the code example you posted is very hard to read here. even considering that the code was especially carefully formatted to consist of mostly unusually short lines. the claim "two extremely long lines, the contents of which aren't really even important" is especially strange, as naturally you first need to horizontally scroll back and forth to understand if it's "important". plus most code examples contain quite a few long lines that are long enough to enable horizontal scroll.
    – Leo Braun
    Commented Feb 16, 2023 at 22:37
  • 1
    the proposed "code zoom" feature is an OPTION for those who want to actually see and understand code samples in a humanly-readable, convenient way. i find it totally PATHETIC that it's exactly us, developers, who have to struggle in the year 2023 with this kind of archaic, inconvenient, and user-unfriendly way of displaying the code.
    – Leo Braun
    Commented Feb 16, 2023 at 22:37
  • I infer from that comment that you think I am not a human, not a developer, and not even a user. In fact, none of those are true. Really, what you have is an opinion, and I have a different one. There's nothing PATHETIC about that.
    – Cody Gray Mod
    Commented Feb 16, 2023 at 22:51
  • 1
    @CodyGray: like i mentioned, i propose an OPTION that would preserve your preferred way of viewing code - while giving other users an OPTION to view code in a more convenient way for them. i don't understand why this OPTION that doesn't change anything for you - but improves experience for others - would evoke such strong opposition from you. the pathetic thing is that we don't have this OPTION in 2023.
    – Leo Braun
    Commented Feb 16, 2023 at 23:37

Not the answer you're looking for? Browse other questions tagged .