13 ms·
Modern C++ Programming Course
- codebeaker 3y ago[flagged]
- bayindirh 3y agoGenuinely asking: Why many programmers need tools to enforce something upon them? Why not they can't take slow, be mindful about what they write and add a couple of layers as pre-commit hooks? Like a code formatter and maybe a linter? This makes me sad. Programmers have the knowledge base to make some of the most sophisticated things bend to their will, and they tell a programming language is bad, because they can make mistakes with it. You can cut yourself while chopping onions, too, if you're not careful. When I code C++, I generally select the structures/patterns I gonna use, use them, and refactor my code regularly to polish it. Nobody enforces this on me, but this is how I operate. I add a formatter to catch/fix the parts I botched on the formatting department, and regularly pass my code through valgrind to see whether it makes anything funny on the memory department.
- dale_glass 3y ago> Why many programmers need tools to enforce something upon them? Why not they can't take slow, be mindful about what they write and add a couple of layers as pre-commit hooks? Like a code formatter and maybe a linter? Why would I want to? Most of that is boring stuff that's hard to get consistently right and highly amenable to automation. Automation is what the computer is good at, it can have that job. Like, why would I want to spend more mental bandwidth on tracking down whether every new goes with every delete than strictly necessary? Yeah, once in a while something is highly performance sensitive and it pays to design it just right for the use case. But it still tends to be surrounded with hundreds of other things that will do just fine with a smart pointer.
- chris_wot 3y agoSo use RAII and smart pointers. I think that's the point.
- dale_glass 3y agoYes, exactly what I'm saying. Use tooling to do the boring parts of your job.
- chris_wot 3y agoIt’s not tooling, it’s the language.
- Novosell 3y agoLanguages are not tools?
- CyberDildonics 3y agoEvery programmer knows the difference the language and the tools surrounding it. This seems like you're trying to create a pointless semantic argument for no reason.
- bayindirh 3y ago> Automation is what the computer is good at, it can have that job. Pre-commit hook is automation. It formats the code and gives you linting notes the moment you write "git commit". > Like, why would I want to spend more mental bandwidth on tracking down whether every new goes with every delete than strictly necessary? It's not more mental bandwidth for me. Because I write the new, and directly delete at the point I need to, then I never think about it again. If I botch something, valgrind will tell me, even pinpointing it with line number. > ...other things that will do just fine with a smart pointer. If that works for you, use it. I have no objections.
- 3y ago
- belter 3y agoYou need to talk to Bjarne and Herb... "C++ Core Guidelines" - https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
- pjmlp 3y agoBecause not everyone has the same values, not everyone has an engineering background even though they like to call themselves engineers, most programming projects are delivered by external companies that don't care about quality unless it is required by law (aka liabilities).
- deleted 3y ago[deleted]
- johannes1234321 3y agoFirst of all: I am failable. I do make mistakes, even if I concentrate. Secondly I want to verify code others wrote. If a tool does the first pass quickly and automatically, I can quickly ensure some basic level of compliance and can focus on the relevant part. In the end it boils down to: Let the computer do what a computer does and do the things a computer can't. Doesn't say, one shouldn't think, but computers are there and are powerful, so use it. If the checker doesn't find anything: great. If it does: good it's there.
- Barrin92 3y agothe problem is of course that tools aren't particularly smart. When you create heavy handed restrictions in your language, you're not just eliminating mistakes, you're eliminating tons of potential programs that make perfect sense, that's to say you drastically reduce the expressiveness of a language. That's why Rust say, has an escape hatch. Unsafe Rust wouldn't exist if all you could write in it were mistakes. Async Rust is to put it plainly, a pain in the ass. These high level tools are more like chemotherapy. You hope that they kill more of the bad code before they kill you. They're not sophisticated, and it's fairly reasonable to prefer a language that let's you opt-in to stricter safety rather than opt out.
- ravenstine 3y agoSoftware development for at least the last 20 years has been about cranking out code.
- desdenova 3y agoThe fact that we now have languages enforcing safety makes them more desirable than a language that doesn't. If I'm writing a small toy project where I'm the only person messing with the code, I can totally do it in C, or even raw assembly if I feel like it. If anyone else will ever write to the same codebase, or the code is for a client/company, I want every automated static check I can possibly have.
- ModernMech 3y agoLook at it this way: every hour, people are coming across C++ for the first time. You can’t expect them to have the same discipline as seasoned programmers. The thing is that even if you teach them “the way”, there’s always a new batch who is clueless. You’re never going to get rid of them, and even the experts are going to make mistakes and take shortcuts. Better to have sane strict defaults with an escape hatch for experts rather than an open range filled with footguns for any newbie to pick up.
- deleted 3y ago[deleted]
- shadowgovt 3y agoThe biggest problem with C++ isn't that you can't write clean, structured code with it. It's that the language is so vast that the odds of any two developers working on two different projects agreeing on what that means are low. I programmed in C++ for a decade, then for a year or two at a second place, then picked it up again in a third... And all three places had nearly completely different best practice protocols. Pre-processor macros are banned, but deep template abstraction and CRTP abounds. Interface and implementation are separated even when templates demand they be in the same header chain, but here we do so by squirreling away the implementation in a separate file with a non-standard suffix instead of splitting it out but keeping it in the bottom of the same file. In my previous company, we used pointers to indicate the called function could mutate the data... In my new firm, pointers in interfaces are just about banned unless absolutely necessary and we indicate whether data could be mutated via const and documentation. The language is broad enough to let the developer change almost anything, but it is unfortunately broad enough to let competent developers build competing and equivalently (un-)safe styles.
- jeffreygoesto 3y agoEmbedded shop? MISRA? Sounds strangely familiar...
- cjfd 3y agoI agree with you. If those tool actually enforced good quality it would be one thing but what is actually being enforced is mediocrity and enforcing the power play of some individuals who have decided for all others what is good.
- e12e 3y ago> Why many programmers need tools to enforce something upon them? Why not they can't take slow, be mindful about what they write and add a couple of layers as pre-commit hooks? Like a code formatter and maybe a linter? Running a formatter and linter in a pre-commit hook is literally using tools to enforce things?
- bayindirh 3y agoI have noted elsewhere in the thread, but I think I was unable to express myself very clearly. What I really meant is enforced externally on the programmer, in the form of compiler, development environment setup (from elsewhere) or other guidelines, without any free will to tune or disable them. The layers I add are voluntary, just checks and balances I decided to add myself because I think they help me, and not enforced as part of the language or toolchain I'm forced to use. IOW, a self-respecting developer striving to do a good job can continuously sharpen themselves iteratively, tuning their processes and fixing the problems they see as they go along their journey. Perhaps pjmlp understood the gist of my comment, and his answer is a pretty nice hit on the head of the subject. Honestly, I'm coming from a point where programming is more of a passion which pays rather than work/job for me, hence I have an inner drive to do my best and improve continuously, and not everyone shares the same set of values or inner drive about programming, and want to be railroaded into an environment where they can do the absolute minimum to get things done.
- muststopmyths 3y agoThat is all well and good on a small team of senior people , but if your project has more than a handful, with mixed experience levels, you want tools to enforce a minimum standard before even getting to code review
- agentultra 3y agoBecause even the most careful C++ programmer still makes plenty of mistakes. Not the, "oops I cut my finger," kind. Those are usually found by linters and analyzers. More like, "there's a PCI breach and now we're liable for millions of dollars," kind: the semantics of C++ are hard to nail down and ensuring that private data doesn't leak to other threads is almost impossible to get right with only knowing C++ and being careful. You generally need to use higher-level tools for that kind of work: Coq + the Iris framework, for example, in order to prove that your system can freely share memory and not leak secrets so long as X, Y, and Z hold, etc. Or you need to run a ton of tools like Jepsen to find if your system behaves the way you think it does. What baking more of the specification language into the programming language does (ie: better type systems) is enable us to have more of these guarantees earlier in the development process when changes are cheaper and faster to make (at the expense of requiring more expertise to use them).
- marcosdumay 3y ago> Why many programmers need tools to enforce something upon them? You can always count on the threads about C or C++ to have somebody ask questions like this. As a hint, you won't see it asked on any other context. The answer is "all", no exceptions. It's widely known. For decades. In fact, C wasn't even universally used when people discovered this.
- chalsprhebaodu 3y agoMost things learned don’t provide strict tools to enforce that you don’t use old practices where better modern practices exist. Do you question what the purpose is of learning most things? Also, there are tools to look for old practices and suggest modern ones.
- pif 3y agoThere is no modern C++ without the old C++. C++ is the success that it is exactly because it has been able to evolve with no shameful past to cancel.
- chris_wot 3y agoWe don't talk about auto_ptr.
- DoctorDabadedoo 3y ago`union` is all I need to mark my territory and make sure no one touches my property!
- shadowgovt 3y agoThis is still the language that supports setjmp and longjmp and just documents that if you mix them with exceptions the behavior is undefined, right? You can't have a shameful past when you started shameful. ;) This language's roots are in "I wrote some extensions to simplify C, but I don't want to make it incompatible with C so the extensions don't work coherently in all contexts and you only get sound code if you hold your mouth right" and it never actually got better because nothing ever got removed to make the language more sound. Well, it did. When it happened, it created other languages.
- ben_w 3y agoI've had the misfortune of needing to fix the C++ from someone who neither knew nor cared what STL and smart pointers are.
- Jtsummers 3y agoI'm still trying to clean up the mess from someone who knew what STL and smart pointers were, and then made their own broken smart pointers (their version of shared_ptr has a particularly nasty bug).
- pif 3y agoYou mean someone who learnt Visual C++ from Microsoft and was conned to think he knew C++?
- flohofwoe 3y agoVisual Studio will yell at you if your code isn't conforming to the "C++ Core Guidelines" (those guidelines basically define what "Modern C++" even means). Unfortunately it also yells at you when your *C* code violates the C++ Core Guidelines (at least it was a few years ago when I permamently switched that "feature" off).
- tialaramex 3y agoMany of the "Core Guidelines" are semantic requirements which are (provably) Undecidable, so even if tooling was created for them the tooling would necessarily have either false positives or false negatives (those are the only options, unless "both" counts as another option). In practice most of these are unaddressed, Microsoft understandably focused on checks which are never wrong and give actionable advice. "Guideline support" does include libraries with classes that e.g. provide a slice which raises an exception on bounds miss, which is something, and it's certainly notable that the equivalently named C++ standard library feature is a foot gun† whereas the one in the guideline support library is not, so that's a good reason to adopt this. But VS does not in fact ensure you obey all the guidelines, it's very much a "best effort" approach even with that switched on. † WG21 (The "C++ Standards Committee") seems to have concluded that because sometimes the fast way to do something is unsafe, therefore the unsafe way to do something must be faster... as if car executives noticed that 240mph crashes in their flagship sports car were often fatal and concluded that if they re-design their under-performing SUV so that the fuel tank explodes during any collision killing everybody aboard that'd improve its top speed...
- KMag 3y ago> tooling would necessarily have either false positives or false negatives (those are the only options, unless "both" counts as another option). Getting stuck in an infinite loop and never producing an answer is a 4th possibility for attempted solutions at deciding undecidable problems.
- tialaramex 3y agoGood point. Note that we can't necessarily tell it's an infinite loop, the constructive proof for this Undecidability reduces it to our old friend the Halting Problem, so we're in the land of the Busy Beaver.
- lnsru 3y agoAny ideas where to start learning C++ as an embedded developer? I wrote many lines of bare metal C code and want to transit to higher level jobs. I see many expensive or completely free courses, but I am not sure which one is usable in my complicated situation.
- robinhola 3y agoI’d recommend reading Effective C++ books from Scott Meyers and trying to interview for the jobs you’re looking for over taking a course!
- indigo945 3y agoWell, you seem to be precisely the target audience for the course linked in this very post: > This open-access course is directed at those who are already familiar with C > and object-oriented programming towards a proficiency level of C++ > programming.
- tialaramex 3y agoMaybe, in this context it makes lots of sense, if you know C well there are things which "just work how you expect" in C++ and so they need at most a brief refresher. I agree with Kate Gregory that this is a bad way to teach C++ from scratch. That is, if you know only say, Python or Java (or nothing) and want to learn C++, you should not begin by learning C. Kate's approach skips many of the things you can do in C++ but you shouldn't, whereas if we try to start with C you're going to see that a lot, because "they were legal in C" is why they're allowed in C++ even though they're a bad idea and then you have to unlearn things. You're maybe expecting some of that if you've years of C programming experience, but there's no need to introduce an idea on Monday only to tell students on Tuesday that it's a bad idea and they must never do that. The most insidious cases are where something is legal and correct in C but it's wrong in C++ yet it will compile and you maybe have broken software. There are some nasty type punning examples, where the pun was an idiomatic C expression which does exactly what you wanted, but in C++ that's Undefined Behaviour and all bets are off. You'd just never teach those type puns in a pure C++ course, they're never the Right Thing™.
- w4rh4wk5 3y agoAnyone went through this and can compare it to https://www.learncpp.com/ https://www.learncpp.com/?
- synergy20 3y agolearncpp might be more beginner friendly and more verbose
- yamrzou 3y agoFWIW, the creator of this course is a team lead at NVIDIA, and principal software engineer of CUDA cuSPARSE.
- T3RMINATED 3y ago[dead]
- synergy20 3y agolooks good,is there one pdf for all chapters?
- s1291 3y agoI have cloned the repository then combined the chapters using pdftk: pdftk *.pdf cat output Modern_Cpp_Programming.pdf
- synergy20 3y agoon airplane with a phone so can't do that,wish it had a download link for the full PDF,will create when I am back to my pc
- curiousgal 3y agoTermux?
- CalChris 3y agoThis worked on the Mac. I had to install pdftk (brew install pdftk-java) first. The result is nicely formatted for reading on an iPad after importing into Books.
- timdiggerm 3y ago"A Little History of C 3/3" says that C was used in the special effects for Star Wars. I do not know what relevance this has, honestly, but independent of that is the strange choice of photo: an image from the Empire Strikes Back which shows stop-motion models with optically-composited, rotoscoped lasers. Excepting that this may be from the digitally recomposited Special Editions, no C code was used in the making of this shot.
- Zetobal 3y agoWatch Lights & Magic on Disney+ and you will understand why the reference is in there. ILM, Pixar, WETA had huge influx on graphical swe... hell even photoshop was a sideproject of ILM at the time.
- zakary 3y agoCare to enlighten those of us who don’t already know the explanation?
- Zetobal 3y agoILM was and is an absolute software engineering power house and they started with motion controlled cameras for star wars at the time all their in house software was c++. A lot of software which is still used today. Pixars Renderman, Photoshop, Maya... was initially engineered at ILM or Lucasarts which were subsidiaries of Lucasfilm.
- RicoElectrico 3y agoI picked C++ back after a long break and I have to say in reasonably recent iterations (like C++17) it's good enough, although OOTB Unicode is a PAIN. They should have solved it in C++11 and moved on. It's a disgrace.
- jadbox 3y agoDoes Carbon or c++next fix the ootb handling?
- dzogchen 3y agoThis is just an idea at this point. Ask again in 30 years.
- bingo3131 3y agoIt's being actively worked on for C++2x. This video is a fairly recent update on how it's progressing: https://www.youtube.com/watch?v=AoLl_ZZqyOk https://www.youtube.com/watch?v=AoLl_ZZqyOk Note for those who are not used to C++Now talks: they are intented to be a bit more informal with regular interjections from the audience (who at C++Now are also often heavily involved in the development of the C++ standard), so don't think people are being rude by jumping in!
- KingLancelot 3y ago[dead]
- Conscat 3y agoHopefully it's really good in the near future. https://thephd.dev/cuneicode-and-the-future-of-text-in-c https://thephd.dev/cuneicode-and-the-future-of-text-in-c
- gkedzierski 3y ago[flagged]
- jacopoipoi 3y ago[dead]
- dzogchen 3y agoIf you prefer to read a book rather than read slides: http://www.icce.rug.nl/documents/cplusplus/ http://www.icce.rug.nl/documents/cplusplus/
- cdperera 3y agoI get 404d on that page. For others: you can download it (in various formats) through here: https://fbb-git.gitlab.io/cppannotations/ https://fbb-git.gitlab.io/cppannotations/ (You might have to jump through some links) Also, fancy seeing someone else from RuG here :)
- bigcheezr 3y agoLooks comprehensive. I’ll take a look.
- booleandilemma 3y ago[flagged]
- dimitrios1 3y ago> Does it make sense to still invest time to learn C++ when Rust exists? Yes. The overwhelming majority of industry is using C/C++. Rust is still very much niche when compared to the overall market. Additionally, (Someone can correct me if this is wrong) IIRC, mozilla, was initially one of the biggest proponents of rust, but still just uses rust in a supplementary role. C++ still powers the heavy lifting.
- booleandilemma 3y agoThank you!
- gosub100 3y agoIt really depends on your career goals and whether you're doing greenfield or maintenance coding. If you want to be part of the "new generation" of tech, learn Rust. If you want job security, dont care about doing anything glamorous or exciting, and don't mind a long learning journey, go with C++. It will always be around and it's hard enough to learn that you won't have as much competition.
- nec4b 3y agoOnly things written in Rust I know are rewrites of decades old C applications or rewrites of js tooling. What "new generation" of games, browsers, editors, CAD applications, etc. are written in Rust? Is Rust used in aerospace, automotive, healthcare, instrumentation or finance industries? What is glamorous in Rust that hasn't been done in other languages?
- steveklabnik 3y agoIt is difficult to answer this question because there are so many answers, and they're so broad. I will try to give some partial answers. > games Some indie games, a new AAA studio has been working on a game for a while (Embark, their first game is still in C++ but they are building the foundations for the next ones, which takes time), at least one AAA studio known to use it for tooling (Treyarch). The first time I personally gave a talk at a AAA studio about Rust was 2019, though I don't believe that studio is using it for anything I am aware of. > browsers Firefox is about 12% Rust by volume, but is also only 41% C and C++, so it's about a quarter of the relevant systems level code. Chromium has Rust in the tree, but only libraries right now, they don't write new code yet except wrappers. Brave has an adblock component in Rust. > CAD applications Not aware of movement here. > aerospace, Very early days, some small projects, nothing massive yet. > automotive, This one is gearing up massively: a rust compiler was just qualified for the relevant safety standards to be used in automotive, several large manufacturers have had job openings open mentioning Rust. It certainly hasn't taken over the world yet but there's a lot of actual movement in this space. > healthcare, Not aware of specific things here. > instrumentation I don't know what the "instrumentation industry" is. > finance Some players are using some things, but as a very proprietary industry, not a lot of specifics are known. I have given an internal talk at a big hedge fund a few years back, unsure if they're doing anything in production just yet. There are other big successes that aren't covered by these industries; Shopify adding a JIT to Ruby, Cloudflare's heavy use of Rust (which means that a significant chunk of internet traffic passes through Rust code), AWS's heavy use of Rust (the core of products like Lambda and S3 are in Rust these days), Apple using it for network services appparently, Meta keeping their monorepo in a version control system written in Rust, and it being an official language to use on projects there, Google using Rust for significant components in Android, Windows having added Rust code already, with more to come, Rust becoming the next language used in the Linux kernel... the stories are endless at this point.
- Koshkin 3y ago> Table of Context Table of Contents?
- PTOB 3y agoIt is of type <T>.
- javier_e06 3y agoI like to watch Formula 1 and NASCAR races. As interesting as seeing the cars pushing the limit of materials and mechanics is just as interesting seeing them crash. It shows the flip side of design. I wish this sunny-side tutorials had at the end of their books some black pages with the hall of horrors. Weird compilation messages and pointers getting demoted and random segfaults in real scenarios. We all remember the inverted wings in the F1 cars and vehicles literally taking off when the body loose close contact to the ground. Now in NASCAR the roof flaps come off when the car gets slight bump and the front wheels loose traction. C++ Is not a risk averse language.
- Pengtuzi 3y agoI’m quite fond of the C++ frequently Questioned Answers: https://yosefk.com/c++fqa/ https://yosefk.com/c++fqa/
- npalli 3y ago"Note: some parts of the FQA are not up to date with C++11/14/17. You can contribute to the FQA on GitHub." LOL, yeah I think we can stop spending time on this (which was quite funny back in the day).
- deleted 3y ago[deleted]
- philmitchell47 3y agoWhen they say modern, which standard to they mean?
- DoingIsLearning 3y agoLiterally in the title of the linked page: > Modern C++ Programming Course (C++11/14/17/20)
- ska 3y agoIt's described in the course, but canonically this means at least c++11 (and these days, likely 14/17 in practice - there is broad toolchain support)
- mbix77 3y agoThis brings back horrible memories at uni.
- deleted 3y ago[deleted]
- jacopoipoi 3y ago[dead]
- manicennui 3y agoThere are at least a dozen C++ intros that go through every little detail like this and I don't get it. I have a pretty good ability to retain a lot of information presented this way, and I've been programming in various C-like languages for long enough that much of this isn't new to me, but this doesn't seem like a good way to learn the material. I'd much rather work through actual programs and iterate on them. I imagine that a lot of people who would be looking for something this basic aren't even going to retain most of this nor understand why they would need most of these things they are memorizing.
- atoav 3y agoI agree with your grievance: Many c++ tutorials are basically like: these are the internal workings of how the graphite in a pencil is structured, now go draw the rest of the owl. I am not saying that this isn't important, but learning about pointers and references is totally useless unless someone shows you why you would use them, where you would use them etc.
- thom 3y agoI think Kate Gregory makes similar good points about the structure of C++ learning materials here: https://www.youtube.com/watch?v=YnWhqhNdYyk https://www.youtube.com/watch?v=YnWhqhNdYyk
- deleted 3y ago[deleted]
- chubot 3y agoI think C++ and Rust are honestly special beasts. I've heard experienced programmers say that you want to actually pick up a book to learn Rust, and the same is true for C++. Like you can basically hack your way through learning Python or JS. I didn't learn Python from a book, for sure. But with C++ and Rust that's not an optimal strategy. You have to do both -- do practical projects, and actually study it a bit. There's also a huge amount of disagreement about C++, so I think it makes sense to start with a codebase you want to work on, and then ask the people who WROTE that codebase what C++ books and learning materials they like. e.g. Game C++ is kind of different than Google C++, but both are good (they get work done, and multiple people can work together in that style). There is a lot of really bad C++ out there. The gulf between good and bad C++ is bigger than good and bad Python or JS. You want to learn from experienced people who get things done, not language lawyers
- laweijfmvo 3y ago> Heap Memory - new, delete Keywords Should "modern" C++ even use new/delete? I'm a C++ n00b, but I thought these can be avoided entirely now.
- jacopoipoi 3y agoIt's explained later in the course
- underdeserver 3y agoNot entirely - you can't generally use std::make_unique with private constructors.
- nitnelave 3y agoYes, in new code you should be able to replace almost all new and delete with unique_ptr, vector or, more rarely, shared_ptr. Placement new can still be useful, but delete not really. There are some patterns where you use new without a delete for a global singleton that is intentionally never deleted, as well. It's still useful to learn about the concept when dealing with old code.
- kimixa 3y agoI noted that - IMHO one of the big advantages to "modern" c++ is the focus on the lifetime of objects with smart pointers rather than the mechanics of heap allocation and pointers. Pushing that down to chapter 19 as "Advanced Topics" seems like a mistake. Arguably the same with std::array vs object[] - the first should "probably" be the default now for teaching new programmers, so covered first (or at least highlighted when discussing array[]-style variables) I also note a number of the possibly-ambiguous c-style casts in examples, despite already having mentioned the explicit versions (static_cast and the like). Plus there seems to be a fair bit of system & machine dependent stuff mentioned like it's /always/ true - like stack being at a "higher" address space than the heap and code sections, or the stack growing down. It also says that the Data section is "slower" than the stack which... isn't true? If they're spilled out of registers, they're likely functionally identical? Or at least for small microbenchmarks depend on specific implementation details, like how the pointer to the object is calculated and dereferenced.... And object size and cache interactions... And a million other things... And that's just the first few chapters I looked at :P
- varagos 3y agoJust what I needed to brush up my long forgotten from University C skills, but I would prefer practical coding tasks for each part.
- manonthewall 3y ago[dead]
- kwant_kiddo 3y agoOne thing that would have helped me when I started learning C++ was learning the C++ compilation model i.e. translation units. It is surprising how many people look surprised (that also claim they know the language) when you tell them that code in .cpp does not get inlined into other .cpp files no matter what doing compilation. (yes the linker can (and should) do that with LTO doing linking)
- ghosty141 3y agoThis also helps understanding why template code completely wrecks compiletimes and ram usage since the compiler cant share template instantiations. This becomes very relevant if template metaprogramming is used in bigger projects.
- fluoridation 3y agoThat's not why. Template processing happens during processing of the translation unit, so it would be expensive even if you only had a single TU in your build. It's true that a template has to be reprocessed for each instantiation, however, that's not merely from one TU to the next, but even inside each TU! For every distinct value of T for std::vector<T> in a single TU, the compiler has to process and generate std::vector entirely
- account42 3y agoCompilation units are mainly about symbol visibility and as you already realized at the end of your comment don't have anything to do with inlining as far as the C++ standard is concerned. Neither does the inline keyword btw. The linker doesn't inline anything, LTO/LTCG is about running (part of) the compile process at link time. But that's really no concern for the C++ code but an implementation detail of the toolchain - you could just as well not have a separate link step and instead have the compiler process all compilation units in one step.
- kwant_kiddo 3y agoyes, LTO itself does not inline but from a user point of view it does, and that is exactly my point. If you are a beginner and you do not come from C, then you might not think about these things (maybe you do I did not). I get that it is just an implementation detail, but so are many things in C++ and you usually care about these things otherwise you would not be using the language in the first place. Many projects also disable exceptions that is also an 'implementation detail' (or at least something that is definitely not required by the standard I would imagine), but now you are technically not writing C++ anymore. I guess this is also one important thing when learning C++. The community is very fragmented, and there seems to be disconnect between C++ users and committee.
- hecanjog 3y agoCan someone explain how to read the Conversion Rules section in the second chapter? I haven't seen this style of notation before. For example: Implicit type conversion rules, applied in order, before any operation: ⊗: any operation (*, +, /, -, %, etc.) (A) Floating point promotion floating type ⊗ integer type → floating type (B) Implicit integer promotion small integral type := any signed/unsigned integral type smaller than int small integral type ⊗ small integral type → int (C) Size promotion small type ⊗ large type → large type (D) Sign promotion signed type ⊗ unsigned type → unsigned type Edit: oops, I missed the explainer. The ⊗ stands in for any operator in case that was confusing to anyone else who missed it. :-)
- Keyframe 3y agoI've been setting up my little docker image that has both llvm/clang/tidy/clangd and gcc inside with boost with an idea I'd run it and from outside use it to code with live checking and compiling without littering my OS. Now, I feel like I'm doing something that already exists but couldn't really find what everyone use, ought of those that would prefer such a setup. Debugger within is probably a pipe dream, but who knows. Basically I'd prefer to have a docker image with tooling that I can hook into.
- jdeaton 3y agoI find it absurd that a programming language which compells someone to set up a containerized OS just to manage their build toolchain could be considered "modern".
- Keyframe 3y agoI cannot disagree. Gcc is trivial to compile and set with prefix however you want. Llvm behemoth, not so very much though and I'd like to have both for reasons. There's always some gotcha involved, and when you finally set it all up, you forgot what and how you did it and then you dig through shell history file to reconstruct what you did in order to replicate it on other machines or same if you nuke the OS.. blah. Rustup and cargo and pyenv and nvm even spoiled us.
- 4gotunameagain 3y agoIt would truly be absurd to claim that C++ is a modern language. A subset of C++ however, is modern. This does not include the toolchain and standard build practices.
- Keyframe 3y agoYour point stands, but it is/was implied, how I took it at least.
- atum47 3y agoI guess that's why i went into JavaScript instead of java. I use to write HTML back when i was around 10 years old, back then java applets were the only way you could have something interactive and dynamic on your page, so i started to learn it. After a while i learned that you could do a lot of neat stuff with JavaScript. So i stopped using java.
- kman82 3y ago[flagged]
- deleted 3y ago[deleted]
- enahs-sf 3y agoC++ was my weapon of choice in college mostly because writing graphics stuff in C required re-inventing the wheel a lot of the time for basic data structures and the STL was pretty slick. Having spent the better part of the last decade writing go though, I think C++'s syntax is a bit too cluttered.
- fnord77 3y agoHow many interesting SE jobs use C++ anymore? Is anyone using it for new projects?
- okdood64 3y agoWhat's your definition of interesting?
- gpderetta 3y agoCompilers , OSs, browsers, VMs, Databases, scientific experiments, high performance systems, HPC, video games, complex desktop applications, simulations. In fact the question should be: what interesting projects don't use C++? For some very subjective definition of intersecting of course.
- Leherenn 3y agoThis is obviously very subjective, but C++ is used in many interesting fields: robotics, graphics, signal/image processing, physics/game engine, ... I'm currently doing some backend work, and I really miss it. I don't think I've done anything interesting algorithm-wise since I switched. Alas, the pay is usually much better in SaaS land.
- collyw 3y agoWhat is the C++ job market like? I do mostly Python / web app developmnt, but I don't like the churn.
- gbin 3y agoIf you are strong in C++ you can get pretty good jobs in robotics, trading, game engines. But TBH at that point it might be more interesting to learn Rust that is on the rise across the industry.
- TillE 3y agoNobody (except hobbyists and maybe an indie or two) is using Rust for game development, and it's unlikely they ever will. The cost of switching far outweighs any benefits in an industry where memory safety is not critical. C++ is here to stay for a very long time.
- steveklabnik 3y agoTreyarch gave a GDC talk in 2019 that they were using it for tooling, Embark hasn't shipped a game in Rust yet but is larger than an indie. You are absolutely right that it is small right now, but "unlikely they ever will" is a more open question, IMHO. Memory safety is absolutely important in certain kinds of games. At least, as a player, I want games to not be exploited for cheats, and I don't want progress lost when a game crashes due to memory issues. All that said, I would agree that if you want a job in games, learning C++ is a better idea than Rust right now.
- collyw 3y agoNo not strong, just considering making the switch.
- LispSporks22 3y agoHaving “spent some time in the job market lately”, the salaries seem astronomical if you’re C++ and fintech/HFT. I think some funny business is going on with those listings though… Kinda average in game development and sadly pretty low in embedded systems. All way less common than your average Python position, but probably way more interesting.
- the__alchemist 3y agoWith the context of learning Modern C++, and the author's association with nVidia and CUDA, I share this anecdote: Partially if it helps anyone directly, and partially as an opportunity for someone experienced with C++ to poke holes at it. I've had great success using ChatGPTv4 to help me write modern C++ that works with CUDA, using prompts like these. (I have not attempted to get it to write parallelized code given loops/serial code as an input): > Please convert this Rust code to modern C++, compatible with the latest version of the nvcc CUDA compiler: ```rust ``` It will output a compilable/working result, and explain each of the language differences in question. It will make sure to use `std::*` instead of the more rigid C-derived equivalents when able, and take advantage of looping over array pointers etc, vice i++ loops. `auto` var types etc.
- dinkleberg 3y agoI’m curious, if you were going to learn a general purpose lower level language today what would you go with?
- deleted 3y ago[deleted]
- anta40 3y agoperhaps zig... the new cool kid on town or pascal.
- redkoala 3y agoDo we have a curated list of similar programming courses for other programming languages?
- LispSporks22 3y agoI did not enjoy the compile-edit-debug cycle when I was using C++. Have there been any advances in the area off a C++ REPL?
- yread 3y agoIs there a good guide on the toolchain? What do people use today to keep sane? Something like meson, ninja or cmake? I have inherited some project in scons that was generating msvc 14.1 project and I can heartily recommend against that
- lacker 3y agoMeson or CMake. Neither one is really all that great, I would say personally that Meson is better in theory but CMake is more widely supported so I prefer Meson but it's pretty even. Either one is better than just an enormous makefile. Ninja is a different level of the stack, you can use meson+ninja or cmake+ninja. Either way the C++ dependency management situation even makes the Python dependency management situation look good by comparison.
- raccoonDivider 3y ago> Either way the C++ dependency management situation even makes the Python dependency management situation look good by comparison. Is there a better way than “script the compilation of all dependencies and share the result” for any big project that has to support Windows? I’m interested in alternatives.
- papichulo2023 3y agoAt least on Windows I quite like vcpkg for dependencies.
- lacker 3y agoI think nowadays smart pointers should not be considered an "advanced topic" in C++. Smart pointers are usually the best way to handle memory management. It's definitely useful to learn about "new" and "delete", because those are the primitives that memory management is built on top of. But it should be followed up with good advice like, rarely use these in practice. You should almost always be using unique_ptr or shared_ptr instead of new'ing up pointers that you intend to explicitly delete later.
- deleted 3y ago[deleted]
- rightbyte 3y ago> You should almost always be using unique_ptr or shared_ptr I really wish there was a thread unsafe version of shared pointers, without atomics overhead, in the standard. Maybe without weak pointers.
- deleted 3y ago[deleted]
- lacker 3y agoIf there's one thing C++ needs, it's more slightly-different varieties of smart pointers in the standard. ;-) What exactly would you use these for? I find that usually I can get away with unique_ptr for the sort of object that I have many of where pointer performance matters.
- rightbyte 3y agoSome sort of problems where you throw trees around. Almost interpreter like programs, where trees are arbitrarily stored on different places. And where you for some reason don't want a proper GC ...
- alexeiz 3y agoThis course is a bunch of presentation slides. The idea that you can learn anything from slides is rather silly. Learning from slides is almost as bad as learning from random youtube videos.
- withzombies 3y agoYouTube videos are fine, at least they have narration. With slides you're kinda left to infer your own story and lessons.
- papichulo2023 3y agoAll channels with reputation at some point were random (except the ones from universities maybe)
- math_dandy 3y agoSlides can be an extremely good medium for learning. Because brevity is required by the format, slides can require a lot more thoughtful attention to emphasize and carefully explain key points than the long-form text format. I think the course looks really nice!
- f1shy 3y agoIn fact when I read a book I do little cards, like slides, with the most important information condensed. I find a good method.
- charlieyu1 3y agoJust read the first pdf. This is an interesting quote. "Every second spent trying to understand the language is one not spent understanding the problem" Did a lot of work in LaTeX the last few years and they make C++ looks like something made in heaven