Hacker News new | ask | show | jobs
by quotemstr 2390 days ago
C with modern safety and productivity features is called "C++" and has been around for decades. I'm amazed at how much effort people will expend just to avoid the C++ boogeyman. No, writing C++ does not automatically make your code bloated. No, using C does not guarantee lean design.

Plain C ought to be considered a legacy language and not used for new code. There is zero reason to prefer it over whatever style of C++ you'd like. If you want procedural struct-based C++, you can have that, but gosh, don't write C.

1 comments

> writing C++ does not automatically make your code bloated

Sorry, but it does.

No, it does not.

  $ cat hello.c
  #include <stdio.h>

  int main(void)
  {
   printf("hello world\n");
   return 0;
  }

  $ cat hello.cpp
  #include <iostream>

  using namespace std;

  int main(void)
  {
   cout << "hello world" << endl;
   return 0;
  }

  $ gcc -o hello_c hello.c
  $ g++ -o hello_cpp hello.cpp
  $ ll hello_*
  -rwxr-xr-x 1 root root 5880 Dec  5 14:13 hello_c
  -rwxr-xr-x 1 root root 7424 Dec  5 14:14 hello_cpp
I see 1544 bytes of bloat. Hope that helps.