News for hackers. Stuff that matters.
Re:OS X app in plain C by derefr on Thursday May 05, 2016 @04:10PM (#11639307)
To put it another way: C doesn't have an ABI; C has an API (or a wire protocol, if you prefer.) The abstraction layer of C doesn't exist between the machine-architecture and the C compiler; rather, the abstraction layer of C exists between the C compiler and the user, and takes the form of uncompiled C source code.

The design of C is predicated on an approach to portability that involves shipping source code, not binaries, around, with the destination machine having a compiler for its own architecture. (Given this, it's kind of shocking that things like Docker work at all. Goes to show how large a server-side monopoly those Intel ISAs currently hold.)

---

But wouldn't it be interesting if the "C compiler" were made into a low-level part of the operating system—basically taking the form of a JIT with a persistent cache—and then an executable format were specified, which really was just an archive of C source that was JIT-compiled by the OS when you first execv(3)ed it? Then you would have portable C binaries, because you'd be using the "correct" C ABI: C source-code.

Well, if you tack on a bit of pre-chewing to annotate the C source a bit (and maybe do some arch-neutral optimizations), and you have Apple's current LLVM-IR-based "Bitcode" approach to binaries.

Re:OS X app in plain C by blt on Thursday May 05, 2016 @04:33PM (#11639465)
Check out the architecture of TempleOS.
Re:OS X app in plain C by chris_wot on Thursday May 05, 2016 @07:52PM (#11640631)
What, like C as a shell script? Gott in Himmel!
Re:OS X app in plain C by Kristine1975 on Friday May 06, 2016 @02:11AM (#11642037)
How about an interactive C++ interpreter: https://root.cern.ch/cling

Also it's Gott im Himmel ;-) (unless it's a reference I didn't get)

Re:OS X app in plain C by chris_wot on Friday May 06, 2016 @04:34AM (#11642514)
iPhone autocorrect :-(