Deutsch English Français Italiano |
<vps9nd$3li98$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Richard Harnden <richard.nospam@gmail.invalid> Newsgroups: comp.lang.c Subject: Re: Which code style do you prefer the most? Date: Fri, 28 Feb 2025 12:21:01 +0000 Organization: A noiseless patient Spider Lines: 107 Message-ID: <vps9nd$3li98$1@dont-email.me> References: <vpkmq0$21php$1@dont-email.me> <vpl62m$250af$1@dont-email.me> <87frk10w51.fsf@onesoftnet.eu.org> <vpn8vs$2jmv1$1@dont-email.me> <vpn92i$86q$1@reader1.panix.com> <vpnfmn$2ksdj$1@dont-email.me> <vpni33$2ld5k$1@dont-email.me> <vpnrld$2mq8h$2@dont-email.me> <vpourn$30a9h$1@dont-email.me> <vpq1es$35inm$1@dont-email.me> <vprtvs$3jfqu$1@dont-email.me> <vps85m$3l1rq$1@dont-email.me> Reply-To: nospam.harnden@invalid.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 28 Feb 2025 13:21:02 +0100 (CET) Injection-Info: dont-email.me; posting-host="eb799fad08c26d0463ce12a98da84c6d"; logging-data="3852584"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/49/dfVCGfL1CvEfVFkAQy/VyQoIRgxzw=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:9+DB5q0T3PvZ0bUd4iE+Agm0C6E= In-Reply-To: <vps85m$3l1rq$1@dont-email.me> Content-Language: en-GB Bytes: 5653 On 28/02/2025 11:54, David Brown wrote: > On 28/02/2025 10:00, Janis Papanagnou wrote: >> On 27.02.2025 16:47, David Brown wrote: >>> On 27/02/2025 06:57, Janis Papanagnou wrote: >>>> On 26.02.2025 20:56, David Brown wrote: >>>>> On 26/02/2025 18:13, Janis Papanagnou wrote: > > (I'm snipping part of this - I don't think it is really going anywhere, > and certainly not anywhere topical for the group!) > >>> Doing too much in >>> one line of code makes it hard to understand - regardless of how many >>> characters it actually uses. >> >> I think we should abandon speaking about it in terms of characters. >> > > Agreed. > >> (I think we agreed that readability is the key, not a hard or soft >> column limit; typically used number of columns are nonetheless based >> on cultural - you may say also technical; still based on cultural - >> sensible heuristics. But habits seem to run out of control "lately".) >> > > Yes. > >>> Taking something that is logically one >>> operation or expression and artificially splitting it into two (or more) >>> lines to suit an arbitrary line length limit also makes the code hard to >>> understand. [...] >> >> This may be the case or not. - That's the whole point; to organize the >> code to become clear. - A split may make it even better readable. (But >> a _misplaced_ split may make it worse.) > > Sure. It is the "artificial" splitting merely to fit some line length > rule that is the problem, not splitting in itself. > >> >> Is that split in your opinion reducing readability...? >> >> if (sscanf (mutations, "r:%u,g:%u,a:%u,d:%u", >> &mutation_rates.base, >> &mutation_rates.genesis, >> &mutation_rates.aging, >> &mutation_rates.death >> ) != 4) >> >> or would you prefer it for (better?) readability to be in one line? >> > > Splitting is fine here - it is natural and fits the flow of the code. > > I might prefer to write it as : > > const int matches = sscanf (mutations, "r:%u,g:%u,a:%u,d:%u", > &mutation_rates.base, > &mutation_rates.genesis, > &mutation_rates.aging, > &mutation_rates.death > ); > > if (matches != 4) { > > since the "!= 4" bit looks a bit lonely and out of place in your code. > But that is perhaps just splitting hairs :-) > > > >>> >>>> Myself I usually operate on a minimum of two physical screens, and >>>> (with my font setting) each one capable of displaying two 80-column >>>> windows side by side. >>> >>> That seems small to me. >> >> Do you mean my screen or my default window size setting? >> >> I cannot help; I'm used to the two 24" screens that I have, and my age >> and health does not allow to regularly use font's below 10pt (or so). >> > > I also have two 24" screens (on this computer), and my eyes are also not > as good as they used to be. (In my youth, I used to write my notes on > 2mm graph paper - normal lined paper seemed a waste of space to me.) > >>> I have no problem with two approximately >>> 120-column windows side-by-side in my IDE, >> >> This actually explains your preferences; elsethread I wrote about my >> observations of people using larger defaults for window sizes, and >> specifically that I've observed IDE users to work with larger default >> window sizes also regularly don't mind writing code with (even much) >> longer lines. > > I don't go overboard on line length, but I do like to have more room > than 80 characters, and I don't like hard limits. One factor in this is > that a fair bit of my development is in C++ (on small embedded systems), > and namespaces and classes mean that the average full identifier length > is a fair amount longer than in C - thus it is natural for lines to be > longer. Have your mental margin-bell ding at around 75 characters, and aim to thow a new line as soon a you can?