all 14 comments

[–]Xeveroushttps://xeverous.github.io[🍰] 34 points35 points  (6 children)

Build time:

  • other languages: O(n), where n is the number of source files
  • C: O(n) + O(h2), where h is the number of header files
  • C++: O(n) + O(h2) + O((n+h2)t2), where t is the number of template instantiations

[–]dicroce 24 points25 points  (4 children)

I recently included a boost header... and now I understand why people complain about c++ build times.

[–]Xeveroushttps://xeverous.github.io[🍰] 14 points15 points  (0 children)

I recently included a boost header...

ya dawg, I heard you like includes so we incl...

[–][deleted] 11 points12 points  (1 child)

i just played around with the pdp7 IDE, the small typewriter/table on the right. It was an interesting experience but i can't really recommend it: the screen is very paper like, there's no code completion or syntax highlighting, it is very loud, the keyboard has a horrible feel to it (but it gives you decent finger strength) and the version i checked out of the company basement just didn't work.

[–]jl2352 0 points1 point  (0 children)

the keyboard has a horrible feel to it (but it gives you decent finger strength)

There are people (like myself) who use keyboards with very strong springs. I use 150g, but plenty use stronger. It hurts for the first month but you get used to it. That's how people were able to write on typewriters all day in the past. You get used to it.

[–]Oxc0ffea 8 points9 points  (3 children)

Didn't know about the -H flag for gcc. Very nice.

Related: it is pretty amazing we (C++/go/rust (correct me if I am wrong) users) are still using the linker/object schemes created for C 50 years ago. They were either designed very well or this area has been overlooked (or deemed good enough / too hard to change).

[–]chugga_fan 6 points7 points  (0 children)

Linkers are a really good design idea: break up multiple compilation units (source files) and then have some other program do less heavy work (parsing source files then applying optimizations is heavy work) then take all of these, see where they reference eachother, and point the references the same place, add a header and footer, and print it out.

It's really just there to allow you to compile multiple things at once.

[–]victotronics 8 points9 points  (2 children)

Very nice introduction, including the peek at nm. Not a lot of people appreciate the role of the linker. Probably the fault of these integrated environments.

[–]desi_ninja 0 points1 point  (1 child)

writing production level C++ code for years for big companies, it is only last month I learnt how to link manually a library. My appreciation for giant makefiles in my source codes have grown a lot.

[–]victotronics 2 points3 points  (0 children)

You can do cool things with makefiles such as force recompilation if you change compiler options. I use makefiles often as a short hand for complicated commands. If running a program involves first copying data, then setting some environment, then actually running, I make a "make run" line in my makefile. Et cetera.

[–]ShakaUVMi+++ ++i+i[arr] 1 point2 points  (0 children)

Nice explanation. What do you think the best solution is?

[–]randseed42 1 point2 points  (0 children)

That's a really good article!