Comment

Comment by zasdffaa

Read this paper before and don't buy it.

   // c++
   if (condition1)
      throw my_exception1 ();
you throw an exception because you can't handle it locally. But then he says

   // C
   if (condition1)
      handle_exception1 ();
so if it can be handled locally in C it can also be in C++, so why throw anything?

Also, and I'm not a C++ guy (a little exposure many years ago) so someone correct me, but if you look at part 2 of this article (link at bottom to https://250bpm.com/blog:8/) he then complains about having to have helper data structures

   // c++
   class person
   {
       int age;
       int weight;
   };

   std::list <person*> people;
vs

   // C
   struct person
   {
       struct person *prev;
       struct person *next;
       int age;
       int weight;
   };

   struct
   {
       struct person *first;
       struct person *last;
   } people;

"First thing to note is that the C++ solution allocates twice the number of memory chunks compared to the C solution. For each element of the list there's a little helper object created." [he provides a diagram too]

But surely you can roll those helper objects into the main structure with templates - that is possible, right? OK, you don't use the library util 'std::list <person*> people' but still, it's possible and straightforward, right? Edit: and this was possible in 2012's version of C++ too I'm sure.

parent zasdffaa 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton