5 ms·
of course nobody should be writing C any more, for exactly the reason you're demonstrating in this comment
by preseinger 4y ago
of course nobody should be writing C any more, for exactly the reason you're demonstrating in this comment
- raldi 4y agoWhat language do you think Linux and Arduino should be programmed in?
- pjmlp 4y agoArduino uses C++, thankfully.
- raldi 4y agoEverything in the top-level comment applies to C++, too.
- pjmlp 4y agoMy "thankfully" remark shows my point of view. The only sin of C++ is the same that plagues evolutionary languages like Typescript, Kotlin and so forth. No matter how many tools they provide to write better code than the language they have grown from, their compatibility with them is like hearding cats while trying to have everyone adopt best practices. Otherwise in regards to Arduino, I would suggest a couple of nice BASIC and Pascal compilers like those sold by Mikroe.
- saagarjha 4y agoIf it was created today? I’d go for Rust and Python respectively
- deleted 4y ago[deleted]
- eric__cartman 4y agoThe ATmega 328P an Arduino Uno or Nano uses has 2KB of memory and 32KB of flash storage for the program. Having some sort of micropython interpreter there would be impossible, and even if it could be achieved, somone still has to write the low level C/ASM code to make it all work. For many embedded systems, low level languages like C or C++ (perhaps Rust for a lot of ARM micros) is the only sensible choice. If it's not a multi user system that's connected to a network, people trying to abuse memory unsafe code isn't a concern.
- deckard1 4y ago> has to write the low level C/ASM code to make it all work shhh. Let's not disturb those that believe in the GC fairy that sprinkles their code with safety magic late at night while they soundly sleep. Firmware doesn't exist. I can't hear you. Na na na na na na na
- pjmlp 4y agoToo late, here is Firmware being written in Go. https://www.withsecure.com/us-en/solutions/innovative-security-hardware/usb-armory https://www.withsecure.com/us-en/solutions/innovative-securi...
- SOLAR_FIELDS 4y agoI hope Rust takes off for embedded programming. I've been working with ESP32 and C is really the only choice if you are doing anything remotely fancy or resource constrained
- Gibbon1 4y agoWhat bothers me about rust is the designers are people that have been bitten hard by working on browsers written in C++ with it's manual memory management and no way to enforce object lifetimes. Rusts solution to that seems like a big hammer when it comes to embedded where you usually have either stack allocated or compile time allocated objects.
- raldi 4y agoGuess what Python is written in. https://stackoverflow.com/a/9451956 https://stackoverflow.com/a/9451956
- saagarjha 4y agoIt doesn’t have to be.
- JKCalhoun 4y agoIf you're steeped in C and its quirks, have good coding patterns that allow for it, I say knock yourself out. I'm absolutely coding in C again — writing some old-school games using SDL. After working for decades with various retain/release, garbage-collected, magic-memory™ languages, going back to C feels like programming again. I like it.
- lmm 4y ago> If you're steeped in C and its quirks, have good coding patterns that allow for it, I say knock yourself out. Somewhere between 95% and 100% of people who think they're "steeped in C and its quirks, have good coding patterns that allow for it" write code that invokes undefined behaviour.
- otabdeveloper4 4y agoThere's nothing wrong with undefined behaviour.
- preseinger 4y agoUndefined behavior means the language provides no guarantees about the outcome. Whatever happens is up to the compiler, or rather the specific implementation of the compiler, and the target architecture on which the program is run. These things are not constrained by any spec or guarantee, so they are allowed to change, for any reason, to anything. These changes may be triggered by not only different execution environments, but also changes to properties of a given execution environment. The behavior of a program with undefined behavior is non-deterministic, and cannot be predicted, modeled, or effectively maintained.
- otabdeveloper4 4y ago> Undefined behavior means the language provides no guarantees about the outcome. No, not "the language", but "the standard". Languages like Python or Rust that don't have standards are 100 percent undefined behavior. If you're really worried about this, then just code against x86_64 clang and not ISO C++ and forget about this non-problem forever.