68
devTea
170d

Does anyone respect the 80 columns rule when coding?

Comments
  • 6
  • 11
    What is it ?
  • 16
    With me it's usually more of a 120-column suggestion, if it is what I think it is :P
  • 17
    Nope.

    But I don't normally let a line get that long anyway before breaking it apart.
  • 7
    I also wanna know what this is
  • 8
    @R1100 @AleCx04 code only get to 80 col long and get break into new line if more than that

    I think the idea is to support multi screen coding
  • 8
  • 5
    @AleCx04 one of those coding style rules. Where lines should not exceed 80 characters.

    If they do you break them up into multiple lines

    If( some_huge && ass_condition ) {}

    Would turn into

    If (
    Some_huge &&
    ass_condition
    ){}

    Just imagine those being really long lines each
  • 5
    @devTea @C0D4 ahh i see, thank you guys :D

    I must say that I have not been then applying that to my codebases.
  • 17
    This is my opinion about that topic:
    https://devrant.com/rants/1483811
  • 8
    I set project linting rules to soft wrap long lines and use tabs for the projects I start.

    If the line is an array of precalculated values or a string constant let it be.

    If there is too much going on in a line and it is unruly it should get knocked down in code review. If a line is that long it probably should have commenting explaining why the logic is like that. Minimize terse lines.

    I think that the number 80 goes back to number of holes in an IBM punch card. It matters for tradition and if you need to print. Though new editors and IDEs can’t even print. CTRL+P is find a file in the project in VS Code.
  • 6
    No, we don't do that nowadays. However, depending on what language you're using, this might be a Hard requirement

    If you're using a mildly recent IDE, you should bei able to configure it to add (or hide) a linebreak at your convinience...

    Short answer: no, Long answer: your IDE's lying, but if you got to know the trutht, my IDEs Tab Setting would instantly switch to 6 spaces, so to prevent this, I can't tell you!
  • 4
    I try to keep my lines short, but from time to time I write longer than 80 characters. Generally conditions can be long.
  • 6
    Because you never know when you'll be using a VT that is limited to 80 char width. Also, many CLI are limited to 80 chars, because they were designed for VT's. When I say VT, I'm taking about the old yellow or green text CRT's of the last. That is why that rule exists.
  • 4
    my ide enforces it, but it sometimes hurts more than it helps...
    also my ide doesnt get that factory patterns are better when statements are blocks...
  • 4
    Yeah standard video term width was 80 char. Tradition.
  • 5
    I use 80 col as a soft rule so I won't break a line if it's only say 3 characters past, but if it's more than 10 it'll get broken up
  • 5
    Personally I use the "if I might have to come back and find this later" rule. Not really sure what the exact column or character limit on it is, generally just however many fit on my 13" screen at pt 18 font 🤷🏻‍♂️
  • 5
    @M1sf3t that's not a lot of characters
  • 4
    @Krokoklemme not at all. I don't immediately break once it starts running off the screen though. As long as the start of it is still visible then I continue until I get to another "section," for lack of a better word, then I break to a new line there.
  • 6
    Finally some knowing one.
    @iAmNaN

    As standard layout and minimum requirements for VT. Also for headless environments.

    Yes, yes. Originating from that IBM punch card. But well, not used for that in a while.

    @devTea @R1100 @AleCx04
  • 4
    145col here
  • 2
    I don't think you need to make an effort. Just setup you ide to reorganize for you at commit time.
  • 3
    it‘s not 1980. people use ide‘s now.
  • 2
    Yes in most cases, imo reading two lines seems easier than one long line of code with horizontal scrolling.

    Also when I write markup languages, JS, I write with 2 spaces indentation.
  • 4
    @r4ndsen Still people might need to merge a diff in a terminal. Long lines can be really annoying there.
  • 5
    I'd also add in that source files should not have more than 1 kB length so that in addition to a prehistoric terminal, you can also use a 300 baud acoustic modem comfortably.
  • 2
  • 4
    Haven't we had wordwrap for like, forever ?

    On some very cranky systems I do try and limit myself to around 75 characters or less, since above that it tends to auto-wrap and insert newline characters where it shouldn't !

    With my current monitor I can go up to around 230 characters per line, which is great.
  • 2
    @chilledfrogs 120 here as well, prettier does the actual formatting anyway.
  • 3
    @Wack Actually tons of people do actually do that nowadays. 80 columns limit is in the Google style guide along with most every other comapny's style guide I've ever read. If makes reading the code much easier (it has been shown that people have an easier time reading lines between 80 and ~110 characters and a line limit makes it much easier to read when debugging. Plus you can then have two files up at once next to each other on the same screen.

    Setting a character limit ensures you won't have to scroll sideways, which is universally despised.

    Saying no one uses a character limit anymore is flat out wrong.

    Personally I have a default line length of 80 with the exception being some things like URLs. Inline comments I let go to a char limit of 110. For HTML I use a char limit of 110 with an inline comment limit of 120.

    It is not hard at all to implement this standard given things like Prettier and Beautify, and I also just keep a margin line visible in my editor at 80, 110, and 120.
  • 2
    @Krokoklemme 80 is plenty of space for everything except the occasionally exception like base64 dataURI or URLs or online comments or HTML. The limit enhances readability which is a big reason it is in most corporate style guides.
  • 3
    @Nanos 230 characters per line is an abomination.
  • 1
    In C yes, strictly. For other languages, I use the default style guide's/formatter's column limit.

    Shorter lines are easier to skim and allow for multiple files next to each other. Additionally, I dislike both horizontal scrolling and automatic linebreaks in code.
  • 2
    Depends on what it's doing.

    I try to keep everything short and easy, but sometimes there is no way around longer (100 char) lines, and breaking them up can reduce legibility. Especially if there are multiple similar lines; vertically aligning their pieces makes them much easier to read and understand.
  • 3
    @7400 Once an automatic line break is put in it had to be manually removed. If that isn’t a reason to avoid automatically breaking lines I don’t know what is.
  • 2
    Usually but not too strictly
  • 3
    COBOL
  • 1
    @devTea multiscreen when you could simply break the line on a single screen
  • 1
    Yes I use it all the time. It sure as hell is easier, faster, and more convenient to read and edit multiple formatted lines than to side scroll through a shit storm of code.
    Sadly where I worn there are pockets of code where multiple long statements are on a single line and its frustrating as hell. Thank God our IDEs have word wrap, but do you know how irritating it is to try to diff code in Subversion that is all on one line?
    I tried implementing 80 column auto formatting there but my coworkers were annoyed by it in a lot of cases. Raising it to 110 columns left them more satisfied than not.
  • 2
    Nope.

    Ultra wide screens make it useless to have all that empty space.
  • 2
    @h4xx3r not every people use ultra wide tho
  • 2
    extra space to work with just translates to bigger font and less eye-strain. I'd use this little tv I got hooked for code but I haven't played with the settings enough to get text to render very well. Think I my try to hook up the old lcd tv I got thru the vga port and see what that looks like if I ever find the energy to grab my desk from the old house. This rate tho it'll probably get sold with the place 🙄
  • 2
    @devTea true tho
  • 2
    I always do. I can't stand people not reacting the 80col rule. Having to scroll to the right only because a line has > 80cols sucks. It's annoying to read
  • 2
    Though, I noticed today that when I write markdown with 80 column rule, it didn't flow very well on web applications like in our task management.
  • 3
    I generally try to keep it under 100. For most of my code, say 500 lines, only about 10-12 will be past 100 nearing 105-110
  • 3
    @b3b3 You can’t turn soft wrap on?
  • 2
    Partially Because resharper kinda does it for you automatically. However I increased the wrap to 200 because I use a 4k screen.
  • 1
    Yes, and personally, i do 79 chars!
  • 3
    If people follow the 80col guideline, you can fit 3 terminals of code in a regular 16/(9/10) aspect ration screen. On ultra-wide 5 blocks! It still has its advantages.
  • 4
    No way. I am using a widescreen fullhd monitor, not an cga terminal
  • 1
    @irene it's on by default i think bht J don't like it as it always starts at col0 on the next line
  • 2
    I use <80 as a guidline and 100 as a hard limit (makes ci fail at work)
  • 1
    I have bad vision so I use large font on my laptop, which basically makes the editing panel about that wide. I use the 80cols rule, I even write it in style guides if I can. I can probably forgive most style issues, but if I start seeing horizontal scrollbars one of us will leave the project soon.
  • 1
    Hells to the yeah I do
  • 2
    @Lor-inc You don’t turn on soft text wrapping?
  • 1
    @irene It wraps to col 0, and even if it didn't, it still wraps at the weirdest places. I usually have a clause along the lines of "If breaking the line up while maintaining meaningful variable names isn't possible, insert a line feed after an opening bracket or a ternary operator."
  • 2
    i respect the "lines should not outrun the width my window has when showing two files side by side (on a single monitor)" rule.
  • 1
    @Midnigh-shcode most of the time it’s 80 cols on standard laptop screen
Add Comment