Deutsch   English   Français   Italiano  
<vps85m$3l1rq$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: Which code style do you prefer the most?
Date: Fri, 28 Feb 2025 12:54:30 +0100
Organization: A noiseless patient Spider
Lines: 125
Message-ID: <vps85m$3l1rq$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 28 Feb 2025 12:54:37 +0100 (CET)
Injection-Info: dont-email.me; posting-host="31821d0a6b005dd78fa8ea192f86a9d6";
	logging-data="3835770"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18xJZVV3cQHVMRwZvPqUTz/V7TL3M/pr+E="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.11.0
Cancel-Lock: sha1:nTAZZAhVP5X1iECgNtLNo1hWd6c=
Content-Language: en-GB
In-Reply-To: <vprtvs$3jfqu$1@dont-email.me>
Bytes: 6140

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.

I use IDE's often, but I also use lighter editors and occasionally 
command-line editors as well.  It depends on the kind of project I am 
working on, and what I am doing with it - IDE's are heavier, but good if 
there's a lot of cross-file navigation and integration with a debugger 
and other tools.  Other editors can often be more efficient for smaller 
tasks or non-coding work.

> 
> (Given what you write here my guess is that our habits actually don't
> differ too much. And I think also our reasoning is not too different
> in principle, if I've read your post correctly. - Our differences are
> probably only in our observation, experiences, opinions, hypotheses,
> concerning the historic or cultural background.)
> 

That sounds about right.  And I've no problem at all with those kinds of 
differences - my only problem is with people (not you) who think there 
are "magic" numbers and fixed rules that should always apply.