| General > General Technical Chat |
| How many people code in C these days, and if so, why? |
| << < (69/99) > >> |
| Picuino:
There have also been attempts to define subsets of C++ for embedded systems, but without much success. https://en.wikipedia.org/wiki/Embedded_C%2B%2B |
| maginnovision:
--- Quote from: Picuino on May 12, 2020, 06:04:00 pm ---Arduino has 2k of ram. It is near impossible to do a good memory management with such a minimal amount of resources. Normally, libraries work only with static memory, with the variables defined by default with each class. Printf isn't even used because of the large amount of memory it consumes. --- End quote --- They teensy 4.1 can have over 8Mb of ram, arduino is not an mcu it's just a lousy ide and a set of libraries to use. |
| Wolfgang:
--- Quote from: coppice on May 12, 2020, 05:51:01 pm --- --- Quote from: Wolfgang on May 12, 2020, 05:47:46 pm ---No language standard specifies how memory that is no longer needed is handled. Thats specific to a runtime component. :palm: And believe me, a lot of intelligent algorithms have been written to handle this. Problem. Efficient / Fast / Deterministic. Choose any two. --- End quote --- Many languages are specified with their run time environment, and are not really separable from it. Java assumes a garbage collecting environment, for example. --- End quote --- Not true, IMHO. Some specify (Java) that GC is done, but not *when* its done and *how* its done. A ton of problems emerged from the fact that on a large machine Java never ran out of memory so no GC was done. The obliterated objects did contain some OS resources, however (e.g. handles) and some ugly day the app crashed because handles were out of stock. In Java, you may call GC(), *but there is no guarantee that something will happen*. On small hardware - this is deadly. |
| IanB:
--- Quote from: Wolfgang on May 12, 2020, 05:47:46 pm ---No language standard specifies how memory that is no longer needed is handled. Thats specific to a runtime component. :palm: And believe me, a lot of intelligent algorithms have been written to handle this. Problem. Efficient / Fast / Deterministic. Choose any two. --- End quote --- In C++ you have complete control over when each resource will allocated and when it will be freed. If you don't want to rely on heap allocation for memory you can make 100% use of stack allocation. You don't have to use dynamic allocation in C++ any more than you have to use malloc() in C. C++ is actually very good at compiling for embedded systems because the compiler can allow for more expressive code (reducing bugs and improving maintainability) while producing binaries as small and fast as a C compiler. Why do you say pick any two from efficient, fast or deterministic? Why can an efficient and fast program not be deterministic at the same time? I would suggest that most code written for small embedded systems is all of these. |
| IanB:
--- Quote from: Picuino on May 12, 2020, 06:23:16 pm ---There have also been attempts to define subsets of C++ for embedded systems, but without much success. https://en.wikipedia.org/wiki/Embedded_C%2B%2B --- End quote --- This is a human problem, not a technical problem. Just because there is a supermarket full of food, does that mean you have to buy and eat everything that is on the shelves? Most people are selective, they buy what they need, leave what they don't. |
| Navigation |
| Message Index |
| Next page |
| Previous page |