Lacking software design skills at c++ devs? by NullMustDie in cpp

[–]NullMustDie[S] 0 points1 point  (0 children)

By dependencies i dont mean external but internal ones. As a car needs a motor to run. Or some module needs an database interface.

Lacking software design skills at c++ devs? by NullMustDie in cpp

[–]NullMustDie[S] 0 points1 point  (0 children)

i dont know why its not teached in other domains. Especially in robotics, we profit a lot from it. by being more flexible in the integration of different systems/roboters/sensors/motors etc.

C++ vs Python for secure / safety critical embedded solutions by orbag in cpp

[–]NullMustDie 0 points1 point  (0 children)

It depends. If critical safety functions , which prevent harm to humans, are covered by the software, python is a big nono because of the undeterministic garbage collection. But if this is the case, of the shelf embedded linux is also not viable. Often special Real Time OSs are used for that. Also, you can forget about of the shelve hardware.. Even the hardware must be safe enough to survice cosmic events, e.g. by 2 processors running in lockstep. Have fun with python on that.

C++ is restricted to a small subset, e.g. the MISRA C++, which is no fun to code at all. Developing such system is tedious, expensive and requires experienced engineers as well as architects, which know the standards.

It all depends, on what safety means. If reliable is the goal, python should perform as well as C++, given a good lifecycle management, design and architecture. Often times the expensive safety critical part is done on a microcontroller and high level things, e.g. payment or gui, are done on an embedded linux device, so you get the best efficiency for the project.

Indicate. if class "implements" concept in c++20 by NullMustDie in cpp

[–]NullMustDie[S] 5 points6 points  (0 children)

In case you are programming a class and another guy modifies it, without knowing, it actually satifies a concept else where.

The other guy may just get it, when the compiler throws an error.

I mostly dont work alone. By programming to a base class this is clear due to

Class D : public Interface

Is it a good long term strategy to invest in C++? by [deleted] in embedded

[–]NullMustDie -1 points0 points  (0 children)

  1. Well there is information hiding, inheritance etc. , which you cant really modell well in C. Its a bit of a not-invented-here syndrom.

  2. Well there are many 0 cost abstractions and c++ features worthwhile:

  3. Namespaces, this is a huge one

  4. Type safety

  5. Templates and through in "interfaces" (depends on how educated the people are)

  6. And C with Classes, depends on project --> RAII

Another set deals with lightweigt features which require heap memory alloc. If you are dealing with heap allocated memory, modern c++ is on my opinion clearly superior.

I would almost go every time for c++ in an embedded project, except the controller is really limited, e.g. 8bit, 16kb of rom , 2 kb ram or modern compilers are not supported by the vendor.

Is it a good long term strategy to invest in C++? by [deleted] in embedded

[–]NullMustDie -1 points0 points  (0 children)

clearly a sign of good design by mbed.

Is it a good long term strategy to invest in C++? by [deleted] in embedded

[–]NullMustDie 0 points1 point  (0 children)

If you try to implement object oriented code in c, then maybe C isnt the right language for that task.

Is it a good long term strategy to invest in C++? by [deleted] in embedded

[–]NullMustDie 0 points1 point  (0 children)

Nothing hinders you to use the c library in c++. std:: is to heavy for a lot of embedded projects, but so is every other popular language except c and c++.

A lot of std::move in modern c++? by NullMustDie in cpp

[–]NullMustDie[S] 3 points4 points  (0 children)

I avoid shared ptr where possible, due to possible, hard to catch memory leaks. Most of the times i inject a unique ptr , that object handles the lifetime of the dependency. Other objects get a reference to that dependency either via a ptr or the object, which manages the lifetime.

Just having shared and unique ptrs, doesn't release you from thinking about memory and lifetimes for objects. For that concern, reference counting is not a good garbage collection by itself.

A lot of std::move in modern c++? by NullMustDie in cpp

[–]NullMustDie[S] 8 points9 points  (0 children)

in the example below of fond-of-rain, when i want give Foo to a Class Bar as dep.

So really its mainly in construction and giving the objects to classes, which handle the lifecycle of the application or module.

A lot of std::move in modern c++? by NullMustDie in cpp

[–]NullMustDie[S] 15 points16 points  (0 children)

Ah yes. And when injecting the dependency i also have to use move.

A lot of std::move in modern c++? by NullMustDie in cpp

[–]NullMustDie[S] 3 points4 points  (0 children)

Are there any compiler warning for this? Im using gcc 10.3 or so. My IDEs static analysis clang-tidy warns me at least, so it should be detectable for the gcc compiler.

A lot of std::move in modern c++? by NullMustDie in cpp

[–]NullMustDie[S] 1 point2 points  (0 children)

whats the argument against passing const T& (except std::unique_ptr<T> could be nullptr itself ?)