On 12/04/2025 03:27, bart wrote:
On 12/04/2025 00:59, Keith Thompson wrote:
bart <bc@freeuk.com> writes:
On 11/04/2025 22:36, Keith Thompson wrote:
bart <bc@freeuk.com> writes:
[...]
Rubbish. Everyone finds C declaration syntax a nightmare.
Rubbish. I find C declaration syntax annoying, not a "nightmare".
>
Annoying would be having to get letter case or punctuation just right.
[...]
So, yeah, a 'nightmare' is more apt than 'annoying'.
>
Bart, bart, bart.
You made a false statement about how *everyone* feels about
C's declaration syntax.
So what would be a true statement? That everyone finds it at least midly annoying?
I don't find C's declaration syntax annoying in the least.
What I /do/ find annoying at times is the way some programmers write declarations in C. But that is a very different thing.
If someone wrote "int (*A)[10](int);" in code that I had to maintain, I would find that mildly annoying. If someone wrote "int long unsigned const long const const typedef A;", I would find it extremely annoying.
But I don't have any problem writing :
typedef int (*FIntInt)(int);
FIntInt A[10];
or
typedef const unsigned long long A;
(other than that I'd want better names for the object or type).
I write my C code in a way that I don't find annoying to read, nor do others that read me code. I'd recommend all programmers try to do the same (with the full understanding that different kinds of code will be read by different kinds of programmers).
Like a great many things in C, if I were making the syntax for a language I would do it a little differently. Again, that is a different thing from saying that I find C's syntax a problem.
And there /are/ things about C that I find annoying, or limiting. Some of these things I can work around using good tools and language extensions. Often I use C++ rather than C (C++ also has things I find annoying).
However, C declaration syntax is not something that bothers me at all for the code I write.
I'm sure that /some/ people find it annoying, at least in some situations. With a language used by so many people, pretty much every feature is going to annoy someone, and pretty much every programmer is going to find something annoying. But there will be a wide range of which things different people find annoying, and to what extent. Generalisations like you are giving, where you extrapolate your own rather radical opinions, are guaranteed to be wrong.
C type syntax is famous for being difficult and confusing; I think most will agree about that. Even the creators said so.
I disagree with that claim. I think it is probably fair to say that advanced, complicated and multi-layer types are difficult in any programming language. It is also fair to say that the way some people write complicated types in C can be confusing - as can be the case in any language. C lets you write confusing types - it does not force you to do so.
This was the discussion:
BC:
> Humans have to parse it too. C must be the only non-esoteric language where you need to use third-party tools (CDECL etc) to make sense of type-declarations. Either that or follow complex spirular algorithms to [decode] them.
DB:
I have never heard of anyone other than you who views cdecl as a necessity.
So, is that last statement true or not?
Are you asking Keith to tell you about my personal experience?
Yes, it is true. Why would I have said it otherwise?
I didn't say it was a necessity, but that you need to use such tools or special methods to understand them. And clearly, that would be the more complicated ones; people can usually cope with 'int'.
So you didn't say it was a necessity, you said people need to use them? Or are you suggesting that people who can understand what complicated C type declarations mean by reading the C code are somehow using "special methods" ? Other people might just call that knowing the language and being experienced at reading it.
To be clear - I think putting a complicated type declaration on a single line makes code harder to read. Putting /anything/ complicated and composed of many parts in one condensed lump makes it harder to understand - regardless of the programming language, and regardless of whether it is programming or something else. Dividing complex things into smaller and more manageable parts is usually a good thing - within reason, of course.
"An array of 10 objects each of which is a pointer to a function that takes an int parameter and returns an int" is not much clearer than "int (*A)[10](int)", and for people who are used to seeing such C declarations, the familiarity of the C version makes it much faster to parse.
I replied to one sweeping statement with another.
One "sweeping statement" was about a single person, the other was about everyone.
You want to be treated better? Stop making deeply silly statements.
DB was making light of the type syntax issue and pretty much dismissed it out of hand. How should I have responded?
If you didn't make such wildly exaggerated remarks in the first place, you wouldn't have to respond to people telling you they are wildly exaggerated.
No one - not me, and not anyone else in comp.lang.c - has ever claimed that C is perfect or flawless. What people have claimed is that they can understand the language, and write useful code in it, and that it is good enough for a lot of purposes. They have sometimes said why the language is the way it is, even though they think some things would have been better if done differently.
Not that it would cut any ice with him. Nothing is ever that complicated or too onerous or too slow or too over the top or too badly designed or ...
A vast number of people have written a vast amount of code in C. Clearly it is /not/ too complicated, or onerous, or slow. Clearly the declaration syntax in C is not a "nightmare" for everyone - clearly most C programmers find it is good enough to do the job even if some people have issues with it.
I write code in C. If it were too complicated, I would not do so. And often my choice to replace C is C++ - at the risk of making a sweeping generalisation, I think most programmers would agree that C++ is more complicated than C. Yet like the millions of other C++ programmers, I manage to write code in C++ too.
I suggest also that you stop taking throwaway comments too literally. Yet, there is probably more truth in my remark than in David's.
You might also consider that while many features of C have been copied, I don't know of any language that has copied its type syntax.
If another language copied all of C's syntax, it would just be C.
The way that types work in a language is fairly fundamental to the kind of language you have, so it's not surprising that there is a lot of variety in the syntax for types. Some languages /have/ copied the syntax, such as C++, D, and Objective-C. No doubt you will call these derivatives of C rather than new languages. You could then say the same about other type syntaxes - what languages have copied Pascal's type syntax, other than Pascal derivatives like Ada and Modula 2 ?
So what if other newer languages have a different syntax for type declarations? It means their designers feel they have a better way of writing types that suit their new language. Fair enough. It doesn't imply that they think the C syntax is a "nightmare" (though of course they /may/ think that).
I wonder why? Do you think the designers had an opinion about it closer to mine, or to David Brown's?
I have said multiple times that if I were to design a new programming language, its syntax would differ significantly from C's.