Live data from Hacker News

C++ Cheat Sheets

hackingcpp.com

51–60 of 82 posts

Re: C++ Cheat Sheets

#51

Also, if you do not use Dash or an open source implementation like Zeal[1] (which is what I use), you are missing out. The supplied C++ docset comes from cppreference.com and is very, very useful to have to hand. The Python and CMake docsets are also particularly useful to me. [1] https://zealdocs.org/

Yep. For GNOME their are packages available for DevHelp through third parties (e.g. Archlinux->AUR). DevHelp could make good use of a direct installation option for users.

Re: C++ Cheat Sheets

#52
post #43

Quoted post unavailable.

Feels fluid for me :)

C++ overs all kind of high-level features and allow to go low-level when need. I know the core stuff and what I use regularly in addition. Will likely never learn all possibilities of C++. I don't think that is neither intended nor possible. The compiler does know all that stuff and according to my knowledge that is its purpose. Compiler, the best friend of the developers. Nowadays the compilers talking most of the time in clear language ;)

Re: C++ Cheat Sheets

#53
post #43

Quoted post unavailable.

Why do these types of comments come up in every thread about C++? Sometimes people who like C++ just want to talk about C++ on the internet. It doesn't have to be for everybody.

Re: C++ Cheat Sheets

#54

Earlier quoted context omitted.

* Compile with clang, link with mold or at least lld. mold can link gigabyte-sized binaries in, like, one second * Use ninja instead of make * Use PCH * -gsplit-dwarf

This is all solid advice (particularly using a faster linker). IME, the single best way to reduce your C++ compile times is to compile less code : * Remove all unnecessary headers. Template expansion is slow, and preprocessing is even slower. Some of the standard includes (like ` ` and ` `) are notorious for slowing individual translation units to a crawl. `#pragma once` for your own headers also helps with cpp-time…

Yep, all of this is good advice but requires being able to change the code, which is far from a given in c++ where you may have to work with a dozen proprietary SDKs.

I personnally use clang -ftime-trace to see which headers take the most time and then Qt Creator's "find all places where this file is included" feature to try to make the most efficient cleanups

Re: C++ Cheat Sheets

#55
post #43

Quoted post unavailable.

What are you talking about exactly ? I don't see anything in there that wouldn't be great for any language. E.g. knowing complexity bounds, random distributions... Those are things you need to know when you program, before even writing a single line of code.

Surely you agree that the same slide (https://hackingcpp.com/cpp/std/sequence_containers.png) for any JVM or CLR language would be much longer ?

Re: C++ Cheat Sheets

#56
post #49

Earlier quoted context omitted.

> I'm curious if anybody is working to make C++ faster to compile. Yes - C++20 added support for modules to the Core Language (both "header units" and "named modules"; header units are an intermediate step between classic includes and named modules), and support for header units to the Standard Library. Compiler/library support is a work in progress (MSVC's STL, which I work on, is the furthest along - see https://gi…

Still looking forward to a solution for _ITERATOR_DEBUG_LEVEL in release builds with modules, VS DevCommunity ticket does exist. Currently it appears anyone that cares about bounds checking and iterator validation in release builds, has to keep using global module fragments.

I have the opposite problem. I can't use modules because I need _ITERATOR_DEBUG_LEVEL=0 in debug builds.

The standard library modules really need to be built as part of your projects build so that you can compile them however you want.

Re: C++ Cheat Sheets

#57
Other than this kind of cheat sheet, I wonder could there be a common idiom cheat sheet for situation like … for people who does not develop but have to understand and fix a minor bugs.

Sometimes you just in that hole and it is hard between the gap of knowing or trained on the basic c++ and then need to or try to understand a c++ …

Or JavaScript.

Re: C++ Cheat Sheets

#58
post #32

Earlier quoted context omitted.

* Compile with clang, link with mold or at least lld. mold can link gigabyte-sized binaries in, like, one second * Use ninja instead of make * Use PCH * -gsplit-dwarf

Is clang still faster? I thought it had slowed down in the past decade and was now worse than GCC.

For my own projects at least it is, by 10-20%

Re: C++ Cheat Sheets

#59
post #49

Earlier quoted context omitted.

Still looking forward to a solution for _ITERATOR_DEBUG_LEVEL in release builds with modules, VS DevCommunity ticket does exist. Currently it appears anyone that cares about bounds checking and iterator validation in release builds, has to keep using global module fragments.

I have the opposite problem. I can't use modules because I need _ITERATOR_DEBUG_LEVEL=0 in debug builds. The standard library modules really need to be built as part of your projects build so that you can compile them however you want.

Either that, or be like MFC/ATL and provide a couple of pre-compiled versions for common workflows.

Re: C++ Cheat Sheets

#60
post #43

Quoted post unavailable.

I agree, you can do a lot with C++, there's a lot of advanced libraries for different purposes, but it's simply not pleasant experience, especially, if anyone gets fancy with everything that C++ offers and you need to understand it.

Personally I want to focus on what code is doing, it's also important to understand how it's doing something, but typically I don't care that much about performance, I just want language that will produce valid code without too much effort and thousands little details that you need to be aware of and with languages like C++ you need to pay high attention to code you write and debugging can be horror story, once something goes bad.

For me, if I need to go low-level, Go is sufficient. It's readable, performant and it's harder to shot your feet with it.

Post reply on HN