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 2 of 8 — ← Prev page 1 [2] 3 4 5 6 7 8  Next page →


#79192

FromMrSpook_l0c6dv@66h4_0ccefudc0u8w.gov
Date2021-04-23 09:14 +0000
Message-ID<s5u36d$1k7h$1@gioia.aioe.org>
In reply to#79185
On Fri, 23 Apr 2021 07:12:30 +0000 (UTC)
Juha Nieminen <nospam@thanks.invalid> wrote:
>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?

Back in those days you have enough time to get them to solve a few algorithmic 
issues and ask a few pertinent questions then its on to the "Tell me about 
yourself HR waffle". These days employers seem to think they need to give
potential employees a cut down CS degree exam, sometimes done over seperate
days. IMO if you can't tell someones coding ability in 30 mins then you 
shouldn't be an interviewer.

>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.

Or you could just use std::list. The point was to show that they understood
basic data structures and memory allocation.

>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).

If you need a linked list you need a linked list. Using an array or hash
would be the wrong answer.

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


#79260

FromJuha Nieminen <nospam@thanks.invalid>
Date2021-04-26 04:47 +0000
Message-ID<s65gk4$1g70$1@gioia.aioe.org>
In reply to#79192
MrSpook_l0c6dv@66h4_0ccefudc0u8w.gov wrote:
>>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.
> 
> Or you could just use std::list. The point was to show that they understood
> basic data structures and memory allocation.

If I were interviewing someone for a position of C programmer, I would be
most interested in knowing that he understands the dynamic memory management
problems in the language.

A linked list is an extraordinarily trivial data container. Naturally if
the interviewee asks "what's a linked list?" then I wouldn't hire such a
person. However, when the position is for a C programmer in particular,
I *would* be more interested in him understanding the memory management
portion more than the linked list part. If the interviewee started asking
such questions as I presented (ie. what the requirements are for the
list, whether it should be generic or just contain a particular type, etc.)
that would certainly be a positive mark, because he clearly understands the
intricacies of C.

If it were for a C++ position, an answer of a type "I would primarily use
std::list, but if I had to implement the list data structure muself,
I would do it like this..." would score highly.

>>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).
> 
> If you need a linked list you need a linked list. Using an array or hash
> would be the wrong answer.

It's actually relatively rare to need linked lists. There exist
algorithms (ones being actually used out there) where a linked list is
actually the most efficient data container, but in my experience they
tend to be rare.

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


#79269

FromMrSpook_531q@dr4t0dkj168m4ml.tv
Date2021-04-26 08:13 +0000
Message-ID<s65sno$a1q$1@gioia.aioe.org>
In reply to#79260
On Mon, 26 Apr 2021 04:47:02 +0000 (UTC)
Juha Nieminen <nospam@thanks.invalid> wrote:
>MrSpook_l0c6dv@66h4_0ccefudc0u8w.gov wrote:
>> Or you could just use std::list. The point was to show that they understood
>> basic data structures and memory allocation.
>
>If I were interviewing someone for a position of C programmer, I would be
>most interested in knowing that he understands the dynamic memory management
>problems in the language.

That comes as part of creating a linked list in C - ie malloc the list 
element and then freeing it and resetting pointers.

>A linked list is an extraordinarily trivial data container. Naturally if

It might be a trivial container, but implementing it from scratch isn't as
it has a few gotchas particularly doubly linked ones. Anyway as i've said, it 
was a job interview, not a comp sci exam.

>the interviewee asks "what's a linked list?" then I wouldn't hire such a
>person. 

Well obviously not.

>If it were for a C++ position, an answer of a type "I would primarily use
>std::list, but if I had to implement the list data structure muself,
>I would do it like this..." would score highly.

Indeed.

>> If you need a linked list you need a linked list. Using an array or hash
>> would be the wrong answer.
>
>It's actually relatively rare to need linked lists. There exist

Queues. You can implement them using arrays but that would be very inefficient.
Obviously in C++ there are already queue containers, but in C you'd use
a linked list.

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


#79270

From"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Date2021-04-26 01:22 -0700
Message-ID<s65t7p$ftr$1@gioia.aioe.org>
In reply to#79269
On 4/26/2021 1:13 AM, MrSpook_531q@dr4t0dkj168m4ml.tv wrote:
> On Mon, 26 Apr 2021 04:47:02 +0000 (UTC)
> Juha Nieminen <nospam@thanks.invalid> wrote:
>> MrSpook_l0c6dv@66h4_0ccefudc0u8w.gov wrote:
>>> Or you could just use std::list. The point was to show that they understood
>>> basic data structures and memory allocation.
>>
>> If I were interviewing someone for a position of C programmer, I would be
>> most interested in knowing that he understands the dynamic memory management
>> problems in the language.
> 
> That comes as part of creating a linked list in C - ie malloc the list
> element and then freeing it and resetting pointers.
> 
>> A linked list is an extraordinarily trivial data container. Naturally if
> 
> It might be a trivial container, but implementing it from scratch isn't as
> it has a few gotchas particularly doubly linked ones. Anyway as i've said, it
> was a job interview, not a comp sci exam.
> 
>> the interviewee asks "what's a linked list?" then I wouldn't hire such a
>> person.
> 
> Well obviously not.
> 
>> If it were for a C++ position, an answer of a type "I would primarily use
>> std::list, but if I had to implement the list data structure muself,
>> I would do it like this..." would score highly.
> 
> Indeed.
> 
>>> If you need a linked list you need a linked list. Using an array or hash
>>> would be the wrong answer.
>>
>> It's actually relatively rare to need linked lists. There exist
> 
> Queues. You can implement them using arrays but that would be very inefficient.
> Obviously in C++ there are already queue containers, but in C you'd use
> a linked list.
> 

Check this queue out:

https://groups.google.com/g/lock-free/c/acjQ3-89abE/m/a6-Di0GZsyEJ

;^)

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


#79275

FromMrSpook_9p05k3C69@xr34.gov.uk
Date2021-04-26 09:03 +0000
Message-ID<s65vlf$1po2$1@gioia.aioe.org>
In reply to#79270
On Mon, 26 Apr 2021 01:22:17 -0700
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
>On 4/26/2021 1:13 AM, MrSpook_531q@dr4t0dkj168m4ml.tv wrote:
>> Queues. You can implement them using arrays but that would be very
>inefficient.
>> Obviously in C++ there are already queue containers, but in C you'd use
>> a linked list.
>> 
>
>Check this queue out:
>
>https://groups.google.com/g/lock-free/c/acjQ3-89abE/m/a6-Di0GZsyEJ


iIt doesn't show the definition of XADD, LOAD or STORE so who knows how
efficient it is or isn't. But I'd be surprised if its better than a list.

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


#79276

From"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Date2021-04-26 02:17 -0700
Message-ID<s660ev$65e$1@gioia.aioe.org>
In reply to#79275
On 4/26/2021 2:03 AM, MrSpook_9p05k3C69@xr34.gov.uk wrote:
> On Mon, 26 Apr 2021 01:22:17 -0700
> "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
>> On 4/26/2021 1:13 AM, MrSpook_531q@dr4t0dkj168m4ml.tv wrote:
>>> Queues. You can implement them using arrays but that would be very
>> inefficient.
>>> Obviously in C++ there are already queue containers, but in C you'd use
>>> a linked list.
>>>
>>
>> Check this queue out:
>>
>> https://groups.google.com/g/lock-free/c/acjQ3-89abE/m/a6-Di0GZsyEJ
> 
> 
> iIt doesn't show the definition of XADD, LOAD or STORE so who knows how
> efficient it is or isn't. But I'd be surprised if its better than a list.
> 

XADD is an atomic fetch-and-add RMW, load and store are atomic loads and 
stores.

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


#79278

FromMrSpook_i4zl8mHy@0tr9r.eu
Date2021-04-26 09:23 +0000
Message-ID<s660qm$dbs$1@gioia.aioe.org>
In reply to#79276
On Mon, 26 Apr 2021 02:17:20 -0700
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
>On 4/26/2021 2:03 AM, MrSpook_9p05k3C69@xr34.gov.uk wrote:
>> On Mon, 26 Apr 2021 01:22:17 -0700
>> "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
>>> On 4/26/2021 1:13 AM, MrSpook_531q@dr4t0dkj168m4ml.tv wrote:
>>>> Queues. You can implement them using arrays but that would be very
>>> inefficient.
>>>> Obviously in C++ there are already queue containers, but in C you'd use
>>>> a linked list.
>>>>
>>>
>>> Check this queue out:
>>>
>>> https://groups.google.com/g/lock-free/c/acjQ3-89abE/m/a6-Di0GZsyEJ
>> 
>> 
>> iIt doesn't show the definition of XADD, LOAD or STORE so who knows how
>> efficient it is or isn't. But I'd be surprised if its better than a list.
>> 
>
>XADD is an atomic fetch-and-add RMW, load and store are atomic loads and 
>stores.

OK, but the size of cells[] is fixed at start up which makes it useless for 
any serious use case aside from perhaps in embedded systems where limits
need to be set which means the cost of resizing the array doesn't come into
it. Plenty of things can be implemented cheaply if you hard limit the max
size at the start.

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


#79277

From"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Date2021-04-26 02:22 -0700
Message-ID<s660o8$are$1@gioia.aioe.org>
In reply to#79275
On 4/26/2021 2:03 AM, MrSpook_9p05k3C69@xr34.gov.uk wrote:
> On Mon, 26 Apr 2021 01:22:17 -0700
> "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
>> On 4/26/2021 1:13 AM, MrSpook_531q@dr4t0dkj168m4ml.tv wrote:
>>> Queues. You can implement them using arrays but that would be very
>> inefficient.
>>> Obviously in C++ there are already queue containers, but in C you'd use
>>> a linked list.
>>>
>>
>> Check this queue out:
>>
>> https://groups.google.com/g/lock-free/c/acjQ3-89abE/m/a6-Di0GZsyEJ
> 
> 
> iIt doesn't show the definition of XADD, LOAD or STORE so who knows how
> efficient it is or isn't. But I'd be surprised if its better than a list.
> 

Actually its faster than lock-free queues comprised of linked nodes, but 
it is bounded. So, in a sense, its not really fair to compare it to a 
linked node queue. Its faster, but oh well, its bounded.

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


#79281

FromJuha Nieminen <nospam@thanks.invalid>
Date2021-04-26 09:37 +0000
Message-ID<s661kf$nf5$1@gioia.aioe.org>
In reply to#79269
MrSpook_531q@dr4t0dkj168m4ml.tv wrote:
> Queues. You can implement them using arrays but that would be very inefficient.

std::deque doesn't use linked lists, and I don't think it's very inefficient.

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


#79284

FromMrSpook_gbzt63zc@83jpfr9ry9f55a.tv
Date2021-04-26 10:22 +0000
Message-ID<s664a1$7ur$1@gioia.aioe.org>
In reply to#79281
On Mon, 26 Apr 2021 09:37:21 +0000 (UTC)
Juha Nieminen <nospam@thanks.invalid> wrote:
>MrSpook_531q@dr4t0dkj168m4ml.tv wrote:
>> Queues. You can implement them using arrays but that would be very
>inefficient.
>
>std::deque doesn't use linked lists, and I don't think it's very inefficient.

It would seem it uses a combination of a tree structure (which is a type
of list) and fixed size array chunks. 

https://stackoverflow.com/questions/6292332/what-really-is-a-deque-in-stl

So yes, obviously fixed sized arrays are efficient but I suspect the potential
memory wastage isn't something that would suit everyone. And you probably
wouldn't implement something this complex yourself in C unless it was a very
specific application.

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


#79287

FromBo Persson <bo@bo-persson.se>
Date2021-04-26 13:05 +0200
Message-ID<ienl3uFlig1U1@mid.individual.net>
In reply to#79284
On 2021-04-26 at 12:22, MrSpook_gbzt63zc@83jpfr9ry9f55a.tv wrote:
> On Mon, 26 Apr 2021 09:37:21 +0000 (UTC)
> Juha Nieminen <nospam@thanks.invalid> wrote:
>> MrSpook_531q@dr4t0dkj168m4ml.tv wrote:
>>> Queues. You can implement them using arrays but that would be very
>> inefficient.
>>
>> std::deque doesn't use linked lists, and I don't think it's very inefficient.
> 
> It would seem it uses a combination of a tree structure (which is a type
> of list) and fixed size array chunks.

The internal structure is not a list (or a tree), but an array of 
pointers to the chunks. This array *will* have to be reallocated 
occationally, but only by copying the set of pointers, not by moving all 
the data stored in the chunks.


> 
> https://stackoverflow.com/questions/6292332/what-really-is-a-deque-in-stl
> 
> So yes, obviously fixed sized arrays are efficient but I suspect the potential
> memory wastage isn't something that would suit everyone. And you probably
> wouldn't implement something this complex yourself in C unless it was a very
> specific application.
> 

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


#79288

FromDavid Brown <david.brown@hesbynett.no>
Date2021-04-26 13:10 +0200
Message-ID<s6673i$qa8$1@dont-email.me>
In reply to#79284
On 26/04/2021 12:22, MrSpook_gbzt63zc@83jpfr9ry9f55a.tv wrote:
> On Mon, 26 Apr 2021 09:37:21 +0000 (UTC)
> Juha Nieminen <nospam@thanks.invalid> wrote:
>> MrSpook_531q@dr4t0dkj168m4ml.tv wrote:
>>> Queues. You can implement them using arrays but that would be very
>> inefficient.
>>
>> std::deque doesn't use linked lists, and I don't think it's very inefficient.
> 
> It would seem it uses a combination of a tree structure (which is a type
> of list) and fixed size array chunks. 
> 
> https://stackoverflow.com/questions/6292332/what-really-is-a-deque-in-stl
> 
> So yes, obviously fixed sized arrays are efficient but I suspect the potential
> memory wastage isn't something that would suit everyone. And you probably
> wouldn't implement something this complex yourself in C unless it was a very
> specific application.
> 

In situations where you might worry about the memory wastage of a
fixed-size array of pointers, you are most likely dealing with a
small-system resource constrained embedded system.  And in that case,
you /definitely/ want a fixed size array, not dynamic memory - because
/knowing/ that your system has enough memory is vastly more important
than minimising the memory usage.  (You wouldn't use a C++ std::deque in
such cases, of course - you'd prefer a std::array.)

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


#79290

FromPaavo Helde <myfirstname@osa.pri.ee>
Date2021-04-26 14:38 +0300
Message-ID<s668n1$pdq$1@dont-email.me>
In reply to#79269
26.04.2021 11:13 MrSpook_531q@dr4t0dkj168m4ml.tv kirjutas:
> On Mon, 26 Apr 2021 04:47:02 +0000 (UTC)
> Juha Nieminen <nospam@thanks.invalid> wrote:
>> It's actually relatively rare to need linked lists. There exist
> 
> Queues. You can implement them using arrays but that would be very inefficient.
> Obviously in C++ there are already queue containers, but in C you'd use
> a linked list.

In C++ the container to use for queues is std::deque. In C one does not 
use it because it would be too tedious and error-prone to code it. So in 
C one uses a linked list instead which is relatively easy to code (but 
still pretty error prone).

So in C++ we have a built-in superior data structure which does not need 
developing and is easy to use. This data structure is not used in C 
because it's too hard to develop and too hard to use. How this would 
prove anything in favor of C is beyond my imagination.

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


#79294

FromMrSpook_mD_r@g72w8ixztm106rprqnby.tv
Date2021-04-26 13:49 +0000
Message-ID<s66ge7$ltm$1@gioia.aioe.org>
In reply to#79290
On Mon, 26 Apr 2021 14:38:08 +0300
Paavo Helde <myfirstname@osa.pri.ee> wrote:
>26.04.2021 11:13 MrSpook_531q@dr4t0dkj168m4ml.tv kirjutas:
>> On Mon, 26 Apr 2021 04:47:02 +0000 (UTC)
>> Juha Nieminen <nospam@thanks.invalid> wrote:
>>> It's actually relatively rare to need linked lists. There exist
>> 
>> Queues. You can implement them using arrays but that would be very
>inefficient.
>> Obviously in C++ there are already queue containers, but in C you'd use
>> a linked list.
>
>In C++ the container to use for queues is std::deque. In C one does not 
>use it because it would be too tedious and error-prone to code it. So in 
>C one uses a linked list instead which is relatively easy to code (but 
>still pretty error prone).
>
>So in C++ we have a built-in superior data structure which does not need 
>developing and is easy to use. This data structure is not used in C 
>because it's too hard to develop and too hard to use. How this would 
>prove anything in favor of C is beyond my imagination.

I never said it does. We were discussing interview questions for C.

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


#79162

FromMrSpook_lxrj1vfhmw@qdgb.org
Date2021-04-22 09:37 +0000
Message-ID<s5rg55$1f75$1@gioia.aioe.org>
In reply to#79157
On Thu, 22 Apr 2021 08:45:08 +0000 (UTC)
Juha Nieminen <nospam@thanks.invalid> wrote:
>Chris Vine <chris@cvine--nospam--.freeserve.co.uk> wrote:
>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).

Dynamic string handling in C really isn't that hard. You've got strdup()
and asprintf() to allocate and calling free() really isn't hard though 
obviously you have to remember to do it! The only thing C really needs is
an appendString() function out the box but frankly writing one yourself is a 2 
minute job.

But given the choice I'd use C++ and std::string.

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


#79164

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2021-04-22 11:32 +0100
Message-ID<87eef2sj88.fsf@bsb.me.uk>
In reply to#79162
MrSpook_lxrj1vfhmw@qdgb.org writes:

> On Thu, 22 Apr 2021 08:45:08 +0000 (UTC)
> Juha Nieminen <nospam@thanks.invalid> wrote:
>>Chris Vine <chris@cvine--nospam--.freeserve.co.uk> wrote:
>>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).
>
> Dynamic string handling in C really isn't that hard. You've got strdup()
> and asprintf() to allocate

Not if you are referring to standard C.  These are often available, but
the language itself, as standardised, does not have them.

> and calling free() really isn't hard though 
> obviously you have to remember to do it!

Ensuring that free is called correctly often dictates the shape of a
function, which can be a distraction from writing the algorithm as
clearly as possible.  Old C hands may do this semi-automatically, but
it's anther obstacle for beginners.

> The only thing C really needs is
> an appendString() function out the box but frankly writing one yourself is a 2 
> minute job.

Without writing YASS (Yet Another String Struct), every append will
result in an allocation, a copy and a free.  C programmers get used to
keeping the size around and over-allocating to ensure these costs are
ameliorated.  None of it is hard, but it's more obstacles for beginners.

> But given the choice I'd use C++ and std::string.

ACK.

-- 
Ben.

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


#79165

FromMrSpook_f0mj9r@d6g.gov.uk
Date2021-04-22 10:38 +0000
Message-ID<s5rjmc$18u7$1@gioia.aioe.org>
In reply to#79164
On Thu, 22 Apr 2021 11:32:07 +0100
Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
>MrSpook_lxrj1vfhmw@qdgb.org writes:
>> Dynamic string handling in C really isn't that hard. You've got strdup()
>> and asprintf() to allocate
>
>Not if you are referring to standard C.  These are often available, but
>the language itself, as standardised, does not have them.

If you only use the core language whether C or C++ you'll be rolling your
own for most things.

>> The only thing C really needs is
>> an appendString() function out the box but frankly writing one yourself is a
>2 
>> minute job.
>
>Without writing YASS (Yet Another String Struct), every append will
>result in an allocation, a copy and a free.  C programmers get used to
>keeping the size around and over-allocating to ensure these costs are
>ameliorated.  None of it is hard, but it's more obstacles for beginners.

You can't get around the copy no matter how you manage the memory and
with an intelligent implementation of realloc() that attempts to extend the
current memory block hopefully the amount of free'ing will be limited too.

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


#79166

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2021-04-22 12:35 +0100
Message-ID<878s5asgb9.fsf@bsb.me.uk>
In reply to#79165
MrSpook_f0mj9r@d6g.gov.uk writes:

> On Thu, 22 Apr 2021 11:32:07 +0100
> Ben Bacarisse <ben.usenet@bsb.me.uk> wrote:
>>MrSpook_lxrj1vfhmw@qdgb.org writes:
>>> Dynamic string handling in C really isn't that hard. You've got strdup()
>>> and asprintf() to allocate
>>
>>Not if you are referring to standard C.  These are often available, but
>>the language itself, as standardised, does not have them.
>
> If you only use the core language whether C or C++ you'll be rolling your
> own for most things.

Sure.  That's the focus of this particular criticism, I think.

Mind you, it also raises the question of why stop at strdup and
asprintf?  A fuller string library would make it even easier!

>>> The only thing C really needs is
>>> an appendString() function out the box but frankly writing one yourself is a
>>2 
>>> minute job.
>>
>>Without writing YASS (Yet Another String Struct), every append will
>>result in an allocation, a copy and a free.  C programmers get used to
>>keeping the size around and over-allocating to ensure these costs are
>>ameliorated.  None of it is hard, but it's more obstacles for beginners.
>
> You can't get around the copy no matter how you manage the memory and
> with an intelligent implementation of realloc() that attempts to extend the
> current memory block hopefully the amount of free'ing will be limited
> too.

I don't think I was clear.  If a string is represented as nothing more
that a pointer, appendString() will be expensive.  You have to choose
between a simple interface or more efficient allocation.  With

  char *appendString(const char *s1, size_t len, const char *s2)

you can avoid a strlen call but if realloc is to be used the beginner
must know the rules: that the string being appended to must be allocated
and not be static, and that the contents of it will change.

And to guarantee efficient string growth, you need appendString to over
allocate and return the size_available as well.

-- 
Ben.

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


#79167

FromChris Vine <chris@cvine--nospam--.freeserve.co.uk>
Date2021-04-22 13:35 +0100
Message-ID<20210422133543.4e033d5a39c1e867a5e36447@cvine--nospam--.freeserve.co.uk>
In reply to#79157
On Thu, 22 Apr 2021 08:45:08 +0000 (UTC)
Juha Nieminen <nospam@thanks.invalid> 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?
[snip]

I wasn't commenting specifically on string manipulation, which is
something C++ does better.  I was commenting on your more general point
that C++ is considerably easier for beginners to learn.

On the specific point of string manipulation, a beginning wanting to
become a competent C++ programmer is going to have to learn the
principles of how C strings work fairly early on, because similar issues
are applicable to other resource management cases for which C++ does
not provide a standard library wrapper, and for which programmers are
going to have to write their own wrapper classes.  And of course
std::string does expose C strings in its interface.  You are simply not
going to get very far in C++ if you don't understand C strings.

> > (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.

I think I was thinking of your contributions to the thread "Why should
a c programmer learn c++", in which as I recall you made similar
points.  But I am willing to be corrected.

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


#79186

FromJuha Nieminen <nospam@thanks.invalid>
Date2021-04-23 07:20 +0000
Message-ID<s5tsg5$an4$2@gioia.aioe.org>
In reply to#79167
Chris Vine <chris@cvine--nospam--.freeserve.co.uk> wrote:
> You are simply not
> going to get very far in C++ if you don't understand C strings.

The problem in this case is not understanding how C strings work, but
managing dynamically allocated (and length-changing) strings.

> I think I was thinking of your contributions to the thread "Why should
> a c programmer learn c++", in which as I recall you made similar
> points.  But I am willing to be corrected.

My arguments there were essentially "you aren't really losing anything
by moving to C++ from C (in terms of features and efficiency)".

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


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

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


csiph-web