5 ms·
> As in, a person who has used and learned a dozen plus languages but only tacitly used C++ suddenly will be a complete invalid when trying to write in C++? I'
by rafaelmn 2y ago
> As in, a person who has used and learned a dozen plus languages but only tacitly used C++ suddenly will be a complete invalid when trying to write in C++?
I've switched at least 5 languages professionally and used probably 5 more for extended periods of time and wrote a decent chunk of C++ "back in the day". I'd say C++ is the least suitable for "learn on the job" approach out of any language I can think of (I'm lumping C in there) - soo many footguns all over the place and very little to guide you to the right path.
They are at fault for even starting the conversation without making it obvious is a hard requirement.
- bmitc 2y agoI generally agree with you, but I think it depends on the team. If the team is just "using" C++ but aren't good software developers, then yea, I totally agree that having a non-C++ expert join the team is going to be a rough ride for everyone. But if the team's software architecture and coding practices are solid, which probably means they use a subset of C++'s vast feature set in a very clear way, then one probably could jump in just fine. In a way, them only accepting in C++ experts probably means they're either doing something actually very complex with regards to C++ itself or their code quality is a shitstorm. > They are at fault for even starting the conversation without making it an obvious deal breaker. That is definitely my feeling. My resume is quite clear about my experience and tools.
- atomicnumber3 2y ago"But if the team's software architecture and coding practices are solid, which probably means they use a subset of C++'s vast feature set in a very clear way" So... C? =P Sorry. But my point is I think there's really very very few C++ places that could say their code is described by your statement. Not helped by the fact that I think there's really very very few C++ places at this point in the first place.
- actionfromafar 2y agoThere still are places slowly enhancing their C codebases with C++.
- lumost 2y agoThere are a small number of high-end software firms doing this. "slow-enhancement" generally translates to "maintenance". The exception to this are a few prominent mega-caps.
- josefx 2y ago> So... C? =P Without the string handling API, the always unsafe casts or the global states hidden in its standard library, the complete lack of automatic memory management, ... . Most of the bugs I run into in badly written C++ code turn up in places where someone had the bright idea to go C without good reason.
- Aeolun 2y agoI think by the time you’ve learned 12 different languages you’ll realize when something is hard enough that you need to take a step back and read some stuff first before diving in.
- vinibrito 2y agoNice that you mentioned it. Just a few weeks ago I didn't even know abstract syntax trees, AST's, existed, and I had that exact experience in order to build some stuff that works with them.
- jeremyjh 2y agoThe problem with C++ is you just don't know what you don't know. But you know there is a lot of it. A good framework certainly helps but it doesn't solve this basic problem.
- Jensson 2y ago> In a way, them only accepting in C++ experts probably means they're either doing something actually very complex with regards to C++ itself or their code quality is a shitstorm. If you aren't doing something complex then you aren't needing C++ today, just use Rust then.
- Terr_ 2y ago> I'd say C++ is the least suitable for "learn on the job" approach out of any language I can think of Anecdote: I've got a couple languages and decades under my belt, and a very simple C/C++ Arduino project is making me doubt my sanity. Ex: Serial.printf("%s", String("Hello world...")); // Emits 4 nonsense bytes... But shorter literals work fine. ________________________ EDIT: To save readers some time--I didn't intend to nerd-snipe [0] y'all, honest!--the answer has been found, and it is probably: Serial.printf("%s", String("Hello world...").c_str() ); The shorter payloads like "Hello World" happen to give the desired results only as an accident of optimization code. [0] https://xkcd.com/356/ https://xkcd.com/356/
- CoastalCoder 2y agoIf you're really asking about that code snippet... I don't know that library, but have you tried this? Serial.printf("%s", "Hello longer world");
- Terr_ 2y agoOh, that works, but the Arduino String library had some features I wanted. Its docs have an explicit example of putting a literal (an even longer one) into the constructor, so... Mysteries! My default expectation is that it is a footgun that I do not understand. The alternative is that I've stumbled across a very rare bug in some popular libraries, or else my hardware is cursed in a very specific and reproducible way.
- r2_pilot 2y agoMaybe what's happening is the `printf` function is interpreting the memory address of the `String` object as if it were a pointer to a char array. This leads to it printing seemingly random bytes (which are actually parts of the `String` object's internal data structure) instead of the string content you expect.
- CoastalCoder 2y agoThis sounds kinda plausible. IIRC, some string implementations have separate implementations for very short strings vs. longer ones. Similar thing for vectors. I also see some size-related logic in the (current?) String implementation [0] [1]. String is a class with no virtual methods, and its first data member is a pointer to the underlying buffer [2]. So if Stream.printf unintentionally type-puns String to char*, it might work out okay? [0] https://github.com/arduino/ArduinoCore-API/blob/master/api/String.cpp https://github.com/arduino/ArduinoCore-API/blob/master/api/S... [1] https://github.com/arduino/ArduinoCore-API/blob/master/api/String.h https://github.com/arduino/ArduinoCore-API/blob/master/api/S... [2] https://github.com/arduino/ArduinoCore-API/blob/cb3ab4c90d71d40c9c3f5a37bac0c274e8c89cbb/api/String.h#L220 https://github.com/arduino/ArduinoCore-API/blob/cb3ab4c90d71...
- icedchai 2y agoSame. I wrote C++ "professionally" for ~5ish years out of my 25 year career and would only consider myself a novice in the language.
- boznz 2y agoBeen doing C for forty years and feel the same.
- MrVandemar 2y agoBeginner: I have so much to learn ... Intermediate: I know everything! Expert: I have so much to learn ...
- deleted 2y ago[deleted]
- dudeinhawaii 2y agoI once jumped into a C++ low level dev role having not written C++ in 20yrs (as a teen writing video games). I think the benefit of experience as the OP is that you have a general understanding of the scope of languages, complexity and how to seek out answers. I found that focusing on writing modern (as modern as was allowed) code using the most up to date patterns and methodologies meant that my code was generally better than peers that had been hacking C++ for 10yrs but developed bad habits or simply preferred riskier styles of coding. I don't think C++ is special in being "hard". In fact, the language is so flexible that you can use one of a myriad paradigms that allow for fairly hassle-free coding. The complexity is usually around the constraints of what you're coding because if you're writing it in C++ it's probably meant to be tiny, fast and memory efficient. That also implies that the problem itself is one that lends itself better to reasoning around as opposed to 42 levels of inheritance in a Java system. I don't think _every_ developer could switch to C++ but if one of your say 5 languages is unmanaged then it's not rocket science making the switch.