9

Rant!

Why enforce a 90 character limit in code file (C++)

It does not make readability any better..
you either break up functions that barely exceed the limits

or

start making nonsense variable names just because they are short.

Comments
  • 5
    You write ugly code!
  • 5
    1. The line limitation is useful. Have you ever NOT written code in a maximized window? Or on a vertical monitor?

    2. Breaking up functions is good! Having functions do just thing they are named after and leaving other stuff to others is clean!

    3. Nonsense variables? Well, if with sensible variables you talk about Java EE class name style, you have a whole set of other issues. If it's a nesting issue, go back to point 2.
  • 5
    If a function or variable name is 80 characters long, you should really rethink what you are doing in any language.
  • 1
    A line length limit of 90 characters is really ugly. It is ten grapheme clusters more than eighty - wich is the line length limit to actually use!
  • 1
    I feel ya man, writing heavily templated code is pain with the 90 character limit, 150 characters seems to work great though
  • 2
    @HitWRight 150 characters! Are you out of your mind?
  • 3
    Any line character limit is just bullshit because it is arbitrary.
    Whether the code is readable or not will depend on the size of the screen and the font size.

    The right thing to do is to just break up things as they become poorly readable, depending on what the actual code is and not depending on the number of characters in a line.

    10 assignment statements in a line? Break up this shit!

    Some generic class declaration with inheritance? Leave this shit in one line!
  • 0
    @kescherRant well if you don't use vertical monitors, and it does allow for 2 files to be open and read comfortably (no horizontal scrolling), what's the problem?
  • 0
    @HitWRight How small is your font?
  • 1
    Umm, even a tweet is more than 140 characters, what in the world are you saying?
  • 3
    I hope it's 90 characters per line, not per file.
  • 1
    ErrorType Error = FunctionName(const NameStruct& VarName, unsigned char* From, unsigned char* To);

    yes 90 character per line.. including spaces and indents..

    And by breaking up I mean adding additional enter so that this one line of execution is now separated over two lines

    I agree not to have more than 3 variables in a function to have clean code.
    but in certain cases this make no sense to spit up functions.. in this case I'm using a library which uses long function names.

    and it is using one indent of 4 spaces

    should I then name my variables A, B, C?
  • 1
    @Lensflare Couldn't agree more
  • 1
    @Lensflare Also breaking up a line just because you added a few characters makes for bad git commits and harder code review as some small refactoring (e.g. renaming a variable) results in breaking up a line, changing a lot of code without actually changing any functionality.
  • 1
    As a person with impaired vision who prefers 20-22pt font, fuck people who do this with shared projects. Yes, break up that damn function. It doesn't make sense semantically that it's on multiple lines but scrolling horizontally or wrapping code lines is much, much worse. And there are people who program on 14" laptops.
  • 0
    @Lor-inc Way to blame other people for your own problems. Yeah it's nice of other people to consider your needs, but equally you could get a larger screen so you don't push your burden on those who have nothing to do with it. Also unless you're borderline blind, there's plenty you could do so you don't need to increase font size, like getting proper glasses or an eye surgery.
  • 1
    Also, if you really don't want to scroll, every editor has soft wraps.
  • 0
    Short variables != Nonsense, especially in short functions.
    https://kernel.org/doc/html/...
  • 1
    @hitko There isn't a surgery (yet) nor glasses that would solve my problem but I'm not blind.
    With a 29" display, I'm in a similar situation to people with 14" laptops.
    The main question is, what is the minimum screen size that you want to make a dev dependency for your project? IMO it shouldn't be more than 14".
  • 0
Add Comment