3 ms·
Here's what I could write in C that I couldn't in (most) other languages: unsigned short *reg = (unsigned short*)0xFFFF1014; *reg = 0x1027; If you have me
by AnimalMuppet 5y ago
Here's what I could write in C that I couldn't in (most) other languages:
unsigned short *reg = (unsigned short*)0xFFFF1014;
*reg = 0x1027;
If you have memory-mapped I/O (like the 68000-style architectures did), this lets you take a hardware register at a known address, and write any bit pattern you wanted to it. For embedded hardware, this meant that the hardware was right there, ready to work with.
Sure, you can crash your program if there isn't the hardware you expect at 0xFFFF1014. Sure, you can use this exact approach to trash memory anywhere in your program image. But it lets you easily do things that are not easily done in most other languages.
- aserafini 5y agoVery interesting and you’re right that this is almost uniquely and most easily expressible in C, but if that makes C ‘weird’ I don’t understand what the point of the article is anymore. By that definition all languages are ‘weird’ including Java and have uniquely expressible koans within them. Maybe it boils down to ‘use the right tool for the job’, ie, the tool that lends itself best to the job at hand.
- arketyp 5y agoYes, weird depends. PG's point is, again, about finding new pockets of programming, not necessarily finding the best tool -- meta or not -- for a task at hand. Fine, everything is binary code in the end; it doesn't mean there aren't different abstractions that can be made on top of it, obviously. You are probably right that PG is biased towards "hacking" rather than team software engineering by him implying that the 99.5% of "glue programming" is boring. There is potential for a lot of mastery on the glue front, but this point about weirdness is about the remaining 0.5% and how to access it via the language route. Personally I'd be interested to hear what PG says about the weirdness of OOP...