Skip to content

Conversation

@aautotte
Copy link

@aautotte aautotte commented Aug 22, 2025

Update recommended line length to 120 characters in coding standard

@jrintaha
Copy link

jrintaha commented Sep 4, 2025

How many characters of code per line does the average developer's editor show in a single window with a comfortable font size and reasonably sized display? For me it's about 270, but I almost always have (at minimum) a vertical split, so the effective comfortable character count drops to ~135. 120 is quite close to that.

But I suspect most people have bigger displays or slightly smaller font sizes. Do we have any guesstimates? I'd prefer to base the recommendation on something other than "seems like a nice round number".

What I am attempting to say is that I am all for increasing the line length, as 80 is silly on a modern display; discounting the case that you're expected to have 3-4 vertically split windows at the same time. But should the limit actually be a little bit higher than 120?

@fbhaiyat-silabs
Copy link

I think the safe default should still be 80 from portability point of view and also side by side diffs. Many open source projects still limit to 80 characters (google c++ as an example, PEP8 etc.)

@aautotte
Copy link
Author

aautotte commented Sep 4, 2025

Portability isn’t really a factor for us. We’re not integrating this code into other SDKs or external code bases, so line length has no impact on portability in our case.

As for the claim that “many open source projects still enforce 80”: that’s true in some ecosystems (e.g., Python’s PEP8, some older Unix projects), but the trend is clearly shifting. A lot of large projects have relaxed the limit:

Google C++: 100 chars

Java (Oracle): 100 chars

.NET / C#: often 120 chars

Linux kernel: no longer treats 80 as a hard rule; maintainers explicitly allow 100–120 when it improves readability

So while 80 is still common, it’s not the universal default anymore. Given modern displays and tooling, it seems more practical to align with the 100–120 range, which balances readability with editor flexibility.

@mananni-silabs
Copy link

80 has proved to be too small over the years, I am glad we are bumping it to 120.

@r-slabs
Copy link

r-slabs commented Sep 12, 2025

I know that:
1/ Python has 79 characters https://peps.python.org/pep-0008/
2/ Pythons black formatter has 88 https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
3/ Google C++ style guide suggests 80, not 100 https://google.github.io/styleguide/cppguide.html#Line_Length
4/ Kernel suggests use of 100 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bdc48fa11e46f867ea4d75fa59ee87a7f48be144 (not upto 120)
5/ Rust suggests using 100 characters https://doc.rust-lang.org/beta/style-guide/index.html#formatting-conventions
5.1/ imo, Rust is also controversial in suggesting to use spaces over tabs.

I see the benefits of having 120 on a wide screen monitor and high res monitors, but we humans (or is it just a mortal like me?) aren't used to such drastic changes in eye movements and I suggest we limit to increasing it by 25% (i.e., 100) instead of 50% increase from the current limitations

@silabs-raashid
Copy link

I've been using line-length of 120 for quite a few years now in my projects. It great improves code readability especially for those std::chrono<> type situations in C++ (the list of specifiers only keeps on increasing there) and in Python when one starts using type hints.

100 is good but there are situations where I felt that the leeway of a few more characters was way better. (I even had two rulers rendered in my IDE at one point, one at 100 and the other at 120, 100 being the warning point). I vote for 120.

@conq
Copy link
Contributor

conq commented Sep 25, 2025

Hi @aautotte !

Thanks for the PR!. We just had a vote in the SW arch meeting and we agree to increase the length. However, the majority wants a line length of 100, not 120. Could you update this PR, or make a new one for 100?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants