3 ms·
It Seems To Me that a little more attention to cross-compilation support would go a long way toward extending support to all the weird architectures. Really, r
by ncmncm 6y ago
It Seems To Me that a little more attention to cross-compilation support would go a long way toward extending support to all the weird architectures.
Really, running a language toolchain on the target machine, where the target machine isn't what everybody has, is largely pointless. We each have loads of machines to run toolchains on.
Early in the life of a language, with a compiler meta-circularly written in it, the compiler is the biggest program in the language, so may seem like an effective early test of a port. But, it must be said, meta-circularity is, in large degree, wankage. There are much better choices to demonstrate the merits of your new language than coding its compiler; a compiler is not the persuasive demonstration of language merit it once was. Writing your language's compiler in an unstable and unreliable new language, making it subject to its own bugs and early inefficiencies, is a poor way to help a new and fragile user community up to speed.
How did we get on this meta-circularity fetish, anyway? It's easy to see how it happened with C, but aping what C did is no formula for success, anymore. C is, or once was, a pretty simple language to compile, so its compiler wouldn't much benefit from being implemented in a more powerful language, if there had been any. That cannot be said of modern languages, where all the help you can give them is just enough to make a usable compiler. Notably, LLVM is coded in (a dialect of) C++, even the project's C compiler.
A cross-toolchain, coded in C++, built to run on Linux amd64 and nowhere else, ought to be all you need to bring up full support for any language on any architecture. As we say about low Earth orbit, it puts you halfway to anywhere in the universe. Even where you don't have Linux, you have a VM you can run it in. Cross-development skills take some investment, but they pay forever after. The overwhelming majority of places you could run code nowadays can't meaningfully host a development environment anyway. Cross skills enable you to program the microcontrollers that manage about everything in the world, today, and phones, and HPC supercomputers alike.
A cross-built program can not only be built on your desktop host machine. It can be debugged from there, running in an emulator or on the actual target hardware. The debugger runs on the host, with access to all the source code. What we call a "debug stub", a tiny fragment of code is inserted in the program or target environment that implements the minimal primitives a debugger needs: mostly just peek, poke, and run; maybe watchpoints if the target supports that. The debugger talks to the stub over a network port, or a serial cable, or by blinking lights, if necessary.
Linux on amd64 didn't take over the world, with no marketing budget in sight, by being the best place possible place to run programs. (It's just adequate, and better at it than Windows.) Linux got there by being the best possible place to develop software. Make it the best place to develop in your language, whatever the target, and you are halfway to anywhere.