Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > sci.electronics.design > #481593

Re: Ping Tom Gardner et. al.

From David Brown <david.brown@hesbynett.no>
Newsgroups sci.electronics.design
Subject Re: Ping Tom Gardner et. al.
Date 2017-10-16 11:18 +0200
Organization A noiseless patient Spider
Message-ID <os1thb$536$1@dont-email.me> (permalink)
References (2 earlier) <2bJBB.1080790$uh.251387@fx28.am4> <or7slj$5lc$1@dont-email.me> <N2LBB.452713$dT2.429787@fx05.am4> <or8464$vdb$1@dont-email.me> <%pOBB.1635444$tu4.530213@fx35.am4>

Show all headers | View raw


On 06/10/17 18:44, Tom Gardner wrote:
> On 06/10/17 15:32, David Brown wrote:
>> On 06/10/17 14:55, Tom Gardner wrote:
>>> On 06/10/17 13:24, David Brown wrote:
>>>> On 06/10/17 12:47, Tom Gardner wrote:
>>>>> On 06/10/17 08:36, David Brown wrote:
>>>>>> and while
>>>>>> everything works correctly (it's easy to check), your code review
>>>>>> folks
>>>>>> are sticking hot pokers in their eyes to avoid looking at it.
>>>>>
>>>>> And that, in a nutshell, is one problem with C/C++
>>>>>
>>>>
>>>> There are two solutions to it.  One is that when a feature appears
>>>> useful but cumbersome, C++ evolves to make it simpler.  Examples
>>>> include
>>>> recursive template programming (replaced by variadic templates and
>>>> generalised constexpr functions), the safe boolean idiom (replaced by
>>>> explicit conversion operators), and "enable_if" templates (replaced by
>>>> concepts).
>>>>
>>>> (If those terms don't mean anything to you, you should question how
>>>> valid your opinions on C++ are without knowledge of the modern
>>>> language.)
>>>>
>>>> The other solution is to realise that you can program in C++ without
>>>> understanding all the fiddly and complex bits - you can leave those to
>>>> the folks writing libraries.  This is the same in most programming
>>>> languages.
>>>
>>> Just so.
>>>
>>> But that doesn't affect the point; C++ descends into being
>>> a write-only state more easily than other equally powerful
>>> languages.
>>
>> 1. I know of no languages with the breadth of features, the breadth of
>> programming styles, and the breadth of target application types, than
>> C++.  I don't know what you could compare it to here.
> 
> No single language, of course - but I regard that as
> unimportant. 

OK, so your point about "equally powerful languages" is a non-starter?

It can often make sense to build different parts of a large system using
different programming languages - one size does not fit all.  So I can
agree that the existence of a single language covering such as range as
C++ is not essential, but it can certainly be convenient.

> Similarly I would have no interest in a
> hammer that also extruded glue.
> 

Think of C++ as a toolbox, rather than a hammer-and-glue combo.  You
don't have to use all the tools in the toolbox, and you certainly don't
have to use them all in the same project.  But most of them will be
useful to some people at some time.

> C/C++ has the bad taste to aim at being what the Germans
> disparagingly term an "eierlegende Wollmilchsau", i.e.
> an egg-laying wool-milk-sow.
> 

There is no language "C/C++".  When you write that, it screams "I don't
know much about C /or/ C++".  There is nothing wrong with ignorance -
but there is a lot wrong with arguing from a position of ignorance.

The scope for C is far smaller than that for C++, especially if you
consider where C /should/ be used rather than were C /is/ used.

> 
>> 2. All languages are write only when you are not familiar with them, or
>> at least with similar languages.
>>
>> 3. A skilled obfuscater can write write-only code in any language quite
>> easily.
> 
> All true, but some make it easier to obfuscate.

Yes - but neither C nor C++ is such a language.

C++ lets you write some pretty complicated stuff, and some areas of it
are definitely advanced and only accessible to experts.  That does not
mean the code is obfuscated - on the contrary, the code is usually
written as clearly as possible.  It just means it is /hard/.  A key
point about C++ that is different from almost any other language, is
that much of the "language" is formed by the /library/, and that the
library should be written in C++.  Many other languages are designed
with a large standard library, but the /implementation/ of these
libraries is usually done in C for speed.

So in Python or PHP, data structures like hashmaps (or dictionaries, or
arrays, or whatever you like to call them) are part of the /language/,
with the actual implementation in C.  These languages don't need a way
to make such structures efficiently.  In C++, the language needs the
scaffolding in order to design such structures efficiently in C++.  That
means templates, SFINAE, move constructors, and all the other
"difficult" parts of the language.  That does not mean that ordinary
users are expected to use all these low-level parts - they can just use
a "std::map" when they need it, and leave the library implementation up
to the library experts.

> 
> C/C++ has the bad taste to want to be what the Germans
> disparagingly term an "eierlegende Wollmilchsau", i.e.
> an egg-laying wool-milk-sow.
> 
> 
>>> Yes, it is entirely possible to write code that is clear,
>>> simple, and easy to read. Not everybody achieves that.
>>>
>>
>> Not everybody is a good programmer.  Not even all professional
>> programmers are good programmers.
>>
>> It is fair to say that as it is a bigger language, it takes longer to be
>> a good C++ programmer than a good C programmer.
> 
> Big != good. In fact, big language == bad.

Big is good for some things.  Small is good for some things.

> 
> I strongly prefer a simple language plus extensive libraries
> embodying the right abstractions for the task at hand.

The C++ core language is not actually /that/ big.  It is certainly
bigger than the C language, but it is not huge.  A great deal of C++ is
the libraries, rather than the core language.

> 
> No one language will ever be able to do that for
> all application domains.
> 
> 
>> It is perhaps also fair
>> to say that for the same reason, a bad C++ programmer can make a bigger
>> mess than a bad C programmer.  But I have seen enough bad C code to know
>> that a small language does not mean clearer or better code.
> 
> The same is true of any language, of course - especially
> home-grown domain specific languages!
> 
> 
> 
>>>>>> So C++11 allows some fancy tricks like, but they should not be used
>>>>>> until C++14 and generalised constexpr functions.  (I can't remember
>>>>>> off-hand if gcc 5.3 supports that - I /think/ it does.)
>>>>>
>>>>> And that, in a nutshell, is one recurring problem with C/C++
>>>>
>>>> If you want to use modern features, use a modern compiler.  I don't
>>>> track all features and all versions of gcc in my head - but I know how
>>>> to look it up.  It is not hard.
>>>
>>> The real nasty is that frequently C/C++ compilers
>>> implement /a/ subset of a standard, where the subset
>>> depends on what is convenient and what the compiler
>>> writers understand.
>>
>> There is no "real nasty" about it.  It usually takes time between a
>> standard being published, and compilers having full support for it.  If
>> you want to write code that requires C++14, you can look at the
>> documentation for your compiler and version to see if it supports it.
>> And you give the compiler a command-line flag to match.  If you want to
>> compile C++14 code with gcc, you write "g++ -std=c++14" or "g++
>> -std=gnu++14" (for gcc extensions).  If the compiler does not support
>> it, it tells you.  If you want experimental partial support for newer
>> features, look up the flags to enable that.
>>
>> Both C and C++ standards go to extraordinary lengths to support backward
>> compatibility, so that old code still works with newer compilers and
>> newer standards.
> 
> Indeed. That's _necessary_, a strength and also a weakness.
> 
> Sometimes it is better to start again, keeping only the
> elegant, and discarding the cruft.

Agreed.  C++ does that a bit (such as re-using "auto" for a completely
different purpose in C++11, and dropping the "register" keyword).  C
almost never makes changes that breaks old code - that is one of the
major features of it as a language.

Discarding stuff and starting again can be a good thing - but you only
need to look at the mass of Python 2 code that is incompatible with
Python 3 to see that it comes at a very high price.

C++ tries to keep a middle ground.  It only breaks things that either
were very rarely used (like pre-C++11 "auto"), or were often wrong in
the first place.  But that also means that there can be many ways to do
the same thing in C++ - the "new" way and the "old" way, since the new
ways have to be in addition to the old ways.

> 
> 
>>> ISTR a triumphant announcement that the first complete
>>> C++ compiler was available, 4/5/6 years after the
>>> standard was published.
>>
>> The first C++ compiler (Cfront from 1983) was available long before the
>> first C++ standard was published (C++98, in 1998).  The first unofficial
>> sort-of-standard was the 1985 book "The C++ Programming Language".  gcc
>> supported C++ from 1987.
>>
>> In the early days of C++, it took a while for new features to be
>> properly implemented on a range of compilers.  They are a lot better
>> now.  The serious C++ compilers (gcc, clang, MSVC, EDG front end) all
>> have full support for C++14.  gcc and clang have full support for C++17
>> (which was finished a few months ago, but I think is still not
>> officially published).
> 
> My apologies; I'm sure you are right.
> 
> My recollection is from ~2003, so it would have been
> one of the late 90s languages. I wish I had kept a
> copy of the announcement. I didn't dream I would still
> be remembering it.

It could well be that the first full C++98 compilers came out years
after that standard was published.  Certainly it took many years before
C compilers implemented most of C99.  It may also be that the
announcement you saw was for "the first version of the XXX compiler to
support C++98", rather than the first such C++ compiler in general.  And
there is also the complicated question of /full/ support for a standard
- most compilers have oddities where they don't quite support everything
in a standard, but usually such corner cases are irrelevant in practice.

Back to sci.electronics.design | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Ping Tom Gardner et. al. bitrex <bitrex@de.lete.earthlink.net> - 2017-10-05 20:49 -0400
  Re: Ping Tom Gardner et. al. David Brown <david.brown@hesbynett.no> - 2017-10-06 09:36 +0200
    Re: Ping Tom Gardner et. al. David Brown <david.brown@hesbynett.no> - 2017-10-06 11:18 +0200
      Re: Ping Tom Gardner et. al. bitrex <bitrex@de.lete.earthlink.net> - 2017-10-06 05:59 -0400
        Re: Ping Tom Gardner et. al. bitrex <bitrex@de.lete.earthlink.net> - 2017-10-06 06:05 -0400
          Re: Ping Tom Gardner et. al. David Brown <david.brown@hesbynett.no> - 2017-10-06 12:20 +0200
    Re: Ping Tom Gardner et. al. Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-10-06 11:47 +0100
      Re: Ping Tom Gardner et. al. David Brown <david.brown@hesbynett.no> - 2017-10-06 14:24 +0200
        Re: Ping Tom Gardner et. al. Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-10-06 13:55 +0100
          Re: Ping Tom Gardner et. al. bitrex <bitrex@de.lete.earthlink.net> - 2017-10-06 09:12 -0400
            Re: Ping Tom Gardner et. al. David Brown <david.brown@hesbynett.no> - 2017-10-06 16:37 +0200
            Re: Ping Tom Gardner et. al. Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-10-06 15:50 +0100
              Re: Ping Tom Gardner et. al. bitrex <bitrex@de.lete.earthlink.net> - 2017-10-06 14:02 -0400
          Re: Ping Tom Gardner et. al. David Brown <david.brown@hesbynett.no> - 2017-10-06 16:32 +0200
            Re: Ping Tom Gardner et. al. Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-10-06 17:44 +0100
              Re: Ping Tom Gardner et. al. David Brown <david.brown@hesbynett.no> - 2017-10-16 11:18 +0200
          Re: Ping Tom Gardner et. al. Jasen Betts <jasen@xnet.co.nz> - 2017-10-09 07:58 +0000
            Re: Ping Tom Gardner et. al. David Brown <david.brown@hesbynett.no> - 2017-10-16 11:23 +0200

csiph-web