# C++ sucks >C makes it easy to shoot yourself in the foot; C++ makes it harder, >but when you do, it blows away your whole leg. --- Bjarne Stroustrup >If you like C++, you don’t know C++. There’s a mutual exclusion going >on here, and I’ve yet to see a counter-example other than possibly a >few of the members of the standards committee. --- ssylvan >I think maybe the guy who invented C++ doesn’t know the difference >between increment and excrement. --- smcameron >I invented the term object oriented, and I can tell you that C++ >wasn't what I had in mind. --- Alan Kay # Object oriented So automatically sucks. # Ugly syntax The only non-ugly part of C++ is the headers' name: iostream, cmath, ctime, thread, etc. Unlike in C, where they are ugly as shit: stdio.h, unistd.h, stdlib.h, pthreads.h... But the rest of the language has the ugliest syntax that I've ever seen: Hello world in C++ ~~~ #include int main(void) { std::cout << "Hello world!" << std:endl; } ~~~ ### What the FUCK was Bjarne smoking when he did this: In C: `printf("0x%04x\n", 0x424);` In C++: `std::cout << "0x" << std::hex << std::setfill('0') << std::setw(4) << 0x424 << std::endl;` Now what the fuck is std:: and why do I have to write << just to print some shit. Note: you can skip the std:: part with ```using namespace std``` but this is a [bad practice](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice) # Error messages in the following code: ~~~ #include int main(void) { std::cout < "Hello world!" < std:endl; } ~~~ You get this error message:

~~~ a.cc: In function ‘int main()’: a.cc:5:13: error: no match for ‘operator<’ (operand types are ‘std::ostream’ {aka ‘std::basic_ostream’} and ‘const char [13]’) 5 | std::cout < "Hello world!" < std:endl; | ~~~~~~~~~ ^ ~~~~~~~~~~~~~~ | | | | | const char [13] | std::ostream {aka std::basic_ostream} In file included from /usr/local/include/c++/10.0.1/bits/stl_algobase.h:64, from /usr/local/include/c++/10.0.1/bits/char_traits.h:39, from /usr/local/include/c++/10.0.1/ios:40, from /usr/local/include/c++/10.0.1/ostream:38, from /usr/local/include/c++/10.0.1/iostream:39, from a.cc:1: /usr/local/include/c++/10.0.1/bits/stl_pair.h:489:5: note: candidate: ‘template constexpr bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)’ 489 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/local/include/c++/10.0.1/bits/stl_pair.h:489:5: note: template argument deduction/substitution failed: a.cc:5:15: note: ‘std::ostream’ {aka ‘std::basic_ostream’} is not derived from ‘const std::pair<_T1, _T2>’ 5 | std::cout < "Hello world!" < std:endl; | ^~~~~~~~~~~~~~ In file included from /usr/local/include/c++/10.0.1/bits/stl_algobase.h:67, from /usr/local/include/c++/10.0.1/bits/char_traits.h:39, from /usr/local/include/c++/10.0.1/ios:40, from /usr/local/include/c++/10.0.1/ostream:38, from /usr/local/include/c++/10.0.1/iostream:39, from a.cc:1: /usr/local/include/c++/10.0.1/bits/stl_iterator.h:366:5: note: candidate: ‘template bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)’ 366 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/local/include/c++/10.0.1/bits/stl_iterator.h:366:5: note: template argument deduction/substitution failed: a.cc:5:15: note: ‘std::ostream’ {aka ‘std::basic_ostream’} is not derived from ‘const std::reverse_iterator<_Iterator>’ 5 | std::cout < "Hello world!" < std:endl; | ^~~~~~~~~~~~~~ In file included from /usr/local/include/c++/10.0.1/bits/stl_algobase.h:67, from /usr/local/include/c++/10.0.1/bits/char_traits.h:39, from /usr/local/include/c++/10.0.1/ios:40, from /usr/local/include/c++/10.0.1/ostream:38, from /usr/local/include/c++/10.0.1/iostream:39, from a.cc:1: /usr/local/include/c++/10.0.1/bits/stl_iterator.h:404:5: note: candidate: ‘template bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)’ 404 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/local/include/c++/10.0.1/bits/stl_iterator.h:404:5: note: template argument deduction/substitution failed: a.cc:5:15: note: ‘std::ostream’ {aka ‘std::basic_ostream’} is not derived from ‘const std::reverse_iterator<_Iterator>’ 5 | std::cout < "Hello world!" < std:endl; | ^~~~~~~~~~~~~~ In file included from /usr/local/include/c++/10.0.1/bits/stl_algobase.h:67, from /usr/local/include/c++/10.0.1/bits/char_traits.h:39, from /usr/local/include/c++/10.0.1/ios:40, from /usr/local/include/c++/10.0.1/ostream:38, from /usr/local/include/c++/10.0.1/iostream:39, from a.cc:1: /usr/local/include/c++/10.0.1/bits/stl_iterator.h:1451:5: note: candidate: ‘template bool std::operator<(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)’ 1451 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/local/include/c++/10.0.1/bits/stl_iterator.h:1451:5: note: template argument deduction/substitution failed: a.cc:5:15: note: ‘std::ostream’ {aka ‘std::basic_ostream’} is not derived from ‘const std::move_iterator<_IteratorL>’ 5 | std::cout < "Hello world!" < std:endl; | ^~~~~~~~~~~~~~ In file included from /usr/local/include/c++/10.0.1/bits/stl_algobase.h:67, from /usr/local/include/c++/10.0.1/bits/char_traits.h:39, from /usr/local/include/c++/10.0.1/ios:40, from /usr/local/include/c++/10.0.1/ostream:38, from /usr/local/include/c++/10.0.1/iostream:39, from a.cc:1: /usr/local/include/c++/10.0.1/bits/stl_iterator.h:1507:5: note: candidate: ‘template bool std::operator<(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&)’ 1507 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/local/include/c++/10.0.1/bits/stl_iterator.h:1507:5: note: template argument deduction/substitution failed: a.cc:5:15: note: ‘std::ostream’ {aka ‘std::basic_ostream’} is not derived from ‘const std::move_iterator<_IteratorL>’ 5 | std::cout < "Hello world!" < std:endl; | ^~~~~~~~~~~~~~ In file included from /usr/local/include/c++/10.0.1/string:55, from /usr/local/include/c++/10.0.1/bits/locale_classes.h:40, from /usr/local/include/c++/10.0.1/bits/ios_base.h:41, from /usr/local/include/c++/10.0.1/ios:42, from /usr/local/include/c++/10.0.1/ostream:38, from /usr/local/include/c++/10.0.1/iostream:39, from a.cc:1: /usr/local/include/c++/10.0.1/bits/basic_string.h:6267:5: note: candidate: ‘template bool std::operator<(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)’ 6267 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/local/include/c++/10.0.1/bits/basic_string.h:6267:5: note: template argument deduction/substitution failed: a.cc:5:15: note: ‘std::ostream’ {aka ‘std::basic_ostream’} is not derived from ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ 5 | std::cout < "Hello world!" < std:endl; | ^~~~~~~~~~~~~~ In file included from /usr/local/include/c++/10.0.1/string:55, from /usr/local/include/c++/10.0.1/bits/locale_classes.h:40, from /usr/local/include/c++/10.0.1/bits/ios_base.h:41, from /usr/local/include/c++/10.0.1/ios:42, from /usr/local/include/c++/10.0.1/ostream:38, from /usr/local/include/c++/10.0.1/iostream:39, from a.cc:1: /usr/local/include/c++/10.0.1/bits/basic_string.h:6280:5: note: candidate: ‘template bool std::operator<(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)’ 6280 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/local/include/c++/10.0.1/bits/basic_string.h:6280:5: note: template argument deduction/substitution failed: a.cc:5:15: note: ‘std::ostream’ {aka ‘std::basic_ostream’} is not derived from ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ 5 | std::cout < "Hello world!" < std:endl; | ^~~~~~~~~~~~~~ In file included from /usr/local/include/c++/10.0.1/string:55, from /usr/local/include/c++/10.0.1/bits/locale_classes.h:40, from /usr/local/include/c++/10.0.1/bits/ios_base.h:41, from /usr/local/include/c++/10.0.1/ios:42, from /usr/local/include/c++/10.0.1/ostream:38, from /usr/local/include/c++/10.0.1/iostream:39, from a.cc:1: /usr/local/include/c++/10.0.1/bits/basic_string.h:6292:5: note: candidate: ‘template bool std::operator<(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)’ 6292 | operator<(const _CharT* __lhs, | ^~~~~~~~ /usr/local/include/c++/10.0.1/bits/basic_string.h:6292:5: note: template argument deduction/substitution failed: a.cc:5:15: note: mismatched types ‘const _CharT*’ and ‘std::basic_ostream’ 5 | std::cout < "Hello world!" < std:endl; | ^~~~~~~~~~~~~~ In file included from /usr/local/include/c++/10.0.1/bits/ios_base.h:46, from /usr/local/include/c++/10.0.1/ios:42, from /usr/local/include/c++/10.0.1/ostream:38, from /usr/local/include/c++/10.0.1/iostream:39, from a.cc:1: /usr/local/include/c++/10.0.1/system_error:252:3: note: candidate: ‘bool std::operator<(const std::error_code&, const std::error_code&)’ 252 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept | ^~~~~~~~ /usr/local/include/c++/10.0.1/system_error:252:31: note: no known conversion for argument 1 from ‘std::ostream’ {aka ‘std::basic_ostream’} to ‘const std::error_code&’ 252 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept | ~~~~~~~~~~~~~~~~~~^~~~~ /usr/local/include/c++/10.0.1/system_error:379:3: note: candidate: ‘bool std::operator<(const std::error_condition&, const std::error_condition&)’ 379 | operator<(const error_condition& __lhs, | ^~~~~~~~ /usr/local/include/c++/10.0.1/system_error:379:36: note: no known conversion for argument 1 from ‘std::ostream’ {aka ‘std::basic_ostream’} to ‘const std::error_condition&’ 379 | operator<(const error_condition& __lhs, | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~ a.cc:5:35: error: found ‘:’ in nested-name-specifier, expected ‘::’ 5 | std::cout < "Hello world!" < std:endl; | ^ | :: ~~~

(In GCC) # Objects are stupid ``` std::string spurdo = "sparde" ``` where spurdo is an object `spurdo.c_str() // converts the string to a C '\0' terminated string.` In C, strings are an array of chars, in C++, they're an object, with methods. # Compatibilty C++ is "compatible" with C But this can break most C programs # A sad story about c++ executables ~~~  try to strip the executable  Did it change anything?  strip?  "strip a.out"  It removes unused stuff  like debug symbols and similar  qorg@satania ~> md5sum a.out cd1cc93ac2ea0c8129042e96ae7d65e7 a.out qorg@satania ~> strip a.out qorg@satania ~> md5sum a.out e6e6e1ea132edb67c6005e703ebe7c81 a.out  yeah?  and now compare the assembly code  how  do i disassembly it or what  how did you do it before?  g++ -S  lol  oof  maybe just compare the filesize  qorg@satania ~> gcc mtx.c -lcurses -lpthread qorg@satania ~> du -h a.out 24K a.out  qorg@satania ~> g++ mtx.cc -lcurses -pthread qorg@satania ~> du -h a.out 40K a.out  now with -Os  qorg@satania ~> gcc mtx.c -lcurses -lpthread -Os qorg@satania ~> du -h a.out 24K a.out  lol  qorg@satania ~> g++ mtx.cc -lcurses -pthread -Os qorg@satania ~> du -h a.out 24K a.out  congrats c++!  exact filesize: 23488 (according to stat)  now the stripped versions  stat'd c version: 21520  stripped c++ 14680  stripped c: 14472  a considerably smaller difference  So c++ is bloated up with debug symbols, awesome  lol  can i take a log of this and put it in kill-9.xyz/harmful/software/c++? ~~~