5 ms·
Port LLVM to it, you're halfway there. Such a restricted machine unfortunately is not amenable to any abstraction and I have no idea what such bad hardware wou
by AstralStorm 10y ago
Port LLVM to it, you're halfway there.
Such a restricted machine unfortunately is not amenable to any abstraction and I have no idea what such bad hardware would be used for. Nor why.
- mikeash 10y agoTiny microcontrollers are used all over the place. They're useful in things like appliances and simple peripherals. I'm guessing that the other comment is referring to PIC microcontrollers. Over a billion such microcontrollers are sold every year. Not all of them are that limited, but many are. And they are amenable to the abstraction of C. That's kind of the whole point of that comment. The world of computing is far larger than PCs and smartphones. One could make a convincing argument that those are a small minority, in fact.
- tathougies 10y agoBut, to be fair, dynamic memory management is rarely used in microcontroller programming. Additionally, it's much easier in such a restricted environment to test the machine against every possible input (or a very representative sample). This explains the relative paucity of memory safety bugs in these environments.
- kbenson 10y ago> And they are amenable to the abstraction of C. That's kind of the whole point of that comment. Well, that's sort of the problem, right? C was made so portable (because, admittedly at the time of development hardware was less uniform) that a lot of assumptions we take for granted are actually undefined, because you can't make those assumptions about the underlying hardware. What makes C usable and useful on these architectures is the same thing that causes problems for the other 99.9% of people programming in it. Should a language with obvious shortcomings in the name of portability be one of the de-facto standard languages for all types of library development? Do i even trust a crypto or XML parser library written in C on a platform with a non "standard" word or byte sizes that wasn't developed specifically for that architecture, or those constraints? > The world of computing is far larger than PCs and smartphones. One could make a convincing argument that those are a small minority, in fact. As a question of where to optimize, I would say it pays to get a much safer language on these devices, both because it would prevent crashes, bugs and security problems, and because (I think?) far less people are responsible for writing the code, so a little extra work on their part pays of more overall). I think C is as prominent as it is today because of how history played out, not necessarily because of its inherent merits.
- makomk 10y agoThey're not that amenable to the abstraction of C. Companies have managed to create C compilers for PICs anyway because there's a market for them, but they have - amongst other problematic features - bank switching for RAM and register access, extremely limited support for indirect addressing, no hardware support for function pointers, a hardware stack with limited depth that cannot be accessed directly, only implicitly via call and return instructions. Someone elsewhere in the thread mentioned using a compiler that didn't support recursion; that's probably because there's no easy way of supporting stack variables on most PICs.
- com2kid 10y agohttps://en.wikipedia.org/wiki/PIC_microcontroller https://en.wikipedia.org/wiki/PIC_microcontroller Incredibly common chips, less so today, but historically they were all over the place. Looking at Wikipedia, it seems the 14bit instruction set PIC had a whopping 128 bytes of memory. For managing a bunch of toggle switches or dials with 8 positions, I imagine that was more than enough.
- DoofusOfDeath 10y ago> Such a restricted machine unfortunately is not amenable to any abstraction I can't tell if you're using hyperbole, or if you mean "any abstraction" literally. If you mean it literally, we should probably discuss that.
- snovv_crash 10y ago>I have no idea what such bad hardware would be used for. Nor why. You would use it for places where the uC is cheaper than a few transistors or flip-flops, for example to flash lights in a pattern. Also when you need extremely low power consumption, like a digital watch or BTLE beacon. There are uCs in everything these days.