18 ms·
21st Century C++
- hoc 2y agoI definitely wouldn't have used "<<" in an "ad" for C++ :) (I must say that I was happy to see/read that article, though)
- lngnmn2 2y ago[dead]
- zygentoma 2y agoWho the hell typeset this?
- rbanffy 2y agoI'm guessing someone pasted from what went into the print edition. Or Bjarne himself. It's just the first code snippet that's messed up. The rest is merely wonky.
- wrs 2y agoCommunications of the ACM has had unbelievably bad typography for code samples for decades (predating the web). No idea how this is allowed to continue.
- rgovostes 2y agoYou don't use 10 spaces of indentation? It's the 21st century.
- layer8 2y agoIt’s a wchar_tab.
- deleted 2y ago[deleted]
- Night_Thastus 2y agoSomething about the formatting of the code blocks used is all messed up for me. Seems to be independent on browser, happens in both Firefox and Chrome.
- Cieric 2y agoFirefox reader view seems to be a slight improvement since it removes the random right alignments in the article.
- npalli 2y agoThis is a Bjarne issue. For personal reasons he uses proportional fonts in his code blocks (in his texts) instead of monospaced and the code snippets always look bad. I guess he is stuck in his ways, just have to work around this ugly look.
- deleted 2y ago[deleted]
- breppp 2y agoLooking at how aesthetically charming the C++ syntax is, I wouldn't expect anything less than Comic Sans code blocks
- edflsafoiewq 2y agoNo, the formatting was definitely botched. It should look much better than it does even in a proportional font.
- jjmarr 2y agoModules sound cool for compile time, but do they prevent duplicative template instantiations? Because that's the real performance killer in my experience.
- Maxatar 2y agoModules don't treat templates any differently than non-modules so no, they don't prevent duplicate template instantiations.
- senkora 2y agoThe best way that I know of to do this is the """ "Manual" export templates """ idea discussed here: http://warp.povusers.org/programming/export_templates.html http://warp.povusers.org/programming/export_templates.html (It's a great post in general. N.B. that it's also quite old and export templates have been removed from the standard for quite some time after compiler writers refused to implement them.) TL;DR: Declare your templates in a header, implement them in a source file, and explicitly instantiate them inside that same source file for every type that you want to be able to use them with. You lose expressiveness but gain compilation speed because the template is guaranteed to be compiled exactly once for each instantiation.
- senkora 2y ago> You lose expressiveness Or more, correctly, the following happens: 1. You gain the ability to use the compilation unit's anonymous namespace instead of a detail namespace, so there is better encapsulation of implementation details. The post author stresses this as the actual benefit of export templates, rather than compile times. 2. You lose the ability to instantiate the template for arbitrary types, so this is probably a no-go for libraries. 3. Your template is guaranteed to be compiled exactly once for each explicit instantiation. (Which was never actually guaranteed for real export templates).
- jcranmer 2y agoYou can declare a template in a header file, and only provide its definition (and hence expansion) in a source file. See for example Firefox doing this for its string implementation here: https://searchfox.org/mozilla-central/source/xpcom/string/nsTSubstring.h#289 https://searchfox.org/mozilla-central/source/xpcom/string/ns... (extern template declarations are at the end of the header file, and the actual template definitions are in https://searchfox.org/mozilla-central/source/xpcom/string/nsTSubstring.cpp https://searchfox.org/mozilla-central/source/xpcom/string/ns...). Which is to say, "extern template" is a thing that exists, that works, and can be used to do what you want to do in many cases. The "export template" feature was removed from the language because only one implementer (EDG) managed to implement them, and in the process discovered that a) this one feature was responsible for all of their schedule misses, b) the feature was far too annoying to actually implement, and c) when actually implemented, it didn't actually solve any of the problems. In short, when they were asked for advice on implementing export, all the engineers unanimously replied: "don't". (See https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1426.pdf https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n14... for more details).
- modernerd 2y agoI haven't read much from Bjarne but this is refreshingly self-aware and paints a hopeful path to standardize around "the good parts" of C++. As a C++ newbie I just don't understand the recommended path I'm supposed to follow, though. It seems to be a mix of "a book of guidelines" and "a package that shows you how you should be using those guidelines via implementation of their principles". After some digging it looks like the guidebook is the "C++ Core Guidelines": https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines And I'm supposed to read that and then: > use parts of the standard library and add a tiny library to make use of the guidelines convenient and efficient (the Guidelines Support Library, GSL). Which seems to be this (at least Microsoft's implementation): https://github.com/microsoft/GSL https://github.com/microsoft/GSL And I'm left wondering, is this just how C++ is? Can't the language provide tooling for me to better adhere to its guidelines, bake in "blessed" features and deprecate what Bjarne calls, "the use of low-level, inefficient, and error-prone features"? I feel like these are tooling-level issues that compilers and linters and updated language versions could do more to solve.
- kstrauser 2y agoI'm curious about that now, too. Is there the equivalent of Python's ruff or Rust's cargo clippy that can call out code that is legal and well-formed but could be better expressed another way?
- bluGill 2y agoClang-tidy can rewrite some old code to better. However there is a lot of working code from the 1990s that cannot be automatically rewritten to a new style. Which is what makes adding tooling hard - somehow you need to figure out what code should follow the new style and what is the old style and updating to modern would be too expensive.
- bb88 2y agoThe problem with 45 years of C++ is that different eras used different features. If you have 3 million lines of C++ code written in the 1990's that still compiles and works today, should you use new 202x C++ features? I still feel the sting of being bit by C++ features from the 1990s that turned out to be footguns. Honestly, I kinda like the idea of "wrapper" languages. Typescript/Kotlin/Carbon.
- coffeeaddict1 2y agoThe C++ Core Guidelines have existed for nearly 10 years now. Despite this, not a single implementation in any of the three major compilers exists that can enforce them. Profiles, which Bjarne et al have had years to work on, will not provide memory safety[0]. The C++ committee, including Bjarne Stroustrup, needs to accept that the language cannot be improved without breaking changes. However, it's already too late. Even if somehow they manage to make changes to the language that enforce memory safety, it will take a decade before the efforts propagate at the compiler level (a case in point is modules being standardised in 2020 but still not ready for use in production in any of the three major compilers). [0] https://www.circle-lang.org/draft-profiles.html https://www.circle-lang.org/draft-profiles.html
- bluGill 2y agoProfiles will not provide perfect memory safety, but they go a long way to making things better. I have 10 million lines of C++. A breaking change (doesn't matter if you call it new C++ or Rust) would cost over a billion dollars - that is not happening. Which is to say I cannot use your perfect solution, I have to deal with what I have today and if profiles can make my code better without costing a full rewrite then I want them.
- tialaramex 2y agoChanges which re-define the language to have less UB will help you if you want safety/ correctness and are willing to do some work to bring that code to the newer language. An example would be the initialization rules in (draft) C++ 26. Historically C++ was OK with you just forgetting to initialize a primitive before using it, that's Undefined Behaviour in the language so... if that happens too bad all bets are off. In C++ 26 that will be Erroneous Behaviour and there's some value in the variable, it's not always guaranteed to be valid (which can be a problem for say, booleans or pointers) but just looking at the value is no longer UB and if you forgot to initialize say an int, or a char, that's fine since any possible bit sequence is valid, what you did was an error, but it's not necessarily fatal. If you're not willing to do any work then you're just stuck, nobody can help you, magic "profiles" don't help either. But, if you're willing to do work, why stop at profiles? Now we're talking about a price and I don't believe that somehow the minimum assignable budget is > $1Bn
- deleted 2y ago[deleted]
- James_K 2y ago[flagged]
- SirHumphrey 2y agoEven Cobol code hasn't been ported in it's entirety, and the whole codebase at the peak was probably orders of magnitude smaller than C++. It's also far easier to port Cobol - with it being used mostly for data processing and business logic - than C++ that was used for all manners of strange, esoteric and complicated pieces of software requiring thousand to millions of man-hours to port (for example most of Gecko and Blink). C++ will be here forever, at least in some manner. edit: spelling
- James_K 2y agoWe can all at least appreciate that COBOL is something you try to get rid of where possible. If we took the same attitude to C++ as we do COBOL, then I think the issue would be much less severe.
- einpoklum 2y ago> Between Rust and Zig, the problems of C++ have been solved much more elegantly Those languages occupy different points in the design space than C++. And thus, in the general sense, neither of them, nor their combination, is "C++ with the problems solved". I know very little Rust and even less Zig. But I do know that there are various complaints about Rust, which are different than the kinds of complaints you get about C++ - not because Rust is bad, just because it's different in significant ways. > It is so objectively horrible in every capacity Oh, come now. You do protest too much... yes, it has a lot of warts. And it keeps them, since almost nothing is ever removed from the language. And still, it is not difficult to write very nice, readable, efficient, and safe C++ code.
- James_K 2y ago> it is not difficult to write very nice, readable, efficient, and safe C++ code That's a fine case of Stockholm Syndrome you've got there. In reality, it is hard. The language fights you every step of the way. That's because the point in the design space C++ occupies is a uniquely stupid one. It wants to have it's cake and eat it too. The pipe-dream behind C++ is that you can write code in an expressive manner and magically have it also be performant. If you want fast code, you have to be explicit about many things. C++ ties itself in knots trying to be implicitly explicit about those things, and the result is just plain harder to reason about. If you want code that's safe and fast, you go with Rust. If you want code that's easy and fast, you go with Zig. If you want code that's easy and safe you go with some GCed lang. Then if you want code that's easy, safe, and fast, you pick C++ and get code which might be fast. You cannot have all three things. Many other langues find an appropriate balance of these three traits to be worthwhile, but C++ does not. It's been 40 years since the birth of C++ and they are only just now trying to figure out how to make it compile well.
- crims0n 2y agoFor someone who wants to get into systems programming professionally, is C++ going to be a hard requirement or can one mostly get away with C/Rust?
- IshKebab 2y agoDepends exactly what you want to do. C is not very popular at all in professional settings - C++ is far more popular. I would say if you know Rust then C++ isn't very hard though. You'll write better C++ code too because you'll naturally keep the good habits that the Rust compiler enforces and the C++ compiler doesn't.
- pjmlp 2y agoThe only places where C++ failed to take C's crown has been on UNIX clones (naturally, due to the symbiotic relationship), and embedded where even modern C couldn't replace C89 + compiler extensions from the chip vendor, many shops are stuck in the past, even though most toolchains are already up to C++20 and C17 nowadays. Rust is still too new for many folks to adopt, it depends on how much you would be willing to help grow the ecosystem, versus doing the actual application. It will eventually get there, but also have the same issues as C++, regarding taking over C in UNIX/POSIX and embedded, and C++ has the advantage of having been a kind of Typescript for C, in terms of adoption effort, being a UNIX language from AT&T, designed to fit into C ecosystem.
- tialaramex 2y agoHere's how Bjarne describes that first C++ program: "a simple program that writes every unique line from input to output" Bjarne does thank more than half a dozen people, including other WG21 members, for reviewing this paper, maybe none of them read this program? More likely, like Bjarne they didn't notice that this program has Undefined Behaviour for some inputs and that in the real world it doesn't quite do what's advertised.
- Maxatar 2y agoThe collect_lines example won't even compile, it's not valid C++, but there's undefined behavior in one of the examples? I'm very surprised and would like to know what it is, that would be truly shocking.
- tialaramex 2y agoReally? If you've worked with C++ it shouldn't be shocking. The first example uses the int type. This is a signed integer type and in practice today it will usually be the 32-bit signed integer Rust calls i32 because that's cheap on almost any hardware you'd actually use for general purpose software. In C++ this type has Undefined Behaviour if allowed to overflow. For the 32-bit signed integer that will happen once we see 2^31 identical lines. In practice the observed behaviour will probably be that it treats 2^32 identical lines as equivalent to zero prior occurrences and I've verified that behaviour in a toy system.
- 2y ago
- mempko 2y agoBjarne Stroustrup (the creator of C++) is the best language designer. Many language designers will create a language, work on it for a couple years, and then go and make another language. Stroustrup on the other hand has been methodically working on C++ and each year the language becomes better.
- biohcacker84 2y agoAfter decades of C++ development, I prefer C, modern Fortran and Rust.
- mskcc 2y agoyour 200+ git repo's attest to that !
- asplake 2y agohttps://news.ycombinator.com/item?id=42952720 https://news.ycombinator.com/item?id=42952720
- imron 2y agoI want to love C++. Over my career I’ve written hundreds of thousands of lines of it. But keeping up with it is time consuming and more and more I find myself reaching for other languages.
- xyproto 2y agoI went from being curious about C++, to hating C++, to wanting to love it, to being fine with it, to using it for work for 5+ years, to abandoning it and finally to want to use it for game development, maybe. It's the circle of life.
- DrBazza 2y agoThe masochist in me keeps coming back to c++. My analogy of it to other languages is that it’s like painting a house with a fine brush versus painting the Mona Lisa with a roller. Right tool for the job I suppose.
- 01100011 2y agoIt's my job and career(well, C and C++) but I often try to avoid C++. Whenever I use it(usually writing tests) I go through this cycle of re-learning some cool tricks, trying to apply them, realizing they won't do what I want or the syntax to do it is awkward and more work than the dumb way, and I end up hating C++ and feeling burned yet again.
- xyproto 2y agoYeah, it's a struggle. Keeping to a good subset often works out, though. I recognize the feelings. Best of luck. :)
- codr7 2y agoI've been writing C++ since 1996-ish. Less and less, for sure. Nothing the past few years. They killed it.
- mr_00ff00 2y ago
- mskcc 2y agoExcellent article. Thanks for sharing.
- deleted 2y ago[deleted]
- Kenji 2y ago[dead]
- wiseowise 2y agoI always hear about “import std” but still don’t see out of the support for it. Is it still experimental?
- vr46 2y agoLast weekend, I took an old cross-platform app written by somebody else between 1994-2006 in C++ and faffed around with it until it compiled and ran on my modern Mac running 14.x. I upped the CMAKE_CXX_STANDARD to 20, used Clang, and all was good. Actually, the biggest challenge was the shoddy code in the first place, which had nothing to do with its age. After I had it running, Sonar gave me 7,763 issues to fix. The moral of the story? Backwards compatibility means never leaving your baggage behind.
- mindcrime 2y agoI was an extreme C++ bigot back in the late 90's, early 2000's. My license plate back then was CPPHACKR[1]. But industry trends and other things took my career in the direction of favoring Java, and I've spent most of the last 20+ years thinking of myself as mainly a "Java guy". But I keep buying new C++ books and I always install the C++ tooling on any new box I build. I tell myself that "one day" I'm going to invest the time to bone up on all the new goodies in C++ since I last touched it, and have another go. When the heck that day will actually arrive, FSM only knows. The will is sort-of there, but there are just SO many other things competing for my time and attention. :-( [1]: funny side story about that. For anybody too young to remember just how hot the job market was back then... one day I was sitting stopped at a traffic light in Durham (NC). I'm just minding my own business, waiting for the light to change, when I catch a glimpse out of my side mirror, of somebody on foot, running towards my car. The guy gets right up to my car, and I think I had my window down already anyway. Anyway, the guy gets up to me, panting and out of breath from the run and he's like "Hey, I noticed your license plate and was wondering if you were looking for a new job." About then the light turned green in my direction, and I'm sitting there for a second in just stunned disbelief. This guy got out of his car, ran a few car lengths, to approach a stranger in traffic, to try to recruit him. I wasn't going to sit there and have a conversation with horns honking all around me, so I just yelled "sorry man" and drove off. One of the weirder experiences of my life.
- ninkendo 2y agoFunny, sounds like the Simpsons gag from the same time period: “what’s wrong with this country? Can’t a man walk down the street without being offered a job?” https://youtube.com/watch?v=yDbvVFffWV4 https://youtube.com/watch?v=yDbvVFffWV4
- mindcrime 2y agoInteresting. I was SO into the Simpsons at one time, but somehow I'd never seen that episode (as best as I can remember anyway). Now I feel the urge to go back and rewatch every episode of the Simpsons from the beginning. It would be fun, but man, what a time sink. I started the same thing with South Park a while back and stalled out somewhere around Season 5. I'd like to get back to it, but time... time is always against us.
- atombender 2y agoPrevious from 3 days ago: https://news.ycombinator.com/item?id=42952720 https://news.ycombinator.com/item?id=42952720 (103 points, 85 comments)
- dang 2y agoThanks! I've merged that thread hither since this one is currently on the front page. (How is that possible, someone may ask? It's the SCP! - see https://news.ycombinator.com/item?id=26998308 https://news.ycombinator.com/item?id=26998308)
- DonHopkins 2y agoGeneralizing Overloading for C++2000 Bjarne Stroustrup, AT&T Labs, Florham Park, NJ, USA Abstract This paper outlines the proposal for generalizing the overloading rules for Standard C++ that is expected to become part of the next revision of the standard. The focus is on general ideas rather than technical details (which can be found in AT&T Labs Technical Report no. 42, April 1, 1998). https://www.stroustrup.com/whitespace98.pdf https://www.stroustrup.com/whitespace98.pdf
- nialv7 2y agoHow does enforcing profiles per-translation unit make any sense? Some of these guarantees can only be enforced if assumptions are made about data/references coming from other translation units.
- Maxatar 2y agoThis is the one major stumbling block for profiles right now that people are trying to fix. C++ code involves numerous templates, and the definition of those templates is almost always in a header file that gets included into a translation unit. If a safety profile is enabled in one translation unit that includes a template, but is omitted from another translation unit that includes that same template... well what exactly gets compiled? The rule in C++ is that it's okay to have multiple definitions of a declaration if each definition is identical. But if safety profiles exist, this can result in two identical definitions having different semantics. There is currently no resolution to this issue.
- juliangmp 2y agoI guess modules are supposed to be the magic solution for that, Bjarne has shown them in this article, even using import std. Its a bit optimistic cause modules are still not really a viable option in my eyes, because you need proper support from the build systems, and notably cmake only has limited support for them right now.
- humanrebar 2y agoModules alone do not guarantee one definition per entity per linked program. On the contrary, build systems are needing to add design complexity to support, for instance, multiple built module interfaces for the std module because different translation units are consuming the std module with different settings -- different standards versions for instance.
- jpc0 2y agoI've been playing with building out an OpenGL app using C++23 on bleeding edge CMake and Clang and it really is a breath of fresh air... I do run into bugs in both but it is really nice. Most of the bugs are related to import std though which is expected... Oh and clangd(LSP) still having very spotty support for modules. The tooling is way better than it was 6 months ago though asin I can actually compile code in a non Visual Studio project using import std. I will be extremely happy the day I no longer need to see a preprocessor directive outside of library code.
- pro14 2y agois the job market for C++ developers still good?
- imron 2y agoDepends. For certain fields the pay is great and there’s a dearth of candidates. For other fields there is also a dearth of candidates but the pay falls short and you’ll be leaving tens of thousands of dollars on the table compared to what you could get with other languages.
- justanotheratom 2y agoC++ should be known for the amount of collective brain cycles wasted on arguing what subset of C++ is the right one to use.
- mempko 2y agoProfessionals know what tool to use for a job. Does it take time to become good? Of course, like anything.
- justanotheratom 2y agoNot a question of difficulty or skill. I am saying professionals can't agree what subset to use!
- mempko 2y agoThey don't have to. The subset depends on the job! That's the beauty and power of C++. That's why we have projects written in it in all domains. From websites to spaceships and Mars rovers.
- justanotheratom 2y agoyes, and you will tell me exactly what subset and coding convention "makes sense" for this domain, and you will give your reasoning too. And I will give my arguments, and on and on it goes. teams have broken up over this. A well-designed language is one in which there are very few different ways of doing the same thing. And C++ is definitely not that.
- mempko 2y agoWhy would a well designed language have only one or few ways to do the same thing? Seems rather arbitrary. I like when I have many ways to do the same thing. Imagine if you told a writer or poet that English is bad because there is more than one way to say the same thing... Programming languages are for people more than machines. Machines are happy with microcode.
- mempko 2y agoThat's why C++ is still around today, it was built on some solid principles. Bjarne is such a good language designer because he never abandoned it. Lesser designers make a language and start another in 5 or 10 years. Bjarne saw the value in what he created and had a sense of responsibility to those using it to keep making it better and take their projects seriously. Whenever I have an idea and I start a project, I start with C++ because I know if the idea works out, the project can grow and work 10 years later.
- 999900000999 2y agoC++ and C still force a usage of header files. For whatever reason this is probably the biggest reason I've struggled with it( aside from tooling... Makes me miss npm).
- otteromkram 2y agoI dislike the style of Code used to write this. I understand that, given who wrote the article, this is blasphemy. Opening braces should be inline with the expression or definition. Comments can be above what they're referred to. Combined, this makes any code snippet look like crap on mobile and almost impossible to follow as a result.
- zie1ony 2y agoSeeing badly formatted code snippets without color highlighting in article called "21st Century C++" somehow resonates with my opinion on how hard to write and to ready C++ still is after working with other laguages.
- AtlasBarfed 2y agoThis honestly looks like C++ being feature-juryrigged to a degree that it doesn't even look like what C++ is: a c-derived low level language. Everything is unobvious magic. Sure, you stick to a very restricted set of API usages and patterns, and all the magic allocation/deallocation happens out of sight. But does that make it easier to debug? Better to code it? This simply looks like C++ trying not to look like C++: like a completely different language, but one that was not built from the ground up to be that language, rather a bunch of shell games to make it look like another language as an illusion.
- DidYaWipe 2y agoYeah, I didn't have a problem keeping my shit straight in C++ in the '90s. The kitchen-sink approach since then hasn't been worth keeping up with. The fact that we're still dealing with header files means that the language stewards' priorities are not in line with practical concerns.
- ninetyninenine 2y ago21st century C++? AKA Rust?
- jandrewrogers 2y agoUnfortunately, Rust is significantly less expressive than C++ and therefore is unlikely to replace it for high-performance systems code. As much as I don’t like C++, it is very powerful as a tool. The ability to express difficult low-level systems constructs and optimizations concisely and safely in the language are its killer feature. Once you know how to use it, other languages feel hobbled.
- AlotOfReading 2y agoC++ doesn't allow you to express low level systems constructs concisely and safely though. You usually get neither. Look at the first example in the article, where the increment can overflow and cause UB despite that overflow having completely defined semantics at the hardware level. Fixing it requires either a custom addition function or C++26, another include, and add_sat(). I wouldn't consider either concise in a program that doesn't include all of std.
- jandrewrogers 2y agoThis assumes you are writing C++ in the most naive way possible. I’m sure some people do that but nothing requires it. The capabilities of a language are not defined by its worst programmers. Modern C++ allows you to swap out most features and behaviors of the language with your own implementations that make different guarantees. C++ is commonly used in high-assurance environments with extremely high performance requirements, and it remains the most effective language for these purposes because you can completely replace most of the language with something that makes the safety guarantees you require. This is rather important. For example, userspace DMA is idiomatic in e.g. high-performance databases kernels; handling this is much safer in C++ than Rust. In C++, you can trivially write elegant primitives that completely hide the unusual safety model. In Rust, you have to write a lot of ugly unsafe code to make this work at all because userspace DMA isn’t compatible with a borrow checker. There can always be multiple mutable references to memory but it is not knowable at compile-time, safety of an operation can only be arbitrated at runtime. Of course, it is still incumbent on the developer to use the language competently in all cases.
- AnonC 2y agoTangential question: is there a Rust equivalent for the book “The Design and Evolution of C++”?
- steveklabnik 2y agoThere is not. I have often thought about writing something vaguely similar. We’ll see if I ever do. It wouldn’t be the same because I don’t hold the same position Bjarne did in the early days, but I am very interested in Rust history, and want to preserve it. It wouldn’t be from my perspective rather than from the creator’s perspective. I did give a talk one time on Rust’s history. It was originally at FOSDEM, but there was an issue with the recording. The ACM graciously asked me to do it again to get it down on video https://dl.acm.org/doi/10.1145/2959689.2960081 https://dl.acm.org/doi/10.1145/2959689.2960081
- munificent 2y agoI would 100% buy a hardback gold embossed version of this book.
- steveklabnik 2y agoWell if I could make it half as good looking as Crafting Interpreters, maybe I’d manage to make it happen, hahah. I’m mostly focused on jj with my writing right now, but we’ll see…
- AnonC 2y agoThank you. It would be interesting to read the history, including the design decisions, the influences (and distractions), the trade offs, etc. When I read “The Design and Evolution of C++”, it gave me a better understanding of the language.
- DidYaWipe 2y agoJust reading the first 1/5 of this made me bored. I started my career with C++, being heavy into it for 10 years. But I've been doing Swift for the last 10 at least. I had a job interview last week for a job that was heavy C++, with major reliance on templates and post-C++ 11... and it didn't go well. You know what? I don't give a shit.
- bboygravity 2y agoIt's crazy that with that amount of experience you wouldn't get the job, just because you lack some modern C++ info in your brain's memory. Stuff you could search for or ask an LLM in 5 seconds (or even look up in a freaking physical book). You'd probably be fully up to date within a few weeks. Says a lot about the people hiring imo. Good luck to them finding someone who can recite C++ spec from memory.
- jpc0 2y agoIf you last worked on Pre templates C++ and now need to work on a template heavy codebase you are effectively writing in a different language. I don't think it will be a few weeks of catching up.
- DidYaWipe 2y agoWow, that must be a very long time ago. Templates were around when I started (if I remember correctly), or soon after. Which reminds me of something I hate more than header files: macros.
- DidYaWipe 2y agoHa, thanks, and obviously true. But I can understand companies wanting people who can just march into their codebase and "hit the ground running," I guess. I don't need the stress anyway. The dough would've been nice, though...
- DidYaWipe 2y agoLet us know when C++ gets rid of the mess that is header files. Until then... YAWN.
- boris 2y ago> [M]any developers use C++ as if it was still the previous millennium. [...] C++ now offers modules that deliver proper modularity. C++ may offer modules (in fact, it's been offering them since 2020), however, when it comes to their implementation in mainstream C++ compilers, only now things are becoming sort of usable with modules still being a challenge in more complex projects due to compiler bugs in the corner cases. I think we need to be honest and upfront about this. I've talked to quite a few people who have tried to use modules but were unpleasantly surprised by how rough the experience was.
- TinkersW 2y agoYa that is rather disingenuous, modules aren't ready, and likely won't be for another 5 years. Also they are difficult to switch to, so I would expect very few established projects to bother.
- ephaeton 2y agoloving he goes 'int main() { ... }' and never returns an int from it. Even better: without extra error / warning flags the compiler will just eat this and generate some code from it, returning ... yeah. Your guess is probably better than mine. If the uber-bean counter, herald of the language of bean counters demonstrate unwillingness to count beans, maybe the beans are better counted in another way.
- toth 2y agoWell, actually... the "main" function is handled specially in the standard. It is the only one where the return type is not void and you don't need to explicitly return from it - if you do it, it is treated as if you returned 0. (You will most definitely get a compiler error if you try this with any other function.) You might say this is very silly, and you'd be right. But as quirks of C++ go it is one of the most benign ones. As usual it is there for backwards compatibility. And, for what it's worth, the uber-bean counter didn't miss a bean here...
- SunlitCat 2y agoTo me, it's kinda funny that he starts with > using namespace std something you get told not to do easily! :D