8 ms·
> for platforms without file systems, or operating systems or where bytes aren't 8 bits, that doesn't use ASCI or Unicode, where NULL isn't on address 0 and so
by ErikCorry 4y ago
> for platforms without file systems, or operating systems or where bytes aren't 8 bits, that doesn't use ASCI or Unicode, where NULL isn't on address 0 and so on.
This seems totally misconceived to me as a basis for standardizing a language in 2022. You are optimizing for the few at the expense of the many.
I get that these strange architectures need a language. Why does it have to be C or C++? They can use a nonstandardized variant of C, but why hobble the language that is 99% used on normal hardware with misfeatures that are justified by trule obscure platforms.
- quelsolaar 4y agoIt doesn't have to be C, but as of today there is no other option. No one is coming up with new languages with these kinds of features so C it is. People should, but language designers today are more interested in memory safety and clever syntax, than portability. I would like to caution you against thinking that these weird platforms are old machines from the 60s that only run in museums. For instance many DSPs have 32bit bytes (smallest memory unit that can be individually addressed), so if you have a pair of new fancy noise canceling headphones, then its not unlikely you are wearing a platform like that on your head everyday.
- ErikCorry 4y agoPerhaps Carbon is the first in a series of new low level languages that free us from the impossible tensions of C/C++ having to be all things to all (low level) programmers. I would love a new language for implementing high level languages. I've worked on several of these projects and we use mostly unstandardized dialects of C++ and it's really not fit for purpose.
- nine_k 4y agoWhile at it, I should mention Zig.
- ErikCorry 4y agoDoes zig have as a selling point that it has _more_ UB than C?
- dleslie 4y agoAFAICT, Zig is halfway step between C and C++ for desktop and mobile developers. I'm thrilled that the folks steering C are keeping the needs of embedded developers at the forefront.
- messe 4y ago> AFAICT, Zig is halfway step between C and C++ for desktop and mobile developers. What does this even mean? Zig very much has embedded use as a target as well, with freestanding use being a first-class citizen. The majority of the standard library works without an OS (and if you wish, you can provide your own OS-like interfaces quite easily, and use the OS-dependent parts in a freestanding environment). I've written a UEFI bootloader in Zig, and right now I'm using it on an RP2040 as well, cross compiling from an M1 Mac without the need to install any additional cross compilers. I'd argue that it might be even better for embedded than C/C++ eventually, as unlike them, allocation is even more tightly controlled, with a convention that only functions (or datastructures) that take an allocator as an argument will allocate memory on the heap. Future versions may even restrict recursion in certain contexts to guarantee max stack depths.
- dleslie 4y agoCool, you've targeted ARM on a common SoC and a desktop PC. Now do sh2, sh4, m68k or even xtensa with Zig with a standard build. They chose to build Zig on top of the worst compiler backend toolchain for embedded support.
- messe 4y agoMan, it hasn’t even fucking reached 1.0 yet. The fact that the default install can target multiple architectures (including C dependencies) is nothing short of impressive. Does GCC target any of those in its standard build? Oh. Wait. It doesn’t. It builds for only one architecture at a time and if you want anything else you’ll need to recompile the compiler. LLVM is even intended to be optional in future, and the Zig team is well on their way to making that a reality with the work on stage2. What backend would you suggest for embedded support?
- mastax 4y agoUnusual platforms like DSPs usually have specific (usually proprietary) toolchains. Why can't those platforms implement extensions to support 32-bit bytes? Why must everyone else support them? In practice ~no C code is portable to machines with 32-bit bytes. That's okay! You don't choose a DSP to run general purpose code. You choose it to run DSP code, usually written for a specific purpose, often in assembly.
- quelsolaar 4y ago"Weird" platforms often do have their own tool-chains but they do have the ability to leverage LLVM, MISRA, and an array of common tools and analyses that exists for C. One of the reason we got new platforms like RISC-V is that today its possible to use existing OSS software to build a platform with a working OS and Development environment, that common basic libraries can be built for is that all this software is written in C and can be targeted towards a new platform.
- ErikCorry 4y agoWhat is the relevance of RiscV here? Not weird at all. I feel like you skipped part of the argument.
- gumby 4y agoThe point is that new exploration of the design space only works when there’s a familiar environment to build on. The old days of each architecture being its own hermetic environment are gone.
- saagarjha 4y agoOk here’s a concrete one, ARM is experimenting with a brand new CHERI implementation that throws out a lot of “obvious” things that are supposed to be true for pointers and integers. The only way this has been able to work is that the standard is flexible enough to let C(++) work here. Rust is getting breaking changes to support the platform.
- chrisseaton 4y ago> It doesn't have to be C, but as of today there is no other option Isn’t C99 an option? Why can’t more advanced things go into newer C and people who genuinely need something more basic can use C99.
- quelsolaar 4y agoWe can! Many of us still use c89.(c99 has problems, like variable length arrays). The reality however is that you cant escape never versions entirely. Not all code you interact with was written in the subset you want, so when your favorite OS or library starts using header files with newer features you need to run that version of the language too. Another less appreciated detail, is that a lot of WG14 work is not about adding new features but clarifying how existing features are meant to work. When the text is clarified this gets back-ported to all previous versions of C in major compilers. An example of this is "provenance". This is a concept that implicitly been standard since the first ISO standard, but only now is becoming formalized. This means that if you want to adhere to the C89 standard, you will find a lot of clarifications about how things should work in the C23 standard.
- kevin_thibedeau 4y agoVLAs are optional since C11. There is no reason why a vendor can't support a modern language.
- duped 4y agoIf it were to focus on stability, it would probably be LLVM IR. That said, there's plenty of C++ being written for these applications. And Ada. > so if you have a pair of new fancy noise canceling headphones, then its not unlikely you are wearing a platform like that on your head everyday. Chip shortage aside, the likelihood of these devices using obscure hardware like discrete DSPs is going down as cheaper low power architectures are becoming commoditized.
- astrange 4y agoLLVM IR isn’t stable or even portable. It’s just a compiler IR, not a language.
- duped 4y agoHence the qualifier, if it focused on stability. And IRs are languages. They look and quack like them and people treat them as such.
- saagarjha 4y agoAnd pay the price, there are tons of places that are stuck with some ossified “LLVM 3.2” toolchain or similar because they build their stuff on an unstable IR.
- duped 4y agoYea and again, I said "if". We live on the else branch of that if statement. My point is that a lot of this sentiment is treating C as the portable backend of a compiler because there is no portable front end. It holds us back in a lot of ways from iterating on systems languages in ways that are interesting and valuable. Ideally there would be an IR with stable textual and binary format that can be compiled into the machine code for various ISAs and support the extensions necessary by silicon manufacturers for the exotic bits. I've used exotic tool chains for weird ISAs where the exotic bits are sugar added to a GCC front end, and it always feels wrong and limiting.
- ryukoposting 4y ago> This seems totally misconceived to me as a basis for standardizing a language in 2022. You are optimizing for the few at the expense of the many. Sure, but it's the same line of reasoning that made C relevant in the first place, and keeps it relevant today - some library your dad wrote for a PDP-whatever is still usable today on your laptop running Windows 10. Because it's antiquated, it's also extremely easy to support, and to port to new and/or exotic platforms.
- ErikCorry 4y agoThe library my dad wrote (lol) for the PDP-11 is probably full of undefined behaviour and won't work now that optimizers are using any gap in the standard to miscompile code.
- flqn 4y agoWhat a useless and jaded assumption that code written in the past is bad.
- jolux 4y agoThe assumption being made here is "any useful C program relies on undefined behavior" which is pretty much true.
- ErikCorry 4y agoYes and I'm sure it's doubly true of code that was written before the C standards were written.
- pantalaimon 4y agoThat sounds like a strong take - to you have examples? Compiling with -Wall -Werror is pretty much standard those days.
- morelisp 4y ago
- skrebbel 4y agoC is pretty much the only language in common use for programming microcontrollers. Microntrollers seldomly have filesystems. To break the language on systems without filesystems or terminals means to break the software of pretty much every electronics manufacturer out there.
- varajelle 4y agoBut you don't run the compiler on a computer without a file system. How would #include works otherwise?
- ithkuil 4y agoIt may have no filesystem but it's extremely likely it has 8 bit bytes
- josephcsible 4y agoCHAR_BIT != 8 on a lot of systems: https://stackoverflow.com/q/2098149/7509065 https://stackoverflow.com/q/2098149/7509065
- ithkuil 4y agoYeah, if the number of platforms using an obscure corner of the spec were exactly zero, we wouldn't be talking about whether the niche size is worth the hassle. My point was that this niche doesn't cover the entirety of the embedded / IoT space.
- varajelle 4y agoThinking of it, JavaScript is a language that target mainly browser, which also doesn't have a filesystem.
- dleslie 4y agoWeb requests are its filesystem.
- 4y ago
- gumby 4y agoAs the GP post comments, if you want those features there are plenty of other languages to choose from. I don’t even like programming in C but I respect what the committee is trying to do, and yes I do sometimes write C code.
- Gibbon1 4y agoI'll flip that around if you want to serve on a language standards commit there are a lot of other languages to choose from. Why be on the C standards committee with the express purpose of blocking progress?
- nine_k 4y agoI would say that one should be pretty cautious when baking in assumptions snouty such a fleeting thing as hardware into such a lasting thing as a language. C itself carries a lot of assumptions about computer architecture from the PDP-9 / PDP-11 era, and this does hold current hardware back a bit: see how well the cool nonstandard and fast Cell CPU fared. A language standard should assume as little about the hardware as possible, while also, ideally, allowing to describe properties of the hardware somehow. C tries hard, but the problem is not easy at all.
- uecker 4y agoCan you explain what aspect of C from PDP-11 was problematic for Cell?
- nine_k 4y agoAll memory is uniform, for instance. There is one scalar data processing unit that finishes a previous operation and then issues the next: no way to naturally describe SIMD, for instance. No way to speak about asynchronous things that happen on a Cell CPU all the time, as much as I can judge. (I never programmed it, but I remember that people who did said they had to use assembly extensively.) OTOH you can write stuff like `*src++ = *dst++`, and it would neatly compile into something like `movb (R1)+, (R2)+`, a single opcode on a PDP-11.
- beached_whale 4y agoThis is purely compiler side and usually those esoteric hosts are not running the compiler, being cross compiled but cross compiled, aren't they?
- Gibbon1 4y agoWell and studiously not talking to the few about their actual needs.
- stephencanon 4y agoIt’s worse—-almost all of them already use a nonstandard variant of C. The committee is bending over backwards to accommodate them, but they literally _do not care what the standard says_, so this doesn’t even benefit them. Most will keep using a busted C89 toolchain with a haphazard mix of extensions no matter what the standard does.
- dotopotoro 4y agoEven if they fork the language, standard still provides the common baseline for all, which is useful.