25 ms·
3rd Edition of Programming: Principles and Practice Using C++ by Stroustrup
- dzogchen 2y agoSharing the C++ Annotations here, which is a continiously updated book on modern C++. http://www.icce.rug.nl/documents/cplusplus/ http://www.icce.rug.nl/documents/cplusplus/
- Thorrez 2y agoI get a 404
- Jtsummers 2y agoFrom https://www.icce.rug.nl/ https://www.icce.rug.nl/ I got https://fbb-git.gitlab.io/cppannotations/ https://fbb-git.gitlab.io/cppannotations/, which does work.
- repelsteeltje 2y agoLink works for me (firefox 125), but only if I use http (port 80), port 443 get me 404 not found as well.
- Jtsummers 2y agoAh, you're right. The issue is the link switching from http to https (even though the supplied link is http) and Chrome making it difficult (by default) to see whether http or https is being used. If I just copy/paste the link it works fine in Chrome and Edge but clicking on the link they both switch it to https. Brilliant. Just tested, works fine with Safari (mobile, but desktop usually has the same behavior).
- repelsteeltje 2y agoThe webserver setup seems sloppy. If the site is http only, have https redirect to port 80 or remove the vhost altogether. Not great for an educational institution doing serious computer science. Chrome's attempt to use a secure connection resulting in 404 while the actual link works fine isn't great. But it's understandable and the TLS-first assumption the're using probably works just fine in the other 99.999% situations. If only they'd taken the time to copy the http config and setup let's encrypt or cert from GEANT Vereniging CA apparently preferred by rug.nl...
- dzogchen 2y agoYour browser is sloppy.
- hnthrowaway0328 2y agoIf I just use C with classes, plus smart pointers and auto, for my emulator project(s), would that be a reasonably good approach? I once heard that the C++ language contains 4 components: the first catalog is "C", the second is for OOP, the third is for productivity and flexibility such as stl and templates, and the last one is for special cases such as volatile, asm, etc. He then recommends to use catalog 1 with care, and avoid scenarios that one has to use catalog 4. Does that make sense?
- Night_Thastus 2y agoI started off writing C++ this way, basically writing it like it was C89. This is fine if you do not plan to share your work with others, but it's not well-written C++. It will bite you later on. It's best to learn the C++ way of doing things. It will save you so much time and headache. Don't use character arrays, use strings. Don't use C arrays, use std::vector or std::array. Don't write your own lists or sets, use std::list/set or std::unordered_list/set. Don't use strcat when std::string operator + exists. Etc. I personally rarely use smart pointers or make_shared/make_unique these days. I just don't need pointers. Most of the time allocation can be done without them, and when I need to pass things around I use references. There are exceptions for C APIs for cross-platform/cross-compiler work, of course. And sometimes library code needs it, ofc. The STL and <algorithm> are your friend. They solve so many problems in a very elegant way. Learning them should be a priority. I'd go easy on the OOP elements unless you know OOP programming very well. Just using classes as containers for data and functions is more than fine for C++ most of the time. Writing your own templates can be a bit of a footgun until you understand them. Feel free to put that off awhile. Don't mess with volatile and asm unless you are 100% sure that what you're doing needs it. Also: Be cautious with use of auto. A bit here and there is fine, but too much and code can become unreadable. C++ is a typed language for a reason.
- hedora 2y agoIn particular, you don't need volatile unless you're writing hardware device drivers. If you're doing that, then you also need to understand the semantics of the memory mappings of the I/O pages you're writing. You also need to know about bus ordering and request coalescing guarantees for PCIe (or AXI, or whatever your embedded system uses). If that paragraph doesn't make any sense, and you think you need volatile then there are basically two possibilities: You're writing a Java program (which uses that keyword for something else), or you need std::atomic (or __sync_* for C) instead.
- deleted 2y ago[deleted]
- mindcrime 2y agoHuh. The ISBN shown at the top of the page (currently "9780136816485") appears to be incorrect. That seems to be the ISBN for "A Tour of C++" from 2022. The ISBN for this book is, according to the Amazon product page[1], "9780138308681". [1]:https://www.amazon.com/Programming-Principles-Practice-Using-C/dp/0138308683 https://www.amazon.com/Programming-Principles-Practice-Using... Edit: emailed Mr. Stroustrup and he just replied to say that the bad ISBN has been corrected.
- sebstefan 2y agoAlready teaching you about the maintainability of tightly coupling different parts of your system before you've even opened the book
- arrowleaf 2y agoIt would have been awesome if that ISBN issue were an actual ISBN re-use issue. I've run into issues coupling my system's design to the assumption that ISBNs uniquely identify a single edition of a single book. The intent of ISBNs are to be unique, but mistakes are made and resellers lose track or straight up abuse some ISBNs.
- lstamour 2y agoNot just that but when ISBNs were first introduced, it was common thought that they were used for cash register price scanning rather than computer-controlled inventory, so a number of early books had ISBNs re-used by publishers and it wasn't caught because they were meant to be the same price. These days you often see two barcodes on books, one is the ISBN and the other is the price.
- layer8 2y agoEven Stroustrup falls prey to copy&paste programming.
- b33j0r 2y agoDarn, I don’t think Bjarne sends $2.56 checks. I think you just earned yourself a coveted check for `sizeof(attaboy)`, and I’m jealous.
- rubymancer 2y agoI expected it to be even more of a tome, but surprisingly it's been cut in half! 2nd edition: Paperback : 1312 pages Item Weight : 4.81 pounds 3rd edition: Paperback : 656 pages Item Weight : 2.71 pounds
- giaour 2y agoFrom the preface, it looks like a bunch of the reference material has been cut from the book in favor of C++ documentation on the internet: "The third edition of Programming: Principles and Practice Using C++ is about half the size of the second edition. Students having to carry the book will appreciate the lighter weight. The reason for the reduced size is simply that more information about C++ and its standard library is available on the Web."
- mirekrusin 2y agoNice to see C++ knowledge counted in pounds! :)
- kevindamm 2y agoTo be fair, someone should print the online reference material to get the real comparison.. it's not like we have fewer details in the standard library -- footnotes about compatibility with which version(s) and the related semantics could fill a book on its own.
- JAlexoid 2y agoAnd it's 1229g for the rest of us.
- kstrauser 2y agoLiterally exactly in half. Did they pick a smaller font or something?
- FrustratedMonky 2y agoI love this book. I wish other languages had something similarly held in high regard to provide some touchstone. Is there something like this for Rust?
- panqueca 2y agohttps://github.com/sger/RustBooks https://github.com/sger/RustBooks
- skilled 2y agoExcellent! I have recently started doing the learncpp.com tutorial and I think this book might have come at the right time.
- pajko 2y agoYou might find the courses useful too: https://github.com/federico-busato/Modern-CPP-Programming https://github.com/federico-busato/Modern-CPP-Programming https://learnmoderncpp.com/ https://learnmoderncpp.com/
- dboreham 2y agoFirst edition was the right thickness imho.
- jdlyga 2y agoI miss my days working with C++. It's moved further down the development stack than where it used to be. We used to handle UI, API parsing, and pretty much everything using C++.
- KptMarchewa 2y agoI just wish to _not_ work with Python.
- REDS1736 2y agoWhy is that? I'm genuinely curious. Also, what languages / environments do you prefer?
- 01HNNWZ0MV43FF 2y agoNot gp but I prefer rust to python and I'm itching to try that "just write your build scripts and stuff in rust too" Sure the builds are slow and Python _kinda_ has static typing, but rust just has a lot of stuff I like and it's practical to install and use natively without learning all the jargon like venvs and eggs and wheels and which package manager and package manager manager (rye?) to use this year I tried Python years ago and never got the motivation to push through that learning curve. I've used c++ a lot but it always required me to "keep my hands inside the ride at all times". Rust feels like it actually wants to be easy to use
- gorjusborg 2y agoThe idea of using Rust for scripting is bizaar. I can understand not wanting to use Python for everything, but I see the problem being the 'use it for everything' not the language choice. Use the tool that excels at the job. There is no language that is good at everything.
- natsucks 2y agoRust is cool now. Python is not cool anymore.
- tiptup300 2y agoI've always wanted to learn C++. I have a great handle on C#, making large applications and architectures as well as legacy refactoring in C#, and I would love to learn C++. I recently started at a company with a bit of a hairy c++ application that I would love to refactor or understand more thoroughly. Is this book a good place. Note that I have read a very basic book on C++ much more learning programming book, but got me introduced to the memory management concepts. As well I've been getting through Effective C++: 55 ways..., but this seems more like a tips and tricks and I don't think I'm getting much out of it.
- _mlbt 2y agoI personally recommend starting with Stroustrup’s other book…A Tour of C++. It really brings you up to speed quickly with what you need to know in the language without a lot of excess fluff. It’s also very up to date compared to other books.
- MontagFTB 2y agoScott Meyers’ “Effective C++” series are digestible reads that cover the corner cases a modern C++ developer might hit, as well as guidelines and best practices to keep from shooting yourself in the foot.
- jcelerier 2y agoThose are starting to be pretty out-of-date. Proper C++23 code looks nowhere like code from Effective Modern C++ (published in 2014) just like you wouldn't expect C# or JS books from 2014 to be up-to-date with 2024 good practices - compare for instance Eloquent Javascript 1st edition (2011) and 4th edition (2024) : `let`, `const`, `use strict;` and a ton of other things taken for granted today weren't there.
- slekker 2y agoSorry if it is a bit off-topic. If you just started learning C++, why did you choose it instead of another language? (Rust, C#, Go, etc) I know a bit of C but feel that the sheer "thickness" of C++ is too daunting and scary to even start.
- npalli 2y agoThe most complex, demanding and cutting edge computational fields - Machine Learning, Artificial Intelligence, Real-time multi-user Gaming, High frequency Trading, Rendering/Animation, High Performance Computing, Compiler infrastructure (LLVM) - are all at the core written in C++ for the most part. There is no other option in the foreseeable future as the investment needed to rewrite (if you can find the people) is in the $100's of billions. So you will need to know C++ if we want to be the cutting edge and need extreme performance. On the other hand, if you don't need these "hard-core" features then any language will do. In fact, most of these have Python or other language interfaces so you don't need to know much C++.
- tialaramex 2y ago> So you will need to know C++ if we want to be the cutting edge and need extreme performance. I would suggest a better phrasing might be that you should learn C++ if you want to cling to existing software in the state it is today, certain that history ended yesterday and the future is just the same forever from here on. You won't get "extreme performance" from C++ because it is buried under the weight of decades of compatibility hacks.
- slekker 2y agoA more extreme version of this would be COBOL right? Even if people stopped writing C++ today the amount of code that's already written will last many lifetimes.
- tialaramex 2y agoSure, I do not advise people to go learn COBOL either. In fact, I never learned COBOL, they were writing COBOL at the first place I "worked" as a teenager† and it was clearly not the future. † in the UK there was a discrepancy between what happens to the sort of teenager who exhibits talent and interest in an area like writing software, who is sent to just watch adults doing that and mostly doesn't do any actual work themselves as "Work Shadowing", versus those whose direction seems more... manual who are expected to actually go do stuff in the same period, supervised by adults of course, but still very much doing the actual work, "Work Experience". This seems very obviously unfair, although of course as the teenager who wasn't expected to actually do much I wasn't complaining at the time...
- dmarchand90 2y agoCan anyone recommend a good book for numerical c++ in 2024?
- AlexeyBrin 2y agoMaybe Discovering Modern C++ 2nd edition. But check the table of content before buying, it may be too beginner level for you.
- tejohnso 2y agoOh, he switched to QT for the GUI chapter. That's a significant change from FLTK. Should be well received as QT is popular in industry. Not sure how the learning curve will be affected.
- layer8 2y agoHe uses a custom wrapper library, so not sure how much (if anything) of QT proper is exposed.
- pjmlp 2y agoFor the better, with Qt there is QtCreator.
- spacechild1 2y agoNot sure what you are trying to say here. Qt, the library, and QtCreator, the IDE, are completely separate products. You can use QtCreator without Qt and vice versa. Now, I'm pretty sure you know that, hence my confusion...
- earthnail 2y agoQtCreator helps with the learning curve as it‘s a very accessible IDE. One of the first IDEs I used in my career.
- spacechild1 2y agoSure, QtCreator is nice and it's actually my IDE of choice. I just wanted to point out that it is independent of Qt, the library.
- germandiago 2y agoHow it compares to CLion?
- Kranar 2y ago
- aero-glide2 2y agoThis is the book i used to learn programming 10 years ago! After that I never really learnt anything new.. been using the same concepts.
- nocoiner 2y agoDid you use it to learn programming as a novice to the field? I have always wanted to learn programming as a hobby, but never really found the right entry point. Would you recommend this?
- semanticc 2y agoI would start with Python instead of C++, if you just want to learn a useful tool as a hobby. The official tutorial is a good starting point: https://docs.python.org/3/tutorial/index.html https://docs.python.org/3/tutorial/index.html
- AlexeyBrin 2y agoFor hobby programming, Python is the best (unless you want to do web development in which case JavaScript is what you want). For Python, a really good book for beginners is Python Crash Course.
- boppo1 2y agoThis is a solid entry point, though you'll get more immediacy out of learn python the hard way. However starting with python (like I did) will 'leave things out' and Principles is great for filling those holes.
- Mikhail_K 2y ago[flagged]
- deleted 2y ago[deleted]
- layer8 2y agoMaybe you should read his books.
- riazrizvi 2y agoIt helps to understand the rationale behind the language choices. Though, sure, if Linus Torvalds ever put substantial effort into writing a concise book on programming in C, I’d choose that over Kernigan & Ritchie’s great starter book.
- zerr 2y agoTC++PL book is full of wisdom in general programming, easily transferable to other languages.
- bregma 2y agoWell, he's articulate and very experienced with software development who invented the original C++ out of necessity. In fact, he sounds like an ideal person to tech good programming practices using the language he helped design.
- Kranar 2y agoOP is making a dig at C++ the language. A lot of people, most likely OP included, consider the language to be a monstrosity, so how can the person who developed such a monstrosity possibly share good advice on programming? That said, I sometimes get the impression that Bjarne recognizes the monstrosity that he created and a large part of his talks and his book is how to make use of the good parts of C++ without making use of the bad parts.
- anonymous_union 2y agoc++ is so bad. when i see threads like this one praising it, i feel bad for all the mental energy these people have put into understanding an unorganized and unelegant garbage dump of ideas. even his coworkers at bell labs tried to convince him c++ was a bad idea. ken thompson wouldn't use it. then he invented go to spite him.
- OnionBlender 2y agoMy problem with newer C++ books is that all of my projects are stuck using C++17.
- nicce 2y agoIf they are purely your projects, then it is just a matter of will :-D
- OnionBlender 2y agoI mean the work projects I work on. Mostly Android NDK stuff that uses C++17.
- zerr 2y agoAre there any university lectures/videos based on this book?
- chuckadams 2y agoKnow what I like about Stroustrup's code? "using namespace std;". The typical convention of sticking std:: in front of std::every std::last std::bloody std::thing drives me std::insane.
- pif 2y agoYou learned to program on Windows, didn't you?
- marcosdumay 2y agolpsiNo, spbI uiOnly lpwAdopted iThe spdwStyle usLater.
- chuckadams 2y agoI learned on C on Unix. The naming conventions in Windows are the same kind of syntactic noise I dislike: long identifiers that are just long without actually being descriptive, with extra crap ladled on top in the form of Hungarian notation (which had its uses in the Excel codebase, but doesn't belong anywhere near C++) BeOS probably had the nicest looking API. Let's hear it for is_computer_on_fire()
- HarHarVeryFunny 2y agoIt depends ... You should NEVER have "using namespace" (for any namespace) in a header file, since that is how you create name clashes, which is what the namespaces are there to avoid. I don't personally like "using namespace std;" even in implementations, since I think it makes code less readable, and the contents of std:: is so large, and growing, that I'd again prefer to just avoid the possibility of name clashes. We write code once, but read it many times, so shorter names (incl. namespaces) seems like a poor efficiency choice.
- culi 2y agoConversely, We write code once, but read it many times, so longer names seems like a poor efficiency choice.
- deeznuttynutz 2y agoOver the past year, I've completed most of the second edition. It truly is an amazing book that has helped me overcome many mental barriers I've faced with programming for years. The main reason for the reduced size of this edition is the removal of 'Part IV: Broadening the View.' This section, which covers additional topics such as text manipulation, numerical computing, and embedded systems, is now available online. The chapters have not been updated from the second edition, as the topics are still relevant and utilize C++11/14.
- ben7799 2y agoHaven't used C++ in 10+ years but I remember studying an earlier version of this book in stupid depth. And this was at the end of 4 years of using 99% C++ in college. It's such a good book. If you really take the time to understand the book C++ it seems kind of sad the world was so afraid of it. But of course after all this I of course met an army of people who had never read a book like this at all and wrote horrifying C++ code.
- uwagar 2y agowhy not P3 instead of PPP3?
- CSMastermind 2y agoA new version is extremely exciting. Even if you're an experienced programmer or have no interest in C++ you should still read this book. It's one of the best examples of technical writing and teaching computer programming that I'm aware of.
- bluedino 2y agoWhy does Bjarne only sometimes use a space after #include? #include<stdint.h> #include<list> #include <map> #include<unordered_map> #include <set> #include<memory> #include <algorithm> https://www.stroustrup.com/PPPheaders.h https://www.stroustrup.com/PPPheaders.h
- aquir 2y agoGreat but I am unable to find an IDE or compiler that supports C++ 20 and every one of them complains about import std; Any recommendations?
- xdavidliu 2y agoI ran into this the last time I tried reading this book. It's supposed to be for beginners; how would a beginner get around this?
- heyoni 2y agoCLion seems to support it through a mixture of clangd and its own parser: https://www.jetbrains.com/help/clion/c-support.html#cpp-standards https://www.jetbrains.com/help/clion/c-support.html#cpp-stan...
- xdavidliu 2y agoI find it really problematic that the "classic first program" in this book includes "import std;" as the very first line, and as far as I know not a single compiler with the possible exception of MSVC supports that out of the box. Writing this on a debian machine, and trying "g++ --std=c++23 -fmodules-ts" does not work, and from https://en.cppreference.com/w/cpp/23 https://en.cppreference.com/w/cpp/23 looks like the "paper" for this is P2465R3, for which clang++ 17 has "partial support". I apt installed clang++17, and it still didn't work, complaining "module 'std' not found" I understand that "import std;" is a very new feature and not "finalized" or whatever, but this book is supposed to be for beginners to C++; I wonder how the average beginner would react to that? (I found the same thing a year or two ago when reading "Tour of C++")
- davidthewatson 2y agoGood point! Me too. My g++ emits exactly the errors and instructions you described. I haven't read the current Stroustrup version under discussion, but I did read the earlier version when C++ was all day, every day for me. I prefer Koenig and Moo's Accelerated C++ twenty years on though I admit there may be better books since which I've not read. IIRC, their hello world was: // a small C++ program #include <iostream> int main() { std::cout << "Hello, world!" << std::endl; } Which copy pastas into my current arch linux, builds in: g++ a.cpp and runs in: ./a.out Hello World! as it has since I first read it twenty years ago, and likely did before that. The rest of the book was a tour de force of making modern C++ emulate the near-pseudocode, sans pointer arithmetic of C, simple-and-clean, buttoned-up style seen in early python, where none of those things existed until pandas brought wrapped C++ libs along with it like numpy and scipy. Professionally, I've not seen clean C++ code in the wild, though I don't work at FAANG and code reviews are unusual in rapid prototypes so I'm not sure how widely Koenig and Moo are mentored outside the greenfield world I've lived in with the possible exception of radiotherapy where you're trying to avoid being the next Therac 25.
- humanrebar 2y agoAt this point, it's not realistic to maintain interesting C++ programs without a build system. That being said, I expect the specific g++ example you provide will end up working with some special casing in the compiler, at least eventually, when someone submits patches to GCC to get it to work. But mostly, it's not realistic to directly wire up calls to g++ anymore outside of research examples. Note that other compiled languages use systems like gobuild, cargo, Maven, etc. instead of fiddling with gccgo, rustc, javac, etc. directly. https://www.kitware.com/import-std-in-cmake-3-30/ https://www.kitware.com/import-std-in-cmake-3-30/