8 ms·
C++ Cheat Sheets
- intricatedetail 5y agoProbably semi related, but when I was looking at C/C++ job offers, why are they paid so little in comparison to Python or JavaScript? It seems like C/C++ is much more complex. I was mainly looking at embedded stuff vs Web. For example senior C++ role was paying £45k pa on average and over £60k for JS.
- ncmncm 5y agoIf it says "C/C++", it means they don't even know what they want, and might even be satisfied with a cave-dwelling C coder. The highest-paid programming jobs are mainly held by C++ programmers, many of them in service of financial gambling. That work shades over into FPGA and HPC programming at the high end. A skilled C++ programmer at these shops can get a half $million, some more.
- flomo 5y agoYeah, job adverts (and resumes) with "C/C++" usually seem like they are reading off MS VisualStudio marketing and imo a clown indicator. I've seen this with jobs which were really C# or Java (or maybe even VB). Top C++ programmers are highly compensated and only unemployed when they want to be.
- pjmlp 5y ago"C/C++ Users Journal" - https://en.wikipedia.org/wiki/C/C%2B%2B_Users_Journal https://en.wikipedia.org/wiki/C/C%2B%2B_Users_Journal You are certainly acquaited with it.
- ncmncm 5y agoIt has been literally decades since I last encountered it. In any case the title has exactly nothing to do with job listings or what may be inferred from them.
- pjmlp 5y agoOk, lets get job listings then, from companies whose staff seat at ISO C++. "Senior C/C++ Software Engineer" @ NVidia https://nvidia.wd5.myworkdayjobs.com/en-US/NVIDIAExternalCareerSite/job/China-Beijing/Senior-C-C---Software-Engineer_JR1953235 https://nvidia.wd5.myworkdayjobs.com/en-US/NVIDIAExternalCar... "Senior Software Engineer" @ Microsoft https://careers.microsoft.com/us/en/job/1152962/Senior-Software-Engineer https://careers.microsoft.com/us/en/job/1152962/Senior-Softw... > Experience using scripting languages such as bash, Python, and PowerShell, or compiled languages such as C/C++, C# and Go are most relevant, but others are acceptable "Software Engineer, Core, Compilers, Runtimes and Toolchains" @ Google https://careers.google.com/jobs/results/72312064984392390-software-engineer-core-compilers-runtimes-and-toolchains/?lipi=urn%3Ali%3Apage%3Ad_flagship3_pulse_read%3BOCG9gjK7R2qwgD2k06UdBQ%3D%3D&page=22 https://careers.google.com/jobs/results/72312064984392390-so... > Experience with software development using C/C++. "Software Developer (C/C++)" @ Apple https://jobs.apple.com/en-us/details/200287299/software-developer-c-c?team=SFTWR https://jobs.apple.com/en-us/details/200287299/software-deve... "Software Developer – C/C++" @ IBM https://careers.ibm.com/job/14295385/software-developer-c-c-littleton-ma/?codes=IBM_CareerWebSite https://careers.ibm.com/job/14295385/software-developer-c-c-... "Principal Software Architect : C/C++/GPU" @ AMD https://jobs.amd.com/job/Markham-Software-Development-Engineer-135954-Onta/837815900/ https://jobs.amd.com/job/Markham-Software-Development-Engine... "Senior Compiler Engineer" @ ARM https://careers.arm.com/job/cambridge/senior-compiler-engineer/33099/17473504816 https://careers.arm.com/job/cambridge/senior-compiler-engine... > Excellent programming skills in C/C++ Better not keep using programming languages tainted by quality standards of all ISO C++ member companies.
- ncmncm 5y agoSo, you are saying that clueless HR people are employed at such very large companies as NVidia, Microsoft, Google, Apple, IBM, AMD, and ARM? I'll bet you can find cigarette smokers working in them, too. And Russian Empire sympathizers. If you ever had a point, you lost it some time ago.
- Kranar 5y agoDifficulty of a job isn't a great metric to evaluate pay/salary, if that were the case then miners or gravediggers would be among the wealthiest people in the world. Salaries often have to do with marginal revenue productivity and from that metric, C++ is not a particularly productive programming language compared to its cost. C++ is a very error prone, complex and risky language and even when used in industry, it's used in such a way that companies significantly restrict its feature set to a mostly sane subset of the language that in many cases looks like a dialect of C with classes. The benefit of using it is your product has the potential to outperform software written in other languages, but this benefit often comes at the cost of software that is more limited in features compared to competitors. For some domains, like HFT, audio and graphics, where performance is the primary feature C++ does pay well, but for most other domains the sheer complexity of the language outweighs any benefit to productivity. So ultimately the reason Python developers get paid more than C++ developers is because products developed in Python are more productive than products developed in C++. The reason for that difference in productivity is that given two developers who are both investing X units of time working a product, the Python developer is far more likely to spend that time adding new features to their product while the C++ developer is likely to spend that time trying to find the cause of some random bug due to undefined behavior, or trying to figure out some arcane and complex language quirk.
- gpderetta 5y agoThis is more a function of the sector. Embedded just does not pay as much as web ATM. FAANG and FAANG-adjacent companies will pay way more than that for a senior C++ developer in London (they will also pay more for a web developer). And of course there is the City. The actual salaries are unfortunately usually not advertised.
- jokoon 5y agoWow, this is really good, there are still things I can learn. C++ really has a lot of good things. It's just a shame it's so slow to compile. I'm curious if anybody is working to make C++ faster to compile. Even if it was a subset of the language, with some features removed, it would be good enough for me.
- jcelerier 5y ago* 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
- techas 5y agoOff topic. Could you recommend an ide to work with c++?
- ibobev 5y agoMicrosoft Visual Studio for Windows and QtCreator for Linux.
- CornCobs 5y agoI find visual studio to be absolutely horrendous for C++. Refactoring doesn't work (even a simple rename symbol!) The errors aren't accurate, autocomplete seems to suggest every symbol from the stdlib before the class defined in the file itself and can't tell when it should suggest classes vs functions/variables. Oh and of course compile errors are absolutely useless but I suppose that's a C++ thing in general. The error panel shows the (last? First?) Error in a chain of errors, which is always something deep in library code. E.g. accidentally tried to copy a non-copyable object using unique_ptr? You can't find the offending callsite, it just points you to xmemory and at best the class being wrongly used.
- ncmncm 5y ago
- BeetleB 5y agoThis should be titled "C++ Algorithms Library Cheat Sheet". It is specifically about the algorithms functions in the standard library.
- bialpio 5y agoThere's a bunch of categories, the first one is indeed standard algorithms. Full list: Standard Algorithms, Standard Randomness, Standard Sequence Views, Standard Containers, Standard Utilities, Language Mechanisms, Libraries, Design Guidelines, Engineering, Terminology. Seems fairly comprehensive to me.
- jll29 5y agoI'm usually not a fan of "cheat sheets" (HTML online documentation, man pages and even real books are quickly at hand) - but this is a useful (and pretty) synopsis of many useful library functions and recent additions to C++, thanks.
- woodruffw 5y agoIn a similar vein: I've had the "initialization in C++17" chart taped above my desk for a 3 years now[1]. [1]: https://timur.audio/initialisation-in-c17-the-matrix https://timur.audio/initialisation-in-c17-the-matrix
- echelon 5y agoThis is fantastic, thanks!
- DesiLurker 5y agoForrest Gump learns C++ Initialization is better : https://i.imgur.com/3wlxtI0.gifv https://i.imgur.com/3wlxtI0.gifv
- itsmenow 5y agowow, this is really fantastic! The whole site seems quite useful in fact.
- adhesive_wombat 5y agoAlso, 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/ https://zealdocs.org/
- ho_schi 5y agoYep. 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.
- nyanpasu64 5y agoI wish Zeal made it easier to inject custom CSS based on the current docset (like Stylus in a browser lets you inject different CSS per domain), or change the zoom level independently for each docset. One pet peeve of mine is fonts I dislike or find too small/large, and browsers currently have better tools for customizing reading.
- erenon 5y agoA similar, online version: https://devdocs.io/ https://devdocs.io/
- iamcreasy 5y agoIs it worth paying the $30 for Dash? Zeal crashes one me every now and then.
- OneOneOneOne 5y agoLooks like cauchy_distribution chart curve annotations are wrong?
- hackingcpp 5y agoYeah, that was a stupid copy & paste bug. I fixed it.
- chrsig 5y agoThis is quite something! I intend to share w/ my coworkers :) If I had one thing I could have added to it: panel for understanding value categories[0] -- I have an incredibly hard time wrapping my head around how they're described. I attribute the difficulty to the cpp standard being excruciatingly complex, the language itself not being designed holistically, and backwards compatibility with itself and C. [0] https://en.cppreference.com/w/cpp/language/value_category https://en.cppreference.com/w/cpp/language/value_category
- MauranKilom 5y agoHonestly, you don't have to understand value categories to this degree. The distinctions are important for writing the standard, but I've never once explained (or was explained) a line of code where diving into the depths of value categories would add anything. In practice it boils down to "if it has a name, you need to std::move it to get move semantics, otherwise you don't". Caveats apply (e.g. returning a named value).
- Jeaye 5y agoRegarding value categories, maybe this is also useful: https://raw.githubusercontent.com/jeaye/value-category-cheatsheet/master/value-category-cheatsheet.pdf https://raw.githubusercontent.com/jeaye/value-category-cheat...
- ge96 5y agohugged
- tryptophan 5y agoCheat sheets are so incredibly useful. All documentation would be so much better if it came with cheatsheets you could quickly scan for things that you might need. I wonder why they are so rare...
- thunkshift1 5y agoVery good resource
- killjoywashere 5y agoThis seems quite useful even for a beginner because it provides a "view of the landscape".
- rramadass 5y agoThis is a great site! Thanks for putting in all the hard work and sharing with the community.
- hackingcpp 5y agoYou're most welcome. I'm glad if people like it and find it useful. If you want to be notified of updates you can follow @hackingcpp on Twitter.
- bobobob420 5y agoThis is why I love c++
- traes 5y ago
- dalleh 5y agoIt does not make sense if you think you have to learn every single function in a language's standard library. And if you think you have to, you are thinking wrong of a language like C++. This sheets are just a summary of what a language is capable of, you don't have to memorize every library function just look up what you need.
- pjmlp 5y agoWhat simple languages, Python? My pocket reference for Python 1.6 already has several pages, let alone an updated version for 3.9.
- tjoff 5y agoEverything is simple once you know it. The struggles I have with python would be hilarious if it wasn't so frustrating. Not saying that C++ isn't much, or has lots of baggage.
- ho_schi 5y agoFeels 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 ;)
- moth-fuzz 5y agoWhy 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.
- gpderetta 5y agoJust flag and move on. There is no point to be dragged in flame wars for every C++ submission.
- ngcc_hk 5y agoOther 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.
- shikhardevgupta 5y agoLearned C++ in school. Dont ever want to go back to it. It's just too complicated.
- dtsdwarak 5y agoThis is very good. Is it possible to get this in a print-friendly format?
- thrwyexecbrain 5y agoThe sizeof(variant) example is wrong. An extra byte is needed to store the discriminator value, which in practice results in 8 extra bytes for these particular types because of alignment. https://godbolt.org/z/vno3v9rPK https://godbolt.org/z/vno3v9rPK The tuple drawing is also somewhat misleading, because the first box (int) should be the same size as the second one (double), due to alignment.
- hackingcpp 5y agoYou are right. That was probably dumbed down too much. I'll fix it.