General > General Technical Chat

How many people code in C these days, and if so, why?

<< < (70/99) > >>

Picuino:

--- Quote from: maginnovision on May 12, 2020, 06:51:15 pm ---
--- 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.

--- End quote ---

Arduino is not an IDE nor a development board. Arduino is a commercial trademark of Arduino LLC (the company). Many of its hardware and software products carry the Arduino brand in their name.
Teensy is not an Arduino LLC project. It just has a compatibility pack with the Arduino IDE, like other external projects.

When I spoke of Arduino I was referring to the development boards based on the Atmega328P, the most widespread.

Picuino:
We are debating about the tools C or C++. But in programming there are two elements involved, the programming language and the programmers. Since the first time I had to program in a company (in my case with ladder language of the PLC) the simplest task was to learn the language.
The most difficult task was learning the method of representing the algorithms (Grafcet) and all the company standards that had to be followed in order for the software to be homogeneous and easily maintainable from the projects office to the workshop technicians.

In other languages ​​the same thing happens, the development environment (the company and the team you work with and its rules) are more important than the language itself.

Picuino:
I think you can make good C++ software for microcontrollers, but that is very much related to being able to follow strict development rules and that programmers follow them efficiently.

engrguy42:
Okay, I'm not gonna rub it in anymore. I promise.

Well, maybe just this one last time  :D

You guys need to get out more. Deep, never ending discussions of booleans and unrelated C stuff. Memory worries, garbage collection...

And me, I whipped together a wonderful app in C# in no time, and son of a gun it's already being used for important stuff.  :-+

In the other forum I posted on a USB battery I have that needed a circuit to apply brief pulses of load to keep it on, otherwise the internal circuit would shut it off. So I kludged together a 555 circuit with some yummy PWM output, and now my battery stays on with 5 second pulses of load current every 15 seconds.

And to log its behavior I used my C# data acquisition app (see below). Took me, on and off, a couple days to build that app and put the finishing touches.

Now honestly, I know you guys just LOVE your C and all that embedded stuff, but come on. You can't do that in C. No way. Not possible. GUI stuff? Logging to CSV file? Making realtime charts/graphs that auto-update scaling factors as data comes in? Hell, that would take weeks to do that in C. Maybe months. Or years.

Anyway, I apologize. Just messin' with ya. C RULES!!!  :-+ 

Nominal Animal:

--- Quote from: nctnico on May 12, 2020, 05:18:14 pm ---But the same is true for C. There is a lot from the standard library you can't use. File I/O for example. Malloc & free are also troublesome to say the least.

--- End quote ---
No, "freestanding C" is very well defined compared to "freestanding C++".  If you compare the standards, you'll find that C++ leaves it basically up to the implementation, which means that "freestanding C++" is implementation defined – it doesn't mean anything unless you specify the implementation.

For freestanding C, none of the standard library is available.  Facilities provided by <float.h>, <limits.h>, <stdarg.h>, <stddef.h>, <stdbool.h>, and <stdint.h> should be available.  Complex number support is optional, and using any floating-point variables or operations can require special consideration (for example, on hardware that does not support FP), but otherwise the core language features are available.  This is well defined, with few surprises.

For freestanding C++, some of the core language features, like exceptions, may or may not be available; you don't know, unless you know the implementation.  And Arduino folks don't say; they don't really even call the code C++, just "Arduino sketches".

It is true that the distinction between "freestanding" and "hosted" is crucial for C, but is often ignored because people think it is "obvious" from the context.  I think that is equally misleading to new programmers.


--- Quote from: madires on May 12, 2020, 06:06:41 pm ---But there are also standards defining some specific variant of a language, like C++17 (ISO/IEC 14882:2017) or C18 (ISO/IEC 9899:2018).
--- End quote ---
Exactly.  And my point was that while "Freestanding C" is well defined in the standards with fuzzy edges around complex and floating-point support only, "Freestanding C++" is almost completely implementation-defined, including core language features like exceptions.

There must be a limit to how many core language features you can remove, and still call it the same language.  With C, you get mostly right if you say "the standard C library is not available", but with C++, all bets are off; and therefore a more descriptive label that much more important.

In the other direction, I've mentioned "POSIX C99", which means a hosted C99 (ISO/IEC 9899:1999) environment that provides IEEE Std 1003.1™-2017 System Interfaces.

(FWIW, I personally do point out to learners that "Arduino uses a subset of C++ features, not the full C++ language" with additional descriptions of those features depending on their knowledge level.  I do that because it is thus far it seems to foster the most reasonable expectations and helps with the intuitive grasp the environment.  Those expecting their hosted C++ to be directly applicable are usually sorely disappointed by the limitations.)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod