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


Groups > comp.lang.c++ > #78998 > unrolled thread

No, C is not a simple language

Started byJuha Nieminen <nospam@thanks.invalid>
First post2021-04-17 05:56 +0000
Last post2021-04-26 08:49 +0000
Articles 20 on this page of 143 — 32 participants

Back to article view | Back to comp.lang.c++


Contents

  No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-17 05:56 +0000
    Re: No, C is not a simple language Christian Gollwitzer <auriocus@gmx.de> - 2021-04-17 08:42 +0200
    Re: No, C is not a simple language wij <wyniijj@gmail.com> - 2021-04-16 23:49 -0700
      Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-18 16:25 +0000
        Re: No, C is not a simple language wij <wyniijj@gmail.com> - 2021-04-19 06:43 -0700
          Re: No, C is not a simple language Bo Persson <bo@bo-persson.se> - 2021-04-19 20:19 +0200
            Re: No, C is not a simple language wij <wyniijj@gmail.com> - 2021-04-19 13:04 -0700
          Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-20 04:02 +0000
            Re: No, C is not a simple language Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2021-04-21 18:30 +0100
              Re: No, C is not a simple language scott@slp53.sl.home (Scott Lurndal) - 2021-04-21 18:33 +0000
                Re: No, C is not a simple language Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2021-04-21 21:14 +0100
                  Re: No, C is not a simple language wij <wyniijj@gmail.com> - 2021-04-21 22:38 -0700
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-21 15:37 -0700
                Re: No, C is not a simple language wij <wyniijj@gmail.com> - 2021-04-22 10:14 -0700
              Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-22 08:45 +0000
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-22 01:48 -0700
                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-22 01:51 -0700
                  Re: No, C is not a simple language MrSpook_l0xjKyc@b3jtfv70fxckzmak.net - 2021-04-22 09:40 +0000
                    Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-22 12:38 -0700
                    Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-23 07:12 +0000
                      Re: No, C is not a simple language MrSpook_l0c6dv@66h4_0ccefudc0u8w.gov - 2021-04-23 09:14 +0000
                        Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-26 04:47 +0000
                          Re: No, C is not a simple language MrSpook_531q@dr4t0dkj168m4ml.tv - 2021-04-26 08:13 +0000
                            Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-26 01:22 -0700
                              Re: No, C is not a simple language MrSpook_9p05k3C69@xr34.gov.uk - 2021-04-26 09:03 +0000
                                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-26 02:17 -0700
                                  Re: No, C is not a simple language MrSpook_i4zl8mHy@0tr9r.eu - 2021-04-26 09:23 +0000
                                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-26 02:22 -0700
                            Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-26 09:37 +0000
                              Re: No, C is not a simple language MrSpook_gbzt63zc@83jpfr9ry9f55a.tv - 2021-04-26 10:22 +0000
                                Re: No, C is not a simple language Bo Persson <bo@bo-persson.se> - 2021-04-26 13:05 +0200
                                Re: No, C is not a simple language David Brown <david.brown@hesbynett.no> - 2021-04-26 13:10 +0200
                            Re: No, C is not a simple language Paavo Helde <myfirstname@osa.pri.ee> - 2021-04-26 14:38 +0300
                              Re: No, C is not a simple language MrSpook_mD_r@g72w8ixztm106rprqnby.tv - 2021-04-26 13:49 +0000
                Re: No, C is not a simple language MrSpook_lxrj1vfhmw@qdgb.org - 2021-04-22 09:37 +0000
                  Re: No, C is not a simple language Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-22 11:32 +0100
                    Re: No, C is not a simple language MrSpook_f0mj9r@d6g.gov.uk - 2021-04-22 10:38 +0000
                      Re: No, C is not a simple language Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-22 12:35 +0100
                Re: No, C is not a simple language Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2021-04-22 13:35 +0100
                  Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-23 07:20 +0000
                    Re: No, C is not a simple language Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2021-04-23 11:01 +0100
                      Re: No, C is not a simple language Paavo Helde <myfirstname@osa.pri.ee> - 2021-04-23 15:44 +0300
                        Re: No, C is not a simple language Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2021-04-23 17:52 +0100
                          Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-26 04:55 +0000
                            Re: No, C is not a simple language Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2021-04-26 22:16 +0100
                Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-22 16:30 +0200
                  Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-23 07:32 +0000
                    Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-23 20:35 +0200
                      Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-26 05:01 +0000
          Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-20 04:56 +0000
            Re: No, C is not a simple language wij <wyniijj@gmail.com> - 2021-04-20 05:22 -0700
    Re: No, C is not a simple language MrSpook_wb@g9b2a_ex9aicgvs04.net - 2021-04-17 10:27 +0000
      Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-18 16:30 +0000
        Re: No, C is not a simple language MrSpook_wyzaq1485z@solbi8e3oaumg9.gov.uk - 2021-04-19 07:42 +0000
    Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-17 17:43 +0200
      Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-18 16:39 +0000
        Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-18 20:48 +0200
    Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-17 19:12 +0200
      Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-18 16:46 +0000
        Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-18 20:30 +0200
          Re: No, C is not a simple language Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-04-18 12:46 -0700
            Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-18 22:53 +0200
          Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-19 07:18 +0000
            Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-19 17:15 +0200
              Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-20 04:05 +0000
                Re: No, C is not a simple language Manfred <noname@add.invalid> - 2021-04-20 18:27 +0200
                  Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-20 16:41 +0000
                    Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-20 19:44 +0200
                      Re: No, C is not a simple language Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-20 18:30 +0000
                        Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-20 20:47 +0200
                          Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-20 13:29 -0700
                          Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-21 04:37 +0000
                            Re: No, C is not a simple language wij <wyniijj@gmail.com> - 2021-04-20 22:02 -0700
                              Re: No, C is not a simple language wij <wyniijj@gmail.com> - 2021-04-20 22:35 -0700
                            Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-21 15:26 -0700
                              Re: No, C is not a simple language wij <wyniijj@gmail.com> - 2021-04-21 22:06 -0700
                                Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-22 08:52 +0000
                                  Re: No, C is not a simple language wij <wyniijj@gmail.com> - 2021-04-22 09:41 -0700
                                    Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-23 07:34 +0000
                                      Re: No, C is not a simple language wij <wyniijj@gmail.com> - 2021-04-23 04:58 -0700
                                        Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-26 05:04 +0000
                                        Re: No, C is not a simple language Paavo Helde <myfirstname@osa.pri.ee> - 2021-04-26 09:41 +0300
                                        Re: No, C is not a simple language James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-04-26 10:25 -0400
                                          Re: No, C is not a simple language wij <wyniijj@gmail.com> - 2021-04-26 12:07 -0700
                                            Re: No, C is not a simple language Christian Gollwitzer <auriocus@gmx.de> - 2021-04-28 08:03 +0200
                                Re: No, C is not a simple language wij <wyniijj@gmail.com> - 2021-04-22 09:26 -0700
                      Re: No, C is not a simple language Richard Damon <Richard@Damon-Family.org> - 2021-04-20 14:46 -0400
                        Re: No, C is not a simple language Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-20 20:18 +0000
                      Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-20 13:19 -0700
                        Re: No, C is not a simple language Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-20 20:29 +0000
                          Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-20 13:39 -0700
                            Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-20 14:29 -0700
                      Re: No, C is not a simple language Ian Collins <ian-news@hotmail.com> - 2021-04-21 08:56 +1200
                      Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-20 14:07 -0700
                        Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-23 12:10 +0200
                          Re: No, C is not a simple language wij <wyniijj@gmail.com> - 2021-04-23 04:10 -0700
                            Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-28 00:32 -0700
                              Re: No, C is not a simple language wij <wyniijj@gmail.com> - 2021-04-28 11:04 -0700
                          Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 12:37 -0700
                            Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 12:38 -0700
                            Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 12:43 -0700
                              Re: No, C is not a simple language jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-23 22:38 +0200
                                Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 13:44 -0700
                                Re: No, C is not a simple language Ian Collins <ian-news@hotmail.com> - 2021-04-24 10:56 +1200
                                  Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 16:09 -0700
                              Re: No, C is not a simple language Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-24 03:51 +0000
                      Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 09:24 +0000
                      Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 09:27 +0000
                    Re: No, C is not a simple language "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2021-04-20 19:53 +0200
                    Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 09:02 +0000
                      Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-26 09:43 +0000
                        Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 10:35 +0000
                          Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-26 13:08 +0000
                            Re: No, C is not a simple language Richard Damon <Richard@Damon-Family.org> - 2021-04-26 09:30 -0400
                            Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 14:15 +0000
                              Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-27 04:37 +0000
                                Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-27 07:22 +0000
      Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-19 21:42 -0700
        Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-22 00:26 -0700
      Re: No, C is not a simple language "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-28 00:02 -0700
    Re: No, C is not a simple language Bonita Montero <Bonita.Montero@gmail.com> - 2021-04-17 21:36 +0200
      Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-18 16:49 +0000
        Re: No, C is not a simple language Bonita Montero <Bonita.Montero@gmail.com> - 2021-04-18 23:31 +0200
        Re: No, C is not a simple language Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-19 01:36 +0100
          Re: No, C is not a simple language Juha Nieminen <nospam@thanks.invalid> - 2021-04-19 07:19 +0000
            Re: No, C is not a simple language Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-19 11:36 +0100
            Re: No, C is not a simple language Bonita Montero <Bonita.Montero@gmail.com> - 2021-04-19 16:54 +0200
    Re: No, C is not a simple language Paavo Helde <myfirstname@osa.pri.ee> - 2021-04-18 00:48 +0300
    Re: No, C is not a simple language (PLO) olcott <NoOne@NoWhere.com> - 2021-04-18 16:04 -0500
      Re: No, C is not a simple language (PLO) Juha Nieminen <nospam@thanks.invalid> - 2021-04-19 07:22 +0000
        Re: No, C is not a simple language (PLO) olcott <NoOne@NoWhere.com> - 2021-04-19 09:50 -0500
          Re: No, C is not a simple language (PLO) jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-19 19:05 +0200
            Re: No, C is not a simple language (PLO) olcott <NoOne@NoWhere.com> - 2021-04-19 12:23 -0500
            Re: No, C is not a simple language (PLO) scott@slp53.sl.home (Scott Lurndal) - 2021-04-19 18:02 +0000
            Re: No, C is not a simple language (PLO) jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-19 21:03 +0200
              Re: No, C is not a simple language (PLO) olcott <NoOne@NoWhere.com> - 2021-04-19 15:14 -0500
            Re: No, C is not a simple language (PLO) "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-19 17:16 -0700
              Re: No, C is not a simple language (PLO) jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-20 07:32 +0200
                Re: No, C is not a simple language (PLO) "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-19 23:47 -0700
            Re: No, C is not a simple language (PLO) Juha Nieminen <nospam@thanks.invalid> - 2021-04-20 10:29 +0000
              Re: No, C is not a simple language (PLO) jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-20 14:14 +0200
                Re: No, C is not a simple language (PLO) Juha Nieminen <nospam@thanks.invalid> - 2021-04-20 16:44 +0000
    Re: No, C is not a simple language Robert Latest <boblatest@yahoo.com> - 2021-04-26 08:49 +0000

Page 1 of 8  [1] 2 3 4 5 6 7 8  Next page →


#78998 — No, C is not a simple language

FromJuha Nieminen <nospam@thanks.invalid>
Date2021-04-17 05:56 +0000
SubjectNo, C is not a simple language
Message-ID<s5dtao$1aj9$1@gioia.aioe.org>
I know that this is probably going to piss off avid C programmers,
but I don't really care all that much.

Many C fans keep insisting how C is so much better than C++ because
C++ is so utterly complicated, with a standard that reads like a
phonebook and a standard library so vast that nobody in their sane
mind could ever even hope to remember all of it, and how C++ is
becoming more and more complicated with every standard, and how
C is such a simple, straightforward and beautiful language, so
immensely better than C++.

I myself happen to know both languages quite well, and in fact I
program in both languages as my profession, and I would say that
I am very knowledgeable and proficient in both languages and have
no trouble in developing in either one. I am of the strong opinion
that no, C is not a "simple" language, and that C++ makes so many
things so much simpler, easier and safer.

I was reminded of this in a quite concrete manner recently when I was
trying to help a beginner programmer who had decided to try his hands
on C, and wanted to create a simple text editor, which would read a
text file, allow the user to edit the text in several ways, and to
save the file.

It quite quickly turned very frustrating for *both* of us that dynamic
string manipulation in C is so damn complicated, especially for a
complete beginner who has never programmed in C, and has only very
little experience even with other programming languages (he had some
very small experience with Python.)

I tried approaching the problem by explaining that for a project of
this nature and size, it would be much more better to create a separate
(and reusable) "string" module, ie. a struct that represents a string
(which has a char* and a length member variable), and a bunch of functions
that operate on objects of that struct type, clearly and logically
named. (In other words, I was trying to make him essentially replicate
a subset of std::string in C.) This would make it much easier to do
things like appending strings to other strings, inserting characters
and strings in the middle of other strings (having them automatically
grow dynamically), and so on.

Even then, it was just frustration after frustration, trying to explain
and make him understand why in C you need to always explicitly call an
initializer function (ie. "constructor") for every single new string
object (and any struct that may have such a string object as a member
variable, and any struct that may have those types of structs as
members, all the way down), and especially how you have to make sure
to call the destruction function for every such object, or else there
would be a leak.

It's surprisingly complicated and frustrating to try to explain to a
complete beginner how and why he should follow very strict coding
practices when it comes to initializing and destructing every object
and, especially, why he should be very careful about assigning string
objects to each other directly. In the middle of this mountain of new
complicated information, try to explain to a complete beginner the
subtleties of doing this:

    String str1 = String_with_cstr("hello");
    String str2 = str1;

While not wrong per se, and it actually does have its uses, it's very
prone to errors because now str1 and str2 are pointing to the same
string data, so only one of them must be destroyed and the other must
not be used after that (unless it's initialized again).

Also, trying to inculcate how wrong this is, and how important it is
to avoid it:

    String str1 = String_with_cstr("hello");
    String str2 = String_with_cstr("there");
    str1 = str2; // No!

He also asked why he couldn't do something like this:

    String str = "hello";

Now try to explain why that doesn't directly work (obviously causes
a compiler error), and try to think whether you should explain that
he *can* assign the string literal to the member char* of the struct
(remember to also update the length parameter) but once again how fraught
with peril that is, because now he will have to remember to *not* destruct
*this* particular object, or else bad things will happen.

Then try to explain the concept of string capacity vs its length,
which is useful in this kind of module because of efficiency reasons
(and also because the string may become shorter, while retaining its
capacity).

The worst thing, however, was trying to inculcate the importance of
always properly initializing and destructing the objects at the proper
places, and to avoid the pitfalls and mistakes that are so easy to make
when handling such objects.

And those are just a couple of examples from many. I couldn't help but
to constantly comment how much easier all this would be in C++, using
std::string, where you don't have to worry about any of that. The
project he was trying to make was almost *trivial* to do in C++, because
of the readymade tools available in the standard library, and the
ease and safety mechanisms provided by the language. Instead of writing
thousands of lines of code to create his own string class, and then
having to follow strict coding practices to avoid mistakes when creating
dynamic arrays of such string objects, in C++ he could just create a
std::vector<std::string> and be done with it. All the tools he needed
for that project available easily and safely.

[toc] | [next] | [standalone]


#78999

FromChristian Gollwitzer <auriocus@gmx.de>
Date2021-04-17 08:42 +0200
Message-ID<s5e01j$hus$1@dont-email.me>
In reply to#78998
Am 17.04.21 um 07:56 schrieb Juha Nieminen:
> I know that this is probably going to piss off avid C programmers,
> but I don't really care all that much.
> 
> Many C fans keep insisting how C is so much better than C++ because
> C++ is so utterly complicated, with a standard that reads like a
> phonebook and a standard library so vast that nobody in their sane
> mind could ever even hope to remember all of it, and how C++ is
> becoming more and more complicated with every standard, and how
> C is such a simple, straightforward and beautiful language

I fully agree and I think there is a confusion about the word "simple".

C is definitively a simple language in the sense that the definition of 
it is small, therefore the code maps very directly to the underlying 
assembly and it is easy to write a compiler for.

That, however, doesn't make it simple to *use*, rather the opposite - 
otherwise we would be coding in Brainfuck or lambda calculus, these are 
inherently simple languages.

C++'s quirks actually come from the forced compatibility with C, for 
example why is this "abc" not a string, but a pointer? Why are unsigned 
integers used not only for bit-twiddling?

std::string test = "abc" + "def"; // Very strange error
for (size_t c=5; c>=0; c--); // endless loop


For a language to be simple to use, it needs a way to express the intent 
of the programmer in the language he thinks in. This varies for 
different domains of computing:

Numerical algorithms -> infix math, linear algebra
Data structures -> List comprehensions, functional programming
Controlling hardware, IO -> Serial/Iterative programming
GUIs -> Classes and Inheritance

Otherwise, the programmer is forced to shoehorn the problem into the 
language. This is easily shown by the abominations of Java's forced-OO 
APIs and "Design patterns" or when you try to do numerical math in Lisp.

To be simple to *use*, a language must be complex - because then you can 
choose the right paradigm for your work. Another example: A pocket 
calculator is so much simpler and more beautiful than a current 
computer! But we wouldn't use it to calculate the stability of a bicycle 
frame using it.



	Christian

[toc] | [prev] | [next] | [standalone]


#79000

Fromwij <wyniijj@gmail.com>
Date2021-04-16 23:49 -0700
Message-ID<80bd08d3-c649-4e16-ba82-7d67501540c0n@googlegroups.com>
In reply to#78998
On Saturday, 17 April 2021 at 13:57:04 UTC+8, Juha Nieminen wrote:
> I know that this is probably going to piss off avid C programmers, 
> but I don't really care all that much. 
> 
> Many C fans keep insisting how C is so much better than C++ because 
> C++ is so utterly complicated, with a standard that reads like a 
> phonebook and a standard library so vast that nobody in their sane 
> mind could ever even hope to remember all of it, and how C++ is 
> becoming more and more complicated with every standard, and how 
> C is such a simple, straightforward and beautiful language, so 
> immensely better than C++. 
> 
> I myself happen to know both languages quite well, and in fact I 
> program in both languages as my profession, and I would say that 
> I am very knowledgeable and proficient in both languages and have 
> no trouble in developing in either one. I am of the strong opinion 
> that no, C is not a "simple" language, and that C++ makes so many 
> things so much simpler, easier and safer. 
> 
> I was reminded of this in a quite concrete manner recently when I was 
> trying to help a beginner programmer who had decided to try his hands 
> on C, and wanted to create a simple text editor, which would read a 
> text file, allow the user to edit the text in several ways, and to 
> save the file. 
> 
> It quite quickly turned very frustrating for *both* of us that dynamic 
> string manipulation in C is so damn complicated, especially for a 
> complete beginner who has never programmed in C, and has only very 
> little experience even with other programming languages (he had some 
> very small experience with Python.) 
> 
> I tried approaching the problem by explaining that for a project of 
> this nature and size, it would be much more better to create a separate 
> (and reusable) "string" module, ie. a struct that represents a string 
> (which has a char* and a length member variable), and a bunch of functions 
> that operate on objects of that struct type, clearly and logically 
> named. (In other words, I was trying to make him essentially replicate 
> a subset of std::string in C.) This would make it much easier to do 
> things like appending strings to other strings, inserting characters 
> and strings in the middle of other strings (having them automatically 
> grow dynamically), and so on. 
> 
> Even then, it was just frustration after frustration, trying to explain 
> and make him understand why in C you need to always explicitly call an 
> initializer function (ie. "constructor") for every single new string 
> object (and any struct that may have such a string object as a member 
> variable, and any struct that may have those types of structs as 
> members, all the way down), and especially how you have to make sure 
> to call the destruction function for every such object, or else there 
> would be a leak. 
> 
> It's surprisingly complicated and frustrating to try to explain to a 
> complete beginner how and why he should follow very strict coding 
> practices when it comes to initializing and destructing every object 
> and, especially, why he should be very careful about assigning string 
> objects to each other directly. In the middle of this mountain of new 
> complicated information, try to explain to a complete beginner the 
> subtleties of doing this: 
> 
> String str1 = String_with_cstr("hello"); 
> String str2 = str1; 
> 
> While not wrong per se, and it actually does have its uses, it's very 
> prone to errors because now str1 and str2 are pointing to the same 
> string data, so only one of them must be destroyed and the other must 
> not be used after that (unless it's initialized again). 
> 
> Also, trying to inculcate how wrong this is, and how important it is 
> to avoid it: 
> 
> String str1 = String_with_cstr("hello"); 
> String str2 = String_with_cstr("there"); 
> str1 = str2; // No! 
> 
> He also asked why he couldn't do something like this: 
> 
> String str = "hello"; 
> 
> Now try to explain why that doesn't directly work (obviously causes 
> a compiler error), and try to think whether you should explain that 
> he *can* assign the string literal to the member char* of the struct 
> (remember to also update the length parameter) but once again how fraught 
> with peril that is, because now he will have to remember to *not* destruct 
> *this* particular object, or else bad things will happen. 
> 
> Then try to explain the concept of string capacity vs its length, 
> which is useful in this kind of module because of efficiency reasons 
> (and also because the string may become shorter, while retaining its 
> capacity). 
> 
> The worst thing, however, was trying to inculcate the importance of 
> always properly initializing and destructing the objects at the proper 
> places, and to avoid the pitfalls and mistakes that are so easy to make 
> when handling such objects. 
> 
> And those are just a couple of examples from many. I couldn't help but 
> to constantly comment how much easier all this would be in C++, using 
> std::string, where you don't have to worry about any of that. The 
> project he was trying to make was almost *trivial* to do in C++, because 
> of the readymade tools available in the standard library, and the 
> ease and safety mechanisms provided by the language. Instead of writing 
> thousands of lines of code to create his own string class, and then 
> having to follow strict coding practices to avoid mistakes when creating 
> dynamic arrays of such string objects, in C++ he could just create a 
> std::vector<std::string> and be done with it. All the tools he needed 
> for that project available easily and safely.

One reason C programmer do not like C++ is C++ does things in the background
Good or bad? not easy to say shortly.
But something is sure, pretty much in all cases, programmers sooner or latter will
need to know those underlying things, C or better, Assembly. C++ is no exception.

[toc] | [prev] | [next] | [standalone]


#79033

FromJuha Nieminen <nospam@thanks.invalid>
Date2021-04-18 16:25 +0000
Message-ID<s5hmic$1vq1$1@gioia.aioe.org>
In reply to#79000
wij <wyniijj@gmail.com> wrote:
> One reason C programmer do not like C++ is C++ does things in the background
> Good or bad? not easy to say shortly.

I can't think of many things that C++ "does in the background". Perhaps the
most prominent (and perhaps the most controversial) thing is exceptions.
However, even then, originally exceptions were accepted into the first C++
standard only if it could be proven that they could be implemented "for
free" (ie. exception support would not slow down the program in any way
if exceptions are not thrown). It's my understanding that the standardization
committee was satisfied enough with the techniques that were possible and
accepted them.

Of course one could also argue that RAII and compiler-generated constructors
and assignment operators are things that the compiler does "in the
background", but I would argue those are only beneficial, not detrimental.
And most importantly, they rarely come as a surprise to the programmer.
RAII certainly makes many things simpler (like in this example.)

(Rather obviously the standard library doesn't really count as "C++ doing
things in the background" because else you could make the same argument
from the C standard library.)

[toc] | [prev] | [next] | [standalone]


#79080

Fromwij <wyniijj@gmail.com>
Date2021-04-19 06:43 -0700
Message-ID<7a35460f-d7cd-4614-824e-38e7c436a17dn@googlegroups.com>
In reply to#79033
On Monday, 19 April 2021 at 00:26:07 UTC+8, Juha Nieminen wrote:
> wij <wyn...@gmail.com> wrote: 
> > One reason C programmer do not like C++ is C++ does things in the background 
> > Good or bad? not easy to say shortly.
> I can't think of many things that C++ "does in the background". Perhaps the 
> most prominent (and perhaps the most controversial) thing is exceptions. 
> However, even then, originally exceptions were accepted into the first C++ 
> standard only if it could be proven that they could be implemented "for 
> free" (ie. exception support would not slow down the program in any way 
> if exceptions are not thrown). It's my understanding that the standardization 
> committee was satisfied enough with the techniques that were possible and 
> accepted them. 
> 
> Of course one could also argue that RAII and compiler-generated constructors 
> and assignment operators are things that the compiler does "in the 
> background", but I would argue those are only beneficial, not detrimental. 
> And most importantly, they rarely come as a surprise to the programmer. 
> RAII certainly makes many things simpler (like in this example.) 
> 
> (Rather obviously the standard library doesn't really count as "C++ doing 
> things in the background" because else you could make the same argument 
> from the C standard library.)

Once upon a time, C++ claimed being a superior system programming language.
Luckily, Linus Torvalds was not fooled as most C++ beginners were.
Such kind of topic (like, C/C++ which one is better) had been heavily discussed
several times before, in ways like debating which religion is better.
Just do not be overly zealous.

[toc] | [prev] | [next] | [standalone]


#79094

FromBo Persson <bo@bo-persson.se>
Date2021-04-19 20:19 +0200
Message-ID<ie5vssF8qcvU1@mid.individual.net>
In reply to#79080
On 2021-04-19 at 15:43, wij wrote:
> On Monday, 19 April 2021 at 00:26:07 UTC+8, Juha Nieminen wrote:
>> wij <wyn...@gmail.com> wrote:
>>> One reason C programmer do not like C++ is C++ does things in the background
>>> Good or bad? not easy to say shortly.
>> I can't think of many things that C++ "does in the background". Perhaps the
>> most prominent (and perhaps the most controversial) thing is exceptions.
>> However, even then, originally exceptions were accepted into the first C++
>> standard only if it could be proven that they could be implemented "for
>> free" (ie. exception support would not slow down the program in any way
>> if exceptions are not thrown). It's my understanding that the standardization
>> committee was satisfied enough with the techniques that were possible and
>> accepted them.
>>
>> Of course one could also argue that RAII and compiler-generated constructors
>> and assignment operators are things that the compiler does "in the
>> background", but I would argue those are only beneficial, not detrimental.
>> And most importantly, they rarely come as a surprise to the programmer.
>> RAII certainly makes many things simpler (like in this example.)
>>
>> (Rather obviously the standard library doesn't really count as "C++ doing
>> things in the background" because else you could make the same argument
>> from the C standard library.)
> 
> Once upon a time, C++ claimed being a superior system programming language.
> Luckily, Linus Torvalds was not fooled as most C++ beginners were.

That was more of a self-fullfilling prophecy on Linus' side.

Unfortunately for Linus, he was apparently presented with some C++ code 
from these C++ beginners. And he saw that it was bad. And the blamed it 
on the language. And not in a nice way either.

To quote http://harmful.cat-v.org/software/c++/linus

"*YOU* are full of bullshit.

C++ is a horrible language. It's made more horrible by the fact that a 
lot of substandard programmers use it, to the point where it's much much
easier to generate total and utter crap with it. Quite frankly, even if
the choice of C were to do *nothing* but keep the C++ programmers out,
that in itself would be a huge reason to use C.

In other words: the choice of C is the only sane choice. I know Miles
Bader jokingly said "to piss you off", but it's actually true. I've come
to the conclusion that any programmer that would prefer the project to 
be in C++ over C is likely a programmer that I really *would* prefer to 
piss off, so that he doesn't come and screw up any project I'm involved 
with."


And so he *did* piss of all competent C++ users, who didn't care to show 
him what their good code looks like.




[toc] | [prev] | [next] | [standalone]


#79097

Fromwij <wyniijj@gmail.com>
Date2021-04-19 13:04 -0700
Message-ID<8032b092-b070-4aa4-9b7a-87b5b37ddd3cn@googlegroups.com>
In reply to#79094
On Tuesday, 20 April 2021 at 02:19:23 UTC+8, Bo Persson wrote:
> On 2021-04-19 at 15:43, wij wrote: 
> > On Monday, 19 April 2021 at 00:26:07 UTC+8, Juha Nieminen wrote: 
> >> wij <wyn...@gmail.com> wrote: 
> >>> One reason C programmer do not like C++ is C++ does things in the background 
> >>> Good or bad? not easy to say shortly. 
> >> I can't think of many things that C++ "does in the background". Perhaps the 
> >> most prominent (and perhaps the most controversial) thing is exceptions. 
> >> However, even then, originally exceptions were accepted into the first C++ 
> >> standard only if it could be proven that they could be implemented "for 
> >> free" (ie. exception support would not slow down the program in any way 
> >> if exceptions are not thrown). It's my understanding that the standardization 
> >> committee was satisfied enough with the techniques that were possible and 
> >> accepted them. 
> >> 
> >> Of course one could also argue that RAII and compiler-generated constructors 
> >> and assignment operators are things that the compiler does "in the 
> >> background", but I would argue those are only beneficial, not detrimental. 
> >> And most importantly, they rarely come as a surprise to the programmer. 
> >> RAII certainly makes many things simpler (like in this example.) 
> >> 
> >> (Rather obviously the standard library doesn't really count as "C++ doing 
> >> things in the background" because else you could make the same argument 
> >> from the C standard library.) 
> > 
> > Once upon a time, C++ claimed being a superior system programming language. 
> > Luckily, Linus Torvalds was not fooled as most C++ beginners were.
> That was more of a self-fullfilling prophecy on Linus' side. 
> 
> Unfortunately for Linus, he was apparently presented with some C++ code 
> from these C++ beginners. And he saw that it was bad. And the blamed it 
> on the language. And not in a nice way either. 
> 
> To quote http://harmful.cat-v.org/software/c++/linus 
> 
> "*YOU* are full of bullshit. 
> 
> C++ is a horrible language. It's made more horrible by the fact that a 
> lot of substandard programmers use it, to the point where it's much much 
> easier to generate total and utter crap with it. Quite frankly, even if 
> the choice of C were to do *nothing* but keep the C++ programmers out, 
> that in itself would be a huge reason to use C. 
> 
> In other words: the choice of C is the only sane choice. I know Miles 
> Bader jokingly said "to piss you off", but it's actually true. I've come 
> to the conclusion that any programmer that would prefer the project to 
> be in C++ over C is likely a programmer that I really *would* prefer to 
> piss off, so that he doesn't come and screw up any project I'm involved 
> with." 
> 

To add more from the link:
------------------------------
In other words, the only way to do good, efficient, and system-level and
portable C++ ends up to limit yourself to all the things that are
basically available in C. And limiting your project to C means that people
don't screw that up, and also means that you get a lot of programmers that
do actually understand low-level issues and don't screw things up with any
idiotic "object model" crap.
------------------------------

I read (just impression in my head, I am not a English speaker) another
reason Linus Torvalds complained about C++ was something about
'interface' issues, difficult to unite codes from different groups
(guess: each has their owe smart idea, back then).

> 
> And so he *did* piss of all competent C++ users, who didn't care to show 
> him what their good code looks like.

[toc] | [prev] | [next] | [standalone]


#79101

FromJuha Nieminen <nospam@thanks.invalid>
Date2021-04-20 04:02 +0000
Message-ID<s5ljok$v0c$1@gioia.aioe.org>
In reply to#79080
wij <wyniijj@gmail.com> wrote:
> Once upon a time, C++ claimed being a superior system programming language.
> Luckily, Linus Torvalds was not fooled as most C++ beginners were.

Almost nothing of what Linux wrote in that idiotic rant was true even back
when it was written, much less now.

Perhaps the most idiotic idea in his rant is the idea that C somehow
magically and automatically leads people to write good and efficient
code. No need to even explain how that's even possible.

[toc] | [prev] | [next] | [standalone]


#79144

FromChris Vine <chris@cvine--nospam--.freeserve.co.uk>
Date2021-04-21 18:30 +0100
Message-ID<20210421183041.51cbf4d4407a520dfff06a89@cvine--nospam--.freeserve.co.uk>
In reply to#79101
On Tue, 20 Apr 2021 04:02:30 +0000 (UTC)
Juha Nieminen <nospam@thanks.invalid> wrote:
> wij <wyniijj@gmail.com> wrote:
> > Once upon a time, C++ claimed being a superior system programming language.
> > Luckily, Linus Torvalds was not fooled as most C++ beginners were.
> 
> Almost nothing of what Linux wrote in that idiotic rant was true even back
> when it was written, much less now.

I would say it has about the same validity as your own arguments about C
and how much easier C++ is for beginners (you came up with a similar
set of arguments about a year or so ago).  Both languages are difficult
for beginners and require a high degree of skill to use well.  On
balance I suspect C++ has a few more 'gotchas' because it is a more
complex language and does more things for you implicitly.

For what it is worth, Linus has now accepted Rust into the linux kernel
for certain (at present limited) purposes, principally I think because
of its linear/affine type system.

[toc] | [prev] | [next] | [standalone]


#79145

Fromscott@slp53.sl.home (Scott Lurndal)
Date2021-04-21 18:33 +0000
Message-ID<me_fI.10274$5%7.8298@fx13.iad>
In reply to#79144
Chris Vine <chris@cvine--nospam--.freeserve.co.uk> writes:
>On Tue, 20 Apr 2021 04:02:30 +0000 (UTC)
>Juha Nieminen <nospam@thanks.invalid> wrote:
>> wij <wyniijj@gmail.com> wrote:
>> > Once upon a time, C++ claimed being a superior system programming language.
>> > Luckily, Linus Torvalds was not fooled as most C++ beginners were.
>> 
>> Almost nothing of what Linux wrote in that idiotic rant was true even back
>> when it was written, much less now.
>
>I would say it has about the same validity as your own arguments about C
>and how much easier C++ is for beginners (you came up with a similar
>set of arguments about a year or so ago).  Both languages are difficult
>for beginners and require a high degree of skill to use well.  On
>balance I suspect C++ has a few more 'gotchas' because it is a more
>complex language and does more things for you implicitly.
>
>For what it is worth, Linus has now accepted Rust into the linux kernel
>for certain (at present limited) purposes, principally I think because
>of its linear/affine type system.

And linux aside, I've personally written two commercial operating systems and two
hypervisors in C++ since 1989.   It works just fine for operating systems
_if you don't use the C++ library crap_.   Don't use vectors, don't use maps,
don't use exceptions, don't use dynamic allocation.  (use placement new
or pool-based page/slab/slub allocators).

You still get the benefits of data hiding/encapsulation, and compiler support
for what linux calls "ops vectors" (which are basically vtables).

I do think Linus is off base.   However, it's a moot point as nobody
will ever rewrite linux in a new language.  He does have a point about
the odd need for some C++ programmers to show off their expertise by using
every odd or unusual C++ feature.

class fs_vectors_t {
   /* pure virtual (abstract) file system op vectors; e.g. lookup, create, open, close, delete, read, write */
}

class ext4_fs : public fs_vectors_t
{
 ...
}

class btrfs : public fs_vectors_t
{
 ...
}

[toc] | [prev] | [next] | [standalone]


#79146

FromChris Vine <chris@cvine--nospam--.freeserve.co.uk>
Date2021-04-21 21:14 +0100
Message-ID<20210421211455.bf4bcb38b427ee353e016915@cvine--nospam--.freeserve.co.uk>
In reply to#79145
On Wed, 21 Apr 2021 18:33:54 GMT
scott@slp53.sl.home (Scott Lurndal) wrote:
> Chris Vine <chris@cvine--nospam--.freeserve.co.uk> writes:
> >On Tue, 20 Apr 2021 04:02:30 +0000 (UTC)
> >Juha Nieminen <nospam@thanks.invalid> wrote:
> >> wij <wyniijj@gmail.com> wrote:
> >> > Once upon a time, C++ claimed being a superior system programming language.
> >> > Luckily, Linus Torvalds was not fooled as most C++ beginners were.
> >> 
> >> Almost nothing of what Linux wrote in that idiotic rant was true even back
> >> when it was written, much less now.
> >
> >I would say it has about the same validity as your own arguments about C
> >and how much easier C++ is for beginners (you came up with a similar
> >set of arguments about a year or so ago).  Both languages are difficult
> >for beginners and require a high degree of skill to use well.  On
> >balance I suspect C++ has a few more 'gotchas' because it is a more
> >complex language and does more things for you implicitly.
> >
> >For what it is worth, Linus has now accepted Rust into the linux kernel
> >for certain (at present limited) purposes, principally I think because
> >of its linear/affine type system.
> 
> And linux aside, I've personally written two commercial operating systems and two
> hypervisors in C++ since 1989.   It works just fine for operating systems
> _if you don't use the C++ library crap_.   Don't use vectors, don't use maps,
> don't use exceptions, don't use dynamic allocation.  (use placement new
> or pool-based page/slab/slub allocators).
> 
> You still get the benefits of data hiding/encapsulation, and compiler support
> for what linux calls "ops vectors" (which are basically vtables).
> 
> I do think Linus is off base.   However, it's a moot point as nobody
> will ever rewrite linux in a new language.  He does have a point about
> the odd need for some C++ programmers to show off their expertise by using
> every odd or unusual C++ feature.
[snip]

I go along with pretty much all of that.  I suppose the calculation for
a putative kernel lead (here, Linus) is (i) whether, if you have
started out in C, it is worth moving to C++ (IOW, are the limited
additional features of C++ over C that you would be prepared to accept
in the kernel worth the change) and (ii) whether you trust open source
contributors to stick to that limited set without opening up potential
aggravation later.  That might be easier in a closed-source environment
such as the one I presume you were working in.

The fact is that C is now a vastly smaller language than, say, C++20.

Of course, similar issues arise for including Rust in the kernel.  It
will be interesting to see how it works out.

[toc] | [prev] | [next] | [standalone]


#79151

Fromwij <wyniijj@gmail.com>
Date2021-04-21 22:38 -0700
Message-ID<c9a9cbb4-a838-42e0-bfe0-6e77489d9ca8n@googlegroups.com>
In reply to#79146
On Thursday, 22 April 2021 at 04:14:27 UTC+8, Chris Vine wrote:
> On Wed, 21 Apr 2021 18:33:54 GMT 
> sc...@slp53.sl.home (Scott Lurndal) wrote: 
> > Chris Vine <chris@cvine--nospam--.freeserve.co.uk> writes: 
> > >On Tue, 20 Apr 2021 04:02:30 +0000 (UTC) 
> > >Juha Nieminen <nos...@thanks.invalid> wrote: 
> > >> wij <wyn...@gmail.com> wrote: 
> > >> > Once upon a time, C++ claimed being a superior system programming language. 
> > >> > Luckily, Linus Torvalds was not fooled as most C++ beginners were. 
> > >> 
> > >> Almost nothing of what Linux wrote in that idiotic rant was true even back 
> > >> when it was written, much less now. 
> > > 
> > >I would say it has about the same validity as your own arguments about C 
> > >and how much easier C++ is for beginners (you came up with a similar 
> > >set of arguments about a year or so ago). Both languages are difficult 
> > >for beginners and require a high degree of skill to use well. On 
> > >balance I suspect C++ has a few more 'gotchas' because it is a more 
> > >complex language and does more things for you implicitly. 
> > > 
> > >For what it is worth, Linus has now accepted Rust into the linux kernel 
> > >for certain (at present limited) purposes, principally I think because 
> > >of its linear/affine type system. 
> > 
> > And linux aside, I've personally written two commercial operating systems and two 
> > hypervisors in C++ since 1989. It works just fine for operating systems 
> > _if you don't use the C++ library crap_. Don't use vectors, don't use maps, 
> > don't use exceptions, don't use dynamic allocation. (use placement new 
> > or pool-based page/slab/slub allocators). 
> > 
> > You still get the benefits of data hiding/encapsulation, and compiler support 
> > for what linux calls "ops vectors" (which are basically vtables). 
> > 
> > I do think Linus is off base. However, it's a moot point as nobody 
> > will ever rewrite linux in a new language. He does have a point about 
> > the odd need for some C++ programmers to show off their expertise by using 
> > every odd or unusual C++ feature.
> [snip] 
> 
> I go along with pretty much all of that. I suppose the calculation for 
> a putative kernel lead (here, Linus) is (i) whether, if you have 
> started out in C, it is worth moving to C++ (IOW, are the limited 
> additional features of C++ over C that you would be prepared to accept 
> in the kernel worth the change) and (ii) whether you trust open source 
> contributors to stick to that limited set without opening up potential 
> aggravation later. That might be easier in a closed-source environment 
> such as the one I presume you were working in. 
> 
> The fact is that C is now a vastly smaller language than, say, C++20. 
> 
> Of course, similar issues arise for including Rust in the kernel. It 
> will be interesting to see how it works out.

Yes, C++ fans often ignore the program size issue.
I used often to see C++ complied object file contain almost 1/2 entries
of name symbols, most of them are throw types, rare people care about.
When it comes to the kernel, the entire OS, even 1Gb would make me
worry the life-time of my disk.

[toc] | [prev] | [next] | [standalone]


#79148

From"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Date2021-04-21 15:37 -0700
Message-ID<s5q9g2$1uce$1@gioia.aioe.org>
In reply to#79145
On 4/21/2021 11:33 AM, Scott Lurndal wrote:
> Chris Vine <chris@cvine--nospam--.freeserve.co.uk> writes:
>> On Tue, 20 Apr 2021 04:02:30 +0000 (UTC)
>> Juha Nieminen <nospam@thanks.invalid> wrote:
>>> wij <wyniijj@gmail.com> wrote:
>>>> Once upon a time, C++ claimed being a superior system programming language.
>>>> Luckily, Linus Torvalds was not fooled as most C++ beginners were.
>>>
>>> Almost nothing of what Linux wrote in that idiotic rant was true even back
>>> when it was written, much less now.
>>
>> I would say it has about the same validity as your own arguments about C
>> and how much easier C++ is for beginners (you came up with a similar
>> set of arguments about a year or so ago).  Both languages are difficult
>> for beginners and require a high degree of skill to use well.  On
>> balance I suspect C++ has a few more 'gotchas' because it is a more
>> complex language and does more things for you implicitly.
>>
>> For what it is worth, Linus has now accepted Rust into the linux kernel
>> for certain (at present limited) purposes, principally I think because
>> of its linear/affine type system.
> 
> And linux aside, I've personally written two commercial operating systems and two
> hypervisors in C++ since 1989.   It works just fine for operating systems
> _if you don't use the C++ library crap_.   Don't use vectors, don't use maps,
> don't use exceptions, don't use dynamic allocation.  (use placement new
> or pool-based page/slab/slub allocators).

Agreed!



> 
> You still get the benefits of data hiding/encapsulation, and compiler support
> for what linux calls "ops vectors" (which are basically vtables).
> 
> I do think Linus is off base.   However, it's a moot point as nobody
> will ever rewrite linux in a new language.  He does have a point about
> the odd need for some C++ programmers to show off their expertise by using
> every odd or unusual C++ feature.
> 
> class fs_vectors_t {
>     /* pure virtual (abstract) file system op vectors; e.g. lookup, create, open, close, delete, read, write */
> }
> 
> class ext4_fs : public fs_vectors_t
> {
>   ...
> }
> 
> class btrfs : public fs_vectors_t
> {
>   ...
> }
> 

[toc] | [prev] | [next] | [standalone]


#79178

Fromwij <wyniijj@gmail.com>
Date2021-04-22 10:14 -0700
Message-ID<fba6a636-3ad9-4206-b2c5-52bd40e54533n@googlegroups.com>
In reply to#79145
On Thursday, 22 April 2021 at 02:34:04 UTC+8, Scott Lurndal wrote:
> Chris Vine <chris@cvine--nospam--.freeserve.co.uk> writes: 
> >On Tue, 20 Apr 2021 04:02:30 +0000 (UTC) 
> >Juha Nieminen <nos...@thanks.invalid> wrote: 
> >> wij <wyn...@gmail.com> wrote: 
> >> > Once upon a time, C++ claimed being a superior system programming language. 
> >> > Luckily, Linus Torvalds was not fooled as most C++ beginners were. 
> >> 
> >> Almost nothing of what Linux wrote in that idiotic rant was true even back 
> >> when it was written, much less now. 
> > 
> >I would say it has about the same validity as your own arguments about C 
> >and how much easier C++ is for beginners (you came up with a similar 
> >set of arguments about a year or so ago). Both languages are difficult 
> >for beginners and require a high degree of skill to use well. On 
> >balance I suspect C++ has a few more 'gotchas' because it is a more 
> >complex language and does more things for you implicitly. 
> > 
> >For what it is worth, Linus has now accepted Rust into the linux kernel 
> >for certain (at present limited) purposes, principally I think because 
> >of its linear/affine type system.
> And linux aside, I've personally written two commercial operating systems and two 
> hypervisors in C++ since 1989. It works just fine for operating systems 
> _if you don't use the C++ library crap_. Don't use vectors, don't use maps, 
> don't use exceptions, don't use dynamic allocation. (use placement new 
> or pool-based page/slab/slub allocators). 
> 
> You still get the benefits of data hiding/encapsulation, and compiler support 
> for what linux calls "ops vectors" (which are basically vtables). 
> 
> I do think Linus is off base. However, it's a moot point as nobody 
> will ever rewrite linux in a new language. He does have a point about 
> the odd need for some C++ programmers to show off their expertise by using 
> every odd or unusual C++ feature. 
> 
> class fs_vectors_t { 
> /* pure virtual (abstract) file system op vectors; e.g. lookup, create, open, close, delete, read, write */ 
> } 
> 
> class ext4_fs : public fs_vectors_t 
> { 
> ... 
> } 
> 
> class btrfs : public fs_vectors_t 
> { 
> ... 
> }

I built a dual(mix) mode DOS environment in probably 1999, a last struggle
to sustain software life. So my question is where "placement new" was from?

[toc] | [prev] | [next] | [standalone]


#79157

FromJuha Nieminen <nospam@thanks.invalid>
Date2021-04-22 08:45 +0000
Message-ID<s5rd2i$1vp3$1@gioia.aioe.org>
In reply to#79144
Chris Vine <chris@cvine--nospam--.freeserve.co.uk> wrote:
> On Tue, 20 Apr 2021 04:02:30 +0000 (UTC)
> Juha Nieminen <nospam@thanks.invalid> wrote:
>> wij <wyniijj@gmail.com> wrote:
>> > Once upon a time, C++ claimed being a superior system programming language.
>> > Luckily, Linus Torvalds was not fooled as most C++ beginners were.
>> 
>> Almost nothing of what Linux wrote in that idiotic rant was true even back
>> when it was written, much less now.
> 
> I would say it has about the same validity as your own arguments about C
> and how much easier C++ is for beginners

You are telling me in all seriousness that dynamic string manipulation in C
is as easy as it is in C++, and thus it makes no difference to a beginner
programmer which one he uses?

Seriously?

As for Linus's famous rant, I could write an entire book giving strong
arguments about why he was wrong even back when he wrote it, and how the
vast majority of the claims he presented in that rant were either completely
idiotic, irrelevant, or just outright false.

The only arguments I have seen from C programmers against my original post
have been "use this non-standard extension to make the language better
(not that C is bad and needs any extensions to make it better)".
Not a single actual refutation to my original point: Which one is simpler
from a beginner programmer's perspective, std::string in C++, or raw char
arrays in C (for which standard C offers pretty much no tools to make
their memory management easier or more automatic).

The irony here is that the C programmers making that argument are tacitly
admitting C to be limited and defective, and in bad need for extensions that
would make it better and easier to use. While still strongly maintaining
that it doesn't.

Oh, and of course the other type of argument: "Yeah? Well, how about
rvalue references!" As if that had anything at all to do about teaching
a beginner programmer about using dynamic strings. I find this "well,
C++ has its complexities too!" to be rather infantile because it doesn't
address the actual original argument.

> (you came up with a similar set of arguments about a year or so ago).

You are probably confusing me with someone else. I have not written about
this subject a year ago, or even two years ago.

[toc] | [prev] | [next] | [standalone]


#79158

From"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Date2021-04-22 01:48 -0700
Message-ID<s5rd98$u8$2@gioia.aioe.org>
In reply to#79157
On 4/22/2021 1:45 AM, Juha Nieminen wrote:
> Chris Vine <chris@cvine--nospam--.freeserve.co.uk> wrote:
>> On Tue, 20 Apr 2021 04:02:30 +0000 (UTC)
>> Juha Nieminen <nospam@thanks.invalid> wrote:
>>> wij <wyniijj@gmail.com> wrote:
>>>> Once upon a time, C++ claimed being a superior system programming language.
>>>> Luckily, Linus Torvalds was not fooled as most C++ beginners were.
>>>
>>> Almost nothing of what Linux wrote in that idiotic rant was true even back
>>> when it was written, much less now.
>>
>> I would say it has about the same validity as your own arguments about C
>> and how much easier C++ is for beginners
> 
> You are telling me in all seriousness that dynamic string manipulation in C
> is as easy as it is in C++, and thus it makes no difference to a beginner
> programmer which one he uses?

C++ is definitely easier... Perhaps, a nice lesson in C would be, how 
could we get fairly close to std::string? So, lets get some simple 
functions up and running. Concatenation, indexing into a string, ect...


> 
> Seriously?
> 
> As for Linus's famous rant, I could write an entire book giving strong
> arguments about why he was wrong even back when he wrote it, and how the
> vast majority of the claims he presented in that rant were either completely
> idiotic, irrelevant, or just outright false.
> 
> The only arguments I have seen from C programmers against my original post
> have been "use this non-standard extension to make the language better
> (not that C is bad and needs any extensions to make it better)".
> Not a single actual refutation to my original point: Which one is simpler
> from a beginner programmer's perspective, std::string in C++, or raw char
> arrays in C (for which standard C offers pretty much no tools to make
> their memory management easier or more automatic).
> 
> The irony here is that the C programmers making that argument are tacitly
> admitting C to be limited and defective, and in bad need for extensions that
> would make it better and easier to use. While still strongly maintaining
> that it doesn't.
> 
> Oh, and of course the other type of argument: "Yeah? Well, how about
> rvalue references!" As if that had anything at all to do about teaching
> a beginner programmer about using dynamic strings. I find this "well,
> C++ has its complexities too!" to be rather infantile because it doesn't
> address the actual original argument.
> 
>> (you came up with a similar set of arguments about a year or so ago).
> 
> You are probably confusing me with someone else. I have not written about
> this subject a year ago, or even two years ago.
> 

[toc] | [prev] | [next] | [standalone]


#79159

From"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Date2021-04-22 01:51 -0700
Message-ID<s5rddp$u8$3@gioia.aioe.org>
In reply to#79157
On 4/22/2021 1:45 AM, Juha Nieminen wrote:
> Chris Vine <chris@cvine--nospam--.freeserve.co.uk> wrote:
>> On Tue, 20 Apr 2021 04:02:30 +0000 (UTC)
>> Juha Nieminen <nospam@thanks.invalid> wrote:
>>> wij <wyniijj@gmail.com> wrote:
>>>> Once upon a time, C++ claimed being a superior system programming language.
>>>> Luckily, Linus Torvalds was not fooled as most C++ beginners were.
>>>
>>> Almost nothing of what Linux wrote in that idiotic rant was true even back
>>> when it was written, much less now.
>>
>> I would say it has about the same validity as your own arguments about C
>> and how much easier C++ is for beginners
> 
> You are telling me in all seriousness that dynamic string manipulation in C
> is as easy as it is in C++, and thus it makes no difference to a beginner
> programmer which one he uses?
[...]

Perhaps start out with creating a dynamic array in C, then move on to 
creating a deque using the dynamic array. Linking arrays together... All 
of that fun stuff. ;^)

[toc] | [prev] | [next] | [standalone]


#79163

FromMrSpook_l0xjKyc@b3jtfv70fxckzmak.net
Date2021-04-22 09:40 +0000
Message-ID<s5rgbb$1hnl$1@gioia.aioe.org>
In reply to#79159
On Thu, 22 Apr 2021 01:51:05 -0700
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
>On 4/22/2021 1:45 AM, Juha Nieminen wrote:
>> You are telling me in all seriousness that dynamic string manipulation in C
>> is as easy as it is in C++, and thus it makes no difference to a beginner
>> programmer which one he uses?
>[...]
>
>Perhaps start out with creating a dynamic array in C, then move on to 
>creating a deque using the dynamic array. Linking arrays together... All 
>of that fun stuff. ;^)

Back when I used to do C developer interviews one of my standard questions
would be "Write some code to create and use a linked list". The number of
people who didn't even know where to start never mind write working code 
was quite worrying. I imagine they're the types now writing reams of 
garbage javascript for websites.

[toc] | [prev] | [next] | [standalone]


#79183

From"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Date2021-04-22 12:38 -0700
Message-ID<s5sjbv$3mh$1@gioia.aioe.org>
In reply to#79163
On 4/22/2021 2:40 AM, MrSpook_l0xjKyc@b3jtfv70fxckzmak.net wrote:
> On Thu, 22 Apr 2021 01:51:05 -0700
> "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
>> On 4/22/2021 1:45 AM, Juha Nieminen wrote:
>>> You are telling me in all seriousness that dynamic string manipulation in C
>>> is as easy as it is in C++, and thus it makes no difference to a beginner
>>> programmer which one he uses?
>> [...]
>>
>> Perhaps start out with creating a dynamic array in C, then move on to
>> creating a deque using the dynamic array. Linking arrays together... All
>> of that fun stuff. ;^)
> 
> Back when I used to do C developer interviews one of my standard questions
> would be "Write some code to create and use a linked list". The number of
> people who didn't even know where to start never mind write working code
> was quite worrying. I imagine they're the types now writing reams of
> garbage javascript for websites.
> 

Oh God! Well, here is some of my crude JavaScript in action:

http://funwithfractals.atspace.cc/ct_fdla_anime_dynamic_test

And, yes it uses a linked list... ;^)

[toc] | [prev] | [next] | [standalone]


#79185

FromJuha Nieminen <nospam@thanks.invalid>
Date2021-04-23 07:12 +0000
Message-ID<s5ts0s$an4$1@gioia.aioe.org>
In reply to#79163
MrSpook_l0xjKyc@b3jtfv70fxckzmak.net wrote:
> Back when I used to do C developer interviews one of my standard questions
> would be "Write some code to create and use a linked list". The number of
> people who didn't even know where to start never mind write working code 
> was quite worrying.

Did you score highly if anybody would start explaining the difficulty of
creating a generic linked list in C, and asking all kinds of questions
on what exactly the requirements are for the implementation?

I would immediately ask "a linked list containing what kind of nodes?"
Should it be a generic type of linked list where the calling code gets
to decide what the elements contain? Or should it be just a "hard-coded"
linked list where the content is predetermined, for one particular specific
use? If it should be generic, how should the programmer be able to specify
the contents of the nodes? Should the linked list code support constructing
and destructing the nodes with user-provided construction and destruction
functions?

It would be the perfect example of how such a task would be so much easier
in C++, as the language directly provides the mechanisms for the programmer
to specify the node type, and for those nodes to be automatically
constructed and destroyed properly, without the linked list code having
to worry about it or change its interface according to such requirements.

Honestly, if I were in a situation where I'm programming in C (yes, I have
to do that too), and a linked list would seem to be like the best
solution to a particular problem, I would at a very minimum think a bit
about whether there would be an easier and better solution, rather than
deal with the nightmare of memory management of a linked list (with nodes
that might themselves require memory management).

[toc] | [prev] | [next] | [standalone]


Page 1 of 8  [1] 2 3 4 5 6 7 8  Next page →

Back to top | Article view | comp.lang.c++


csiph-web