473,698 Members | 2,942 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What's your maximum line size preference?


Do you have a preference on maximum line width for C++ code?

I've seen the craziest debates on this most silly of topic.

I have witnessed engineers spent oodles of time fiddling with line
breaks just to get it right. I find in general a prescriptive rule
makes for markedly less readable code, which unfortunately is a
subjective argument, however, the waste of time modifying code when it
does not need to is not.

I'm interested in knowing what you'all do.

G
Oct 9 '08
53 12115
On Oct 10, 4:57*pm, Victor Bazarov <v.Abaza...@com Acast.netwrote:
James Kanze wrote:
On Oct 10, 11:18 am, Juha Nieminen <nos...@thanks. invalidwrote:
James Kanze wrote:
What does interactive programming (whatever that means) have
to do with it?
I meant interactive text editing. With text editing programs.
But I don't see where that really makes a difference. *If I'm
editing with a card punch, I have an even more rigorous set of
constraints.
Are you *reading* the cards? *If you're not, how is
*readability* involved? *Wasn't that the issue the OP brought
forth? *The cards need to be readable, but not by a human.
Not in the sense we use the term. The point is that the 80
character limit is imposed technically, and that the reason
technical issues impose it ultimately goes back to the punched
card (which also imposed it technically). I certainly don't
think that there's a hard limit that says that 79 characters is
perfectly readable, and 81 isn't---there are even special cases
(e.g. table initializations ) where the 80 character limit
reduces readability (although most of the time, you really want
even less).

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Oct 11 '08 #31
On Oct 10, 7:51*pm, Hendrik Schober <spamt...@gmx.d ewrote:
James Kanze wrote:
[...]
* * * * * * * * * The problem is things like the sizeof paper,
for example (my printer won't handle much larger than A4).
* I can't remember the last time I printed code.
Code review.

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Oct 11 '08 #32
On Oct 10, 11:42*pm, "Default User" <defaultuse...@ yahoo.comwrote:
Martin Eisenberg wrote:
James Kanze wrote:
(On the other hand, like everyone else, I'll copy/paste my
code directly from the original source, so if I post actual
code from elsewhere, it is wider. *And its formatting does
get messed up.)
Your newsreader may have an option not to wrap outgoing lines.
His news system is Google Groups. That doesn't have many options.
And even if it did, I don't know the width of the window the
reader will have---if my outgoing software doesn't wrap it, his
reading software might. It's just common politeness to format
your outgoing posts to a maximum of, say, 64 characters
(allowing quoted sections to be correspondingly longer).

Similarly, if you're publishing in a magazine, they're likely to
impose a limit, so that the code will not be wider than one
common. Something like 40 characters.

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Oct 11 '08 #33
James Kanze wrote:
On Oct 10, 7:51 pm, Hendrik Schober <spamt...@gmx.d ewrote:
>James Kanze wrote:

[...]
>> The problem is things like the size of paper,
for example (my printer won't handle much larger than A4).
> I can't remember the last time I printed code.

Code review.
What's one of those ? :)

--
Ian Collins
Oct 11 '08 #34
Jeff Schwab wrote:
80. Period. Please. It's a hard and fast rule.
Does that count the newline at the end of the line or not?
Oct 11 '08 #35
After takin' a swig o' grog, Ian Collins belched out
this bit o' wisdom:
James Kanze wrote:
>On Oct 10, 1:42 pm, Chris Ahlstrom <lino...@bollso uth.nutwrote:
>>After takin' a swig o' grog, James Kanze belched out
this bit o' wisdom:
>>>So as a general rule: a maximum of 80 characters, total, and
between 60 and 70, without the leading indentation.
>>Check out Ch. 32 of BEAUTIFUL CODE, entitled "Code in Motion".
Here's the article it is based on:
>> http://www.perforce.com/perforce/papers/prettycode.html
>> Seven Pillars of Pretty Code
>> Christopher Seiwald

Which starts well, and gets worse as it goes along, ending up
with some of the worst coding practices imaginable.
I'm with you there, horrible.

Use goto to avoid indentation, what was he thinking?
I agree with that, and would refactor to avoid excessive indentation.

The book chapter, as far as I can tell, does not recommend gotos to
avoid indentation <grin>.

--
For your penance, say five Hail Marys and one loud BLAH!
Oct 11 '08 #36
After takin' a swig o' grog, James Kanze belched out
this bit o' wisdom:
Not in the sense we use the term. The point is that the 80 character limit is imposed technically, and that the reason technical issues impose it ultimately goes back to the punched card (which also imposed it technically). I certainly don't think that there's a hard limit that says that 79 characters is perfectly readable, and 81 isn't---there are even special cases (e.g. table initializations ) where the 80 character limit reduces readability (although most of the time, you really want even less).
(Reformatted for readability.)

--
Q: Why shouldn't I simply delete the stuff I never use, it's just taking up
space?
A: This question is in the category of Famous Last Words..
-- From the Frequently Unasked Questions
Oct 11 '08 #37
Juha Nieminen wrote:
Jeff Schwab wrote:
>80. Period. Please. It's a hard and fast rule.

Does that count the newline at the end of the line or not?
Not usually. :)
Oct 11 '08 #38
Jeff Schwab wrote:
Juha Nieminen wrote:
>Jeff Schwab wrote:
>>80. Period. Please. It's a hard and fast rule.

Does that count the newline at the end of the line or not?

Not usually. :)
Well, that may present a problem with lines which have exactly 80
characters (without counting the newline at the end): Some editors will
wrap and then print the newline, which will cause the next line to look
empty, while others won't do that.
Oct 11 '08 #39
Juha Nieminen wrote:
Jeff Schwab wrote:
>Juha Nieminen wrote:
>>Jeff Schwab wrote:
80. Period. Please. It's a hard and fast rule.
Does that count the newline at the end of the line or not?
Not usually. :)

Well, that may present a problem with lines which have exactly 80
characters (without counting the newline at the end): Some editors will
wrap and then print the newline, which will cause the next line to look
empty, while others won't do that.
I've never seen an editor do that, although I have seen command-line
shells do it; do you have a particular editor in mind?

Emacs wraps after only 79 characters by default, because it adds a
pre-emptive backslash (or other symbol) to show the wrapping. I see
that as more of a shortcoming of the editor's default configuration than
an issue with the code, though. If I worked in an environment where it
were an issue, of course, I wouldn't mind limiting the code to 78
columns, in the same way that I limit it to 72 characters when including
it inline in email, or 68 characters when posting on Usenet.
Oct 11 '08 #40

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1472
by: Robert | last post by:
dear sir: I have read the c++ primer plus 5 book, and do the chapter 12 programming exercises question 5, but the average_wait have negative result. I don't understand why? here is the code, thank you anyone replay me.:) /************************* customer.h *************************/ #ifndef CUSTOMER_H_ #define CUSTOMER_H_
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8611
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8904
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7741
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.