4 ms·
> You wouldn’t shit on C language... at least less. Nope. If anything, while programming for microcontrollers I learned C is too remote from hardware and leave
by oriolid 6y ago
> You wouldn’t shit on C language... at least less.
Nope. If anything, while programming for microcontrollers I learned C is too remote from hardware and leaves too much implementation-defined. Struct padding? Implementation-defined. Bit field implementation? So implementation-defined you'll have to roll your own with shifts and masks. Accessing anything mapped to memory address? The pointers as defined in C standard aren't what you think, but fortunately the implementation often is. Even standard variable sizes are only 21 years old, which means that there is still legacy code that either doesn't use them or wraps them in layers of typedefs to work with toolchains or libraries that don't. And good luck if you have 24-bit registers.
Of course it's frustratingly low level at the same time. I don't know what could be a good choice, and C is what everyone already uses anyway.
- SV_BubbleTime 6y ago> Struct padding? Implementation-defined. Bit field implementation? So implementation-defined you'll have to roll your own with shifts and masks. You must be much more advanced than I am. Because in 20 years I’ve never had an issue with structure padding because I just assume it pads to n basetypes and pad them manually to 4byte intervals in 32bit. As to portability, man, you must be moving from ARM to mips to x86 to 8051 to OLD stuff, I’ve never had an issues here either, I just don’t make assumptions of but order if it might matter. Jh mean, code gets tested right? LE to BE or padding or whatever isn’t going to slip by me typically. The problem with shifts and masks is they don’t typically “automatically” take advantage of the BMF cpu operations like structures definitely will. IDK, like I said, you must be more advanced than I am. I’ve had none of this issues. Ignorance must be bliss! :)
- oriolid 6y agoYes, my most interesting experience is from writing code that was portable between to TI DSPs. One had 16-bit char and 24-bit pointer, the other 8 and 32 bits. Of course, the struct padding, bit field packing, char signedness, etc were also different. By the way, their compilers were very good at two things: optimizing shifts and masks into bit access operations and sticking to the standard where it is the least intuitive. C was originally intended to be a high level systems programming language and this stuff would have been written in assembly, and it shows.