10 ms·
The Time Needed to Write “Effective Modern C++”
- greg7mdp 12y agoLove the book!
- misiti3780 12y agoAll of his books are great - especially the one on STL. Herb Sutter wrote some great C++ books also. On a side note, based on that picture of him sitting at this desk, he is still using iPod V1
- joshuapants 12y ago> he is still using iPod V1 Are you sure? I see some color contrast between the center button and the wheel, and no ring of buttons around it.
- gms 12y agoIt's not V1 - that one took a Firewire cable, not USB.
- quotemstr 12y agoSutter's written that we should use "async" everywhere (even though conventional threads have numerous advantages) and that we should use "auto" everywhere (even to the point of writing "auto x = int{5}" instead of "int x = 5" and "auto foo() -> void" instead of "void foo()"). I'd take his advise with a grain of salt.
- quotemstr 12y agoSutter's written that we should use "async" everywhere and that we should use "auto" everywhere, even to the point of writing "auto x = int{5}" instead of "int x = 5" and "auto foo() -> void" instead of "void foo()". I'd take his advise with a grain of salt.
- shmerl 12y agoIt's a must have book.
- mpu 12y agoIs this guy actually writing C++ programs in the wild? He often presents himself as an apostle in the C++ church, but, I am always surprised that he does not seem to apply his guidelines into any practical project of his. As a programmer, I'm suspicious when people have opinions and give advice but never showed me more than snippets of code. Like a master tailor that wouldn't sew. How come he gets that much recognition and respect? I would be much more inclined into accepting advice from someone like, say, Carmack, that has successful projects in C++ under his belt. (Many people consider Doom 3's code beautiful C++, yet, the choices made there are very controversial, and far from "modern".) I also put Bjarne Stroustrup in the same category. What do you think?
- solipsism 12y agoAre you putting Stroutrup in the I'm suspicious of his advice category or the He teaches from experience category?
- rshaban 12y agoIt would seem from the context of his statement the latter, especially given that he built C++
- lfowles 12y agoIt could also go the "ivory tower" direction
- solipsism 12y agoCreating C++ means you're likely to know the ins and outs of the language. That's a necessary condition to being a good C++ programmer, but it's not sufficient. It's not at all obvious to me that Stroustrup would be a good C++ programmer or even a good C programmer.
- innguest 12y agoMacho man! If you need to know the intricacies of an abstraction in order to use an abstraction, then it's not a very good abstraction. Do engineers know the ins and outs of concrete and rebar? Or do they offload that knowledge onto manufacturers? But programmers can't offload anything onto the language creator or they aren't real programmers. I'm glad for all the work the SBCL and GHC teams put onto their languages so I can use their abstractions without needing to know the ins and outs of performance optimization. Maybe one day you'll find a language you like that allows you to focus more on your problem domain and less on its traps, idiossyncrasies and inadequacies.
- curiouslurker 12y agoI wonder how long it took Kernighan and Ritchie to write 'The C Programming Language'? Amazon says the 2nd edition (1988) is 272 pages long but looking back, it felt like it was 80 pages :) Going by the OP's math (of the language creator being twice as productive) prolly 4 months?
- TylerE 12y agoRemember that that's inluding like 60 pages of what are basically printed man pages.
- unwind 12y agoWhen K&R was written, it's not a given that the man pages for C functions already existed, is it?
- Sanddancer 12y agoThey were, albeit potentially more terse than is available now. System III's functions section was pretty full by 1983 even [1]. [1] http://minnie.tuhs.org/cgi-bin/utree.pl?file=pdp11v/usr/man/u_man/man3 http://minnie.tuhs.org/cgi-bin/utree.pl?file=pdp11v/usr/man/...
- dagw 12y agoSystem III's functions section was pretty full by 1983 K&R was published in 1978
- mikekchar 12y agoVery interesting to reflect on the amount of time needed to write a technical book on a programming language. If I compare that to amount of time taken to write code (and forgive me for the horrible KLOC metric), I think one could easily average about 300 lines of good C++ code (including tests) per day on a new project -- probably more if you are working alone, but let's keep it conservative. So about 37.5 lines per hour * 1350 hours = ~50KLOC. Say half of it is tests, so that's a medium sized app. I don't know why, but writing a book seems waaay more effort than churning out ~25 KLOC of tested C++. I guess it is what you are used to... * 300 lines per day is what I averaged over a multi-year period when I was a C++ programmer. But that was more than a decade ago, so I'm guessing it would take less lines of code with "Effective Modern C++" ;-) (and yes, I measured it for interest sake...)
- munificent 12y ago> I don't know why, but writing a book seems waaay more effort than churning out ~25 KLOC of tested C++. It is. I wrote a programming book, and the code for each chapter was always a breeze compared to writing the prose. I rationalize it by thinking of English as a programming language. It has a fantastically complex syntax and semantics, tons of undefined behavior, and a few billion interpreters out there, each with a large number of quirks and bugs. Writing a program in English that does the more or less correct thing on all of those interpreters ain't easy.
- geerlingguy 12y agoDitto. I'm almost finished writing a book Ansible (self published on LeanPub), and most of the difficult sections have had the code samples ready to go for months. Getting the code organized an laid out in a logical fashion with appropriate, short intros, descriptions, and summaries requires much more effort than the code itself!
- greggman 12y agoI'm actually finding it hard because I feel like I need to re-write all the old chapters each time I write a new one. The problem is as I go from A to B to C when I get to D I realize I really want the code to be in a different shape. But to do that I either need to make a C' where I take a timeout to explain why I'm refactoring the code before I move on to D. Or, I need to go re-write A, B, and C so they fit directly into D. Making C` sucks because it's irrelevant to whatever the topic is. But re-writing is also a ton of work. You could argue I should start at Z and work backward but I'm writing as I go so I don't know what Z is yet.
- kenrikm 12y agoWith the amount of time invested into writing the book it would be interesting to see what type of financial return he was able to get for it. Certainly I would hope he was able to make as much as if he were working in private industry for the same amount of time. (though somehow I doubt this is the case)
- bluedino 12y agoBeing an author of a well regarded programming book has plenty of benefits that don't involve book royalties. You're considered an industry expert and can make money on speaking and consulting gigs.
- watmough 12y agoJohn Resig may be a bigger name, and he didn't make much from publishing. http://ejohn.org/blog/programming-book-profits/ http://ejohn.org/blog/programming-book-profits/ It doesn't seem like the reward is primarily financial, though I'm incredibly glad of both Scott's C++ books, and Resig's Javascript books.
- InclinedPlane 12y agoTo within a disturbingly accurate margin of error I can tell you right now his financial return for this book: zero dollars. There isn't enough money in tech books for writers to rely on it as a day job. At best it'll get you noticed and make other jobs or speaking engagements easier to get.
- ipsin 12y agoI am inclined to disbelieve you. I could agree that tech writing in general doesn't pay well, but this is an author who has sold over 150,000 physical copies, in addition to whatever virtual sales (like mine) he's had. Even if his take is 10% for a $30 book, that's still respectable income.
- InclinedPlane 12y agoI had no idea where you came up with the "150,000 copies" figure but then I ended up seeing the same thing listed on a page about "More Effective C++", which has been in print for 2 decades. Even if he received $3-4 per copy sold for all those books, that's over a 20 year timespan, that only works out to $20k or so a year, although he does have other books. It's possible that Scott Meyers might be a sufficiently popular author to be able to support himself just on book income at a level comparable to having a decent day job, but at best it's a very close thing and even so he would be one of the extremely rare few who could do so.
- istvan__ 12y agoCould somebody redpill me on why something like D (http://dlang.org/ http://dlang.org/) is not a better alternative to C++. Is that the library support or what exactly makes C++ still a better option in 2015? I am not sure what is the best alternative to C++.
- aric 12y agoD is a better alternative for many people. Speaking of Scott Meyers, C++, and D, his talk at DConf 2014 was humorous and you'll get a better sense of him. https://www.youtube.com/watch?v=48kP_Ssg2eY https://www.youtube.com/watch?v=48kP_Ssg2eY It depends on your actual goals. Personally, though I prefer Go for everything when possible, my favorite alternative to C++ is C++. If you want a true alternative, Rust is probably a smarter investment of time compared to D, based on traction. However, I'm uninformed about the D community as of late, and certainly won't be surprised of a future surge.
- istvan__ 12y agoThanks this video is just too funny. I was aware of the quirkiness of C++ but this is very insightful. On the Go note, I like it but I think the target of Go is system programming with great concurrency support. More about Go here: http://yager.io/programming/go.html http://yager.io/programming/go.html Rust seems to incorporate all of the academic research about programming languages and also moves towards memory safety and correctness, and that is a good start. See what happens in the next 10 years! :)
- aric 12y agoScott is hilarious. He's a bundle of insight. The slight jest about C++ being an alternative to itself sums it up: it can be a multidimensional beast. Quirky is a very kind way to describe smashing one's head on a keyboard repeatedly. That said, C++11 changed its game. It's so much easier to write in it without inducing bleeding eye syndrome. The Go article has some fair points. Yet, most of the reasons the author discounts Go are reasons I prefer Go. Its minimalism is a virtue. I'm grateful that it ignores a lot of research overload. It's grounding. I see more and do more in it. Reading people's code and the standard library itself isn't painful. Go is versatile. Systems don't sum it up. In my view, it'll have a healthy stride in a lot of other areas outside of networking and the web, given time (e.g. desktop GUIs, mobile, games, game servers, etc.). In 10 years, we'll have exhausted all letters and be back on C.
- blt 12y agoI write C++ for a living and I like it, but it bothers me that we need a book that's essentially a list of "you can easily fuck this up by accident, watch out!" for now, it seems that C is insufficiently expressive and everything else is too slow. but the complexity of C++ is troubling.
- angersock 12y agoEverything else isn't too slow, though, especially if you hit any meaningful IO.
- unstabilo 12y agoOr if you use clever algorithms. I don't have benchmarks at hand, but I suspect that an FFT in Python is faster than a naive Fourier transform in C.
- nadam 12y agoTheoretically this is true, but in practice, those who need to write very efficient code competitively, rarely use naive algorithms. (Pure C/C++ also isn't enough nowadays though, the processor isn't competitive with the GPU in a lot of algorithms, so CUDA/OpenCL needs to be also used in most cases.)
- stinos 12y agoNot sure if this way of comparing programming languages (i.e. do A in language X and do B in language Y => Y is not slower than X) makes enough sense to draw conclusions. If you can use clever algorithms, in the majority of cases you'd do so in any language and in the majority of cases C would lead to more performant code than Python. Then again, wheteher this matters in the scope of the actual application is something else.
- verbin217 12y agoI suspect his comment meant to imply that a level of skill exists for which a programmer could build an FFT in python, a plain DFT in C, but not a proper FFT in C. That programmer would benefit from using python.
- bankim 12y agoI've read couple of Effective C++ series books by him and I've found Effective STL to be the most useful book for my day-to-day C++ programming at work.
- blaenk 12y agoI actually finished this book today. It's a great resource on the various pitfalls and good practices that are present in C++11/C++14, and they are presented in a very readable format that really lends itself to referencing later on. I highly recommend it.
- ternaryoperator 12y agoWhen I track my time scrupulously, the results are significantly different than what I thought they would be and also quite different from what, several weeks removed, I remembered re the project. So, when I read an article that does back of the envelope calculations on time spent, based on rough estimates (20% on other projects, etc.), I find myself suspicious of the computed results.
- oskarth 12y agoThis is interesting, but the hours are vastly overestimated, at least compared to similar metrics (e.g. from the deliberate practice and expertise literature): If we figure a 40-hour work week... it wasn't my only activity. Let's knock that number down by 20% to account for my occasionally having to spend time on other things. There's no way anyone spends 40 or even 30 hours a week writing. Most authors spend something like 3-4 hours a day writing - and that's a good day! See for example the chapter on writers in Cambridge Expertise Performance Handbook (http://www.amazon.com/Cambridge-Expertise-Performance-Handbooks-Psychology/dp/0521600812 http://www.amazon.com/Cambridge-Expertise-Performance-Handbo...). In general this type of reasoning (40h work week => time for 40h of writing) makes time estimates troublesome in my opinion. Another example is people who claim to write code for 40, 60 or even 80 hours a week. A look at actual RescueTime data gives a sober picture: https://news.ycombinator.com/item?id=209195 https://news.ycombinator.com/item?id=209195 Of course, you could claim a lot of the work happens in breaks, and I would agree. But then the actual weekly number for our most beloved artists, programmers, and scientists is more like 24*7, literally. In that case, it makes more sense to talk about it in on the timescale of days, weeks, months or years.
- TheOtherHobbes 12y agoI find the hours amazing. My understanding is that a typical tech publishing cycle is three months for a first draft, with an SD of around 1.5 months, and a page count of 300-600. Not infrequently the book will be a side project and not the author's main gig. E.g. When iPhone OS (as it was) first appeared, in-depth guides like Erica Sadun's were on the shelves almost as soon as it was released. Even if some of those authors had limited distribution beta versions, they still worked their way through all the new features of the OS, wrote and tested sample code, and wrote all the content in a couple of months. I understand Meyers wants to make sure the content represents industry practice, and that takes longer than just cranking out some code and making sure it works. But even so - that's still a surprisingly long time for a tech book.
- unfamiliar 12y agoI think that the lesson here is that it is kind of silly to try and put a time estimate on these things. How do you define time spent "writing"? Does it include time spent researching? Time spent thinking of the structure? If you pause to formulate the next sentence or line of code, should you stop the clock? Maybe we should only measure time taken in each individual key press. It makes much more sense, and is less ambiguous, to talk about "time to complete a project". Like a book, for example.