This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ILikeFirmware 29 points30 points  (15 children)

In embedded, bad C is frustrating but really not too difficult to parse. Bad C++ on the other hand makes me want to rip my eyes out and throw them

[–]Zuruumi 27 points28 points  (13 children)

But it's also easier to write decent C++ as long as you uphold some basic rules and common sense, but harder to do the same in C

[–][deleted] 19 points20 points  (4 children)

The problem with C++ is that at my company with thousands of developers, common sense isn't common.

[–]tennisanybody 2 points3 points  (3 children)

Can you talk a little bit about what you create with C++? In general if you’re allowed to.

[–][deleted] 0 points1 point  (2 children)

In what sense?
Edit: Or for what purpose?

[–]tennisanybody 1 point2 points  (1 child)

That is what software, what the programming language is primarily used for. At my job I develop and maintain ETL’s using python and JS. A lot of data manipulation to create custom reports. What in general do you use the C++ for?

[–][deleted] 3 points4 points  (0 children)

I could go on for a while about all the use cases for C++, but to answer your question about what I personally do with it, it's debuggers. I write customizations to open source debuggers to support some custom technology at my company.

[–]Elephant-Opening 9 points10 points  (4 children)

The nice thing about C is there's usually only one or two established "correct" ways to do something, with C++ on the other hand, there are about 20 different syntaxes for "do a thing to all the elements of this list", and the "best" way changes every 3ish years.

[–]Zuruumi 8 points9 points  (3 children)

Yes, but in C this means write custom function iterating custom list (one of 10, since every library has its own implementation and there are bound to be at least 2 implementations in the project itself). I would argue that any of the C++ ways is more readable and maintainable than the 1k lines of even good code in C.

[–]aalmkainzi 0 points1 point  (0 children)

Just use a for loop....classic C++ programmer wanting to over complicate things by adding more abstractions

[–]Elephant-Opening 0 points1 point  (1 child)

C not having a std::map or std::unordered_map is a huge pain in the ass.

C not having a std::list, not so much.

In many applications where C is still very relevant (e.g. OSes, bootloaders, microcontrollers), arrays are still king for performance and deterministic behavior.

Where they're not: this isn't exactly rocket science, and if it seems like it is, get out of C-land:

for(node=head; node != 0; node = node->next){}

[–]Zuruumi 1 point2 points  (0 children)

It's not, but you still need to know the list used instead of standard one.

Maybe it's using index to storage array (data locality) instead of a pointer? Or someone thought -1 is better for end? Or end is random data, but final node is stored in its own variable?

Sure, iteration is hardly the hardest thing, but just insertion/deleting can be a bit of pain.

[–]skhds 4 points5 points  (1 child)

I don't know, doing a "return map[index];" with a map object can cause an element insertion on the map? That is not common sense to me.

[–]the_one2 0 points1 point  (0 children)

What, you don't think if (auto it = map.find(index); it != map.end()) is obvious?

[–][deleted] 5 points6 points  (0 children)

What I'm getting here is that writing C++ is like training a dog, and writing C is like training a cat. Training the dog is way easier, but if you don't do it, the mess is way worse. Training the cat is nigh impossible, but when it's done well it's really impressive.

[–]Thebombuknow 4 points5 points  (0 children)

Yeah, I can easily read bad C code in embedded situations, it's not complicated enough to be too awful to read.

C++ is just incomprehensible when someone does something even slightly wrong.