[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Lies in education [was Re: The "loop and a half"]

On 2017-10-11, Marko Rauhamaa <marko at pacujo.net> wrote:
> Bill <BILL_NOSPAM at whoknows.net>:
>> Steve D'Aprano wrote:
>>> Bjarne Stroustrup is famous for designing one of the most
>>> heavyweight, baraque, hard-to-understand, difficult-to-use
>>> programming languages in common use. While C++ has many excellent
>>> features, and is constrained by the need to be compatible with C, I
>>> don't think many people believe that it is a well-designed language.
>> It is a well-designed language.  It is and was carefully
>> thought out. One could argue that there are perhaps "too many
>> ways" to do a given thing in Python (one could say it's
>> features are "not orthogonal"). I'm sure you are familiar with
>> where the language drew its name.   I'm not here to "cast
>> stones", I like Python. I just think that you shouldn't cast
>> stones at C/C++.
> One is allowed to have opinions and express them. We are not talking
> about religion here.
> I don't like everything in Python. On the whole, though, it is an
> excellent language. In practice, it is the best available tool for most
> programming needs I face.
> There are situations where C++ is suitable. Its primary
> advantage over C is the automatic generation of the virtual
> table. However, having programmed in C++ for a decade or so, it
> has left a bad taste in my mouth. Its core philosophy (ie, do
> the utmost at compile time) is cumbersome and misplaced. Until
> very recently, C++ didn't offer a good way to implement
> callback functions, for example.

Some other cool stuff in C++ and how it relates to a Python
features as I understand them:

Support for Resource Acquisition is Initialization (RAII) with
constructors and destructors is a big advantage. Python's got
this now, too, with with.

C++'s big idea of allowing you to define you own data types and
make them work precisely as you wish is a great idea, only it's
too bad it requires such experience and skill to get it right.
Python provides a similar feature with dynamic typing, though the
urge to implement my own type that acts just like one of the
built-in types hardly ever comes to me in Python, thanks to its
fabulous standard library, which regularly uses these features.

C++ compile-time polymorphism using templates is awesome and
vital, but unfortunately (or fortunately?) abusable for
compile-time data processing and foster-parent of horrid compiler
error message bloat.

Run-time polymorphism using inheritance is a feature that in both
Python and C++ is easy to overcomplicate with the multiple
inheritance feature. Alternatives are almost always preferable.

Some people also appreciate C++'s improvements upon C's type
sytem enough to compile all their C programs with C++. I dig
const qualifiers, even though I'm comletely fine with their
absence from Python.

I'd use C++ for stuff--but Python is perfect for my needs,
meanwhile the advantages I'd get from using C++ wouldn't be
relevant to my work. If I ever need to write a device driver I'm
really screwed.

Neil Cerutti