Live data from Hacker News

3rd Edition of Programming: Principles and Practice Using C++ by Stroustrup

stroustrup.com

71–80 of 231 posts

Re: 3rd Edition of Programming: Principles and Practice Using C++ by Stroustrup

#71

Earlier quoted context omitted.

If 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 car…

I 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…

> Be cautious with use of auto. A bit here and there is fine, but too much and code can become unreadable.

Yes, although one place where "auto" should almost always be used is to declare iterators (not that one should be needing them so much nowadays), and I think harmless for range-based for loops "for (auto i : v)" although as you say there's definitely a convenience/readability trade off.

Re: 3rd Edition of Programming: Principles and Practice Using C++ by Stroustrup

#72

Know 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.

You learned to program on Windows, didn't you?

Re: 3rd Edition of Programming: Principles and Practice Using C++ by Stroustrup

#73
post #45
post #34

Sorry 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.

The 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 i…

> 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.

Re: 3rd Edition of Programming: Principles and Practice Using C++ by Stroustrup

#74
post #34

Sorry 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.

I started because I became interested in graphics and audio programming. Audio plugin development in particular is completely dominated by C++.

Do you have any recommendations for someone interested in audio programming?

Re: 3rd Edition of Programming: Principles and Practice Using C++ by Stroustrup

#75

Earlier quoted context omitted.

Not 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 Pyth…

The 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.

Rust is cool now. Python is not cool anymore.

Re: 3rd Edition of Programming: Principles and Practice Using C++ by Stroustrup

#76

Earlier quoted context omitted.

Not 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 Pyth…

The 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.

cargo -Zscript is in nightly

Re: 3rd Edition of Programming: Principles and Practice Using C++ by Stroustrup

#77
post #72

Know 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.

You learned to program on Windows, didn't you?

lpsiNo, spbI uiOnly lpwAdopted iThe spdwStyle usLater.

Re: 3rd Edition of Programming: Principles and Practice Using C++ by Stroustrup

#78
post #42

Earlier quoted context omitted.

If 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 car…

These days, OO programing is mostly frowned upon. OO added the idea of implementation inheritance to interfaces, and that's mostly a bad idea. Newer languages and modern C++ favor composition instead. You define interfaces that provide some well-defined capability, and then you write things that wrap the interfaces to provide additional functionality. In C++ you can use templates to do this without any runtime overhe…

> You can end up having many copies of the same template logic, which blows up your instruction cache.

linkers have been able to perform identical-code-folding optimizations for a few decades now

Re: 3rd Edition of Programming: Principles and Practice Using C++ by Stroustrup

#79
post #17

I 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++.

I felt some nostalgia for Fortran a while ago. Spent half an hour programming in it, cured. Maybe take a shot at parsing JSON in C++ and see if the nostalgia survives the process.

I recently had to port an existing C++ JSON parser into a new project, and even though it was complete in terms of what we needed it to do right now, adding any kind of additional functionality to it would've been a nightmare.

Re: 3rd Edition of Programming: Principles and Practice Using C++ by Stroustrup

#80

I 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

Literally exactly in half. Did they pick a smaller font or something?
Post reply on HN