News for hackers. Stuff that matters.
Re:Post-Apocalyptic Programming by kibwen on Monday August 08, 2022 @08:30AM (#32384688)
Even aside from the apocalypse, I was wondering recently how someone might "pass down" some piece of software, like say a video game, to their descendants. If you want to leave a written record for future generations then it's easy enough to print out a book on some acid-free paper and reasonably expect that it will last for up to a millennium. But for robustly archiving a piece of software it's not enough to print out the complete source code (including dependencies), you also need the complete source of the compiler (including dependencies), and the complete source of the operating system it runs on, and complete schematics for the hardware it runs on, and instructions on how to manufacture the hardware, and possibly more.

In the same way that we have standards for archival-grade books, it seems like we could benefit from some sort of standard archival-grade software stack designed for simplicity (and I mean real simplicity, I agree with the article that even C is too complicated and you want a Forth or something (or maybe a Scheme)). It's okay if the stack is as slow as molasses, as long as you have a functional reference implementation you can always produce a translation into whatever modern stack exists in your time period.

Re:Post-Apocalyptic Programming by Kadin on Monday August 08, 2022 @10:09AM (#32385562)
Printing the source out on paper would probably be the most long-lasting storage method (aside from engraving it into large pieces of stone, maybe). But typing the source code back in for most non-trivial pieces of software would be really painful.

"Here's the source code, go type it in" hasn't been a very popular method of distributing software, for good reason, in a long time.

Maybe there's some way that you could include the true source code (in C or some other well-understood language) of a small decoder program, which would then take as input some more-compact representation of the desired programs? Something minified and compressed, but kept in a form that would make it relatively quick to type in? Maybe you could have the user type in groups of characters (6-7 or so at a time, because that's generally assumed to be the number of abstract symbols a person can easily hold in working short-term memory) and get a checksum back, that they could verify against the input book.

Actually, you should probably have checksums per-line, per-page, and per-chapter/section. That way if you had a decoding problem, you could quickly drill down to the error without manually checking each character.

Re:Post-Apocalyptic Programming by Banana699 on Monday August 08, 2022 @03:23PM (#32389835)
Saving the source alone hardly solves anything, the comment you're replying to highlights the real problem : The Stack. Everything from the compiler\VM to the OS to the instruction set architecture and everything in between. You have to save and store all of that.

You need a format other than text, text is extraordinarily inefficient and lossy at anything that is not declarative factual information. There has to be artifacts.

Re:Post-Apocalyptic Programming by AstralStorm on Monday August 08, 2022 @07:17PM (#32392311)
What you need is a C compiler, an assembler and maybe a basic linker, then you're set. It does not need to be very good either.

In a pinch, an interpreter might do.

From there, getting an OS running is relatively quick. Remember back when PCs came with nothing but BASIC and machine code? People typed in complex machine code via that interface and ran quite complex apps.

Re:Post-Apocalyptic Programming by Banana699 on Tuesday August 09, 2022 @08:26AM (#32396918)
This really only works if the programs you want to preserve are already written in C or can be transformed readily into comprehensible C source, which is not the most elegant or comprehensible language even in the best of times. What if you want to preserve Python ? now you have to type the entirety of Cpython before you even get to write the main preserved program (in python). What if you want to preserve browser JS ? (for a taste of why this might be useful, see the conversation on Flash. You can crticize and hate it till the cows come home, but it's a substantial part of human cultural heritage regardless.), now you need to type in a browser or at least a JS engine on top of the JS program. For a self-hosted compiled implementations of languages like Haskell or Rust, you would type in an irrelevant bootstrapping compiler in C first then type in the self-hosting compiler then type in the program. That's... tedious and unscalable.

The amount of work you would spend to think and implement workarounds for all of this is better spent thinking and implementing language-, OS-, and hardware- independent specifications and VMs that are minimal and long-lasting, to better support a huge variety of the software and media and languages that make up our cultural heritage now, C being just one language among many.

-------

You mention in an aside that a C interpreter would better suit preservation efforts than a heavy-duty overkill like today's optimizing C compilers, that's a good idea, naive interpreters are easy, much more so than complex compilers or runtimes. BUT, C is horrifically full of undefined behaviour and implementation-defined behaviour, and the spec is a natural language document so even if a behaviour is defined it's not really *defined* in the mathematical well-behaved sense, because you know how natural language is, you're always one tricky test case away from a bug. This is important, you never know you're depending on this or that behaviour until the applications fails or runs very strangely when running on another toolchain.

That's why I argue we need formal specifications and VMs, and minimal ones at that. Indeed, we need a hierarchy of such specifications and VMs, becase hierarchies are efficient at compressing an otherwise-exponential amount of data (think of deep neural networks or search trees, why are they so efficient?). A sequence of bootstrapping minimal VMs is better and easier to preserve than one large heavy VM, eggs and baskets and all. Furthermore, designing new VMs and specifications specifically for preservation would force us to think about the framework we use to formalize and talk about them : maybe we can use $HOT_NEW_THING fresh from CS academia, or maybe we can use a natural numbers- or a boolean circuits- based approach, as those things are not fancy and easier to explain when you don't have a lot of shared context, they are - in a sense - the "bare minimum" you need to understand or talk about computers.

Re:Post-Apocalyptic Programming by jeremysalwen on Monday August 08, 2022 @03:09PM (#32389639)
You might be interested in this superuser question: https://superuser.com/questions/415451/how-to-transfer-a-fil...

I was thinking forward error correction would make interactivity unnecessary.

Re:Post-Apocalyptic Programming by cardanome on Monday August 08, 2022 @12:33PM (#32387690)
Or you could just use APL, which already has a high information density.

Lot's of useful APL programs are very small, easily fitting on a single stone table and would not be much trouble to retype. In fact good APL programmers are even able to memorize them easily.

Re:Post-Apocalyptic Programming by bitwize on Monday August 08, 2022 @04:56PM (#32390909)
Fun fact: PCs used to come with nearly all this information. Full schematics, manufacturer specs for the CPU and other important chips, all in the Technical Reference Manual. The same with Tandy computers: provided you could source the components, you could build your own Tandy 1000 or 2000 with the information in the manual.

It's an absolute crying shame that computers do not come with this level of documentation anymore. It's not even available. There are probably parts of your computer that the "intelligence community" goes to great expense to ensure you know nothing about.

Re:Post-Apocalyptic Programming by ifyoubuildit on Monday August 08, 2022 @11:51AM (#32387038)
I think you could design a device that optimizes for longevity. Build the cheapest, simplest device that can run your piece of software, and then produce lots of them.

On the simplicity side, all of the parts would be solid state, it would handle whatever power you have on hand, the inputs and outputs would allow for using whatever devices you could cobble together in a post apocalyptic world.

Then on the software side, every one of these devices could easily export a standard image that could be used to build another device.

A lot of handwaving here, but most of what we sell these days is basically disposable because that's what is incentivized. If we actually optimized for longevity, we could probably do some amazing things.

Edit: for bonus points, each device will include detailed technical documentation on how to produce the device itself from scratch. It could be a sort of rosetta computer.

Re:Post-Apocalyptic Programming by NegativeLatency on Monday August 08, 2022 @06:08PM (#32391730)
So a 6502(C)?
Re:Post-Apocalyptic Programming by AstralStorm on Monday August 08, 2022 @07:19PM (#32392324)
Don't forget the BASIC interpreter.

The problem is that making any computer smaller than a big cabinet requires large scale integration microchips, notoriously hard to make, and potentially replace.

So it's going to be closer to PDP-7. You can do quite a lot with this sort of machine in an industrial setting.

Re:Post-Apocalyptic Programming by ifyoubuildit on Tuesday August 09, 2022 @02:41AM (#32394909)
What's the life expectancy of an integrated circuit? I was thinking make tons of them and the odds are that some percentage of them would still be functional long into the future, assuming you package them up nicely.
Re:Post-Apocalyptic Programming by int_19h on Friday August 12, 2022 @12:42AM (#32434781)
OP is suggesting premaking such devices in large enough quantities that you'd just rely on them for the foreseeable future to run that legacy code.
Re:Post-Apocalyptic Programming by FartyMcFarter on Monday August 08, 2022 @09:21AM (#32385049)
The most reliable way to do this is with emulators. A full emulator is a complete description of some hardware and software combination.

If we can keep emulators working on modern hardware and OSs, we can guarantee that most old games will be playable indefinitely.

For example, if you have dosbox you can play a lot of old MS-DOS games without having an x86 CPU or DOS itself.

Re:Post-Apocalyptic Programming by jayhoon on Monday August 08, 2022 @08:45AM (#32384778)
Would a technical description in plain English (specification) and C code be sufficient to preserve a piece of software? The understanding of the specification may be different years later, but this applies even to the paintings and the works of fiction.

So, the question is not only about the preservation the actual software, but also about its correct interpretation.

Re:Post-Apocalyptic Programming by cableshaft on Monday August 08, 2022 @09:18AM (#32385021)
I think for simpler games this idea works well, yeah (and I tend to design simpler games, so I might have to start doing something like this). One of my old games, Proximity, ended up in a couple chapters on a book on an old book about Flash development, I think it was called Actionscript 3 Design Patterns.

You could make the original game pretty close from there (even though it was someone else that reverse engineered it and did it somewhat differently, it still got the job done).

But that game is pretty darn simple, just a hex grid where you draw a tile from 1-20, and wherever you place it, it'll capture tiles of an opposing team surrounding it if the tile you placed has a higher number than them. I've worked on tweaking the formula in a bunch of a ways over the years, but that's the core mechanism.

Once a game gets complicated enough it gets a lot harder to ensure that all of the nuances in the code, edge cases, hacky shit to get the game out the door, etc, so it's going to be more limited. But I'd still love to see a series that did this for more games though (I know one guy did it with the Quake source code and a couple other Id games).

Re:Post-Apocalyptic Programming by GrinningFool on Monday August 08, 2022 @09:29AM (#32385125)
> The understanding of the specification may be different years later, but this applies even to the paintings and the works of fiction.

That's an interesting parallel. But for it to be equivalent, I think it would have to be to the method of creating those paintings/works of fiction. Instead of passing down the Mona Lisa, you're passing painstakingly detailed instructions detailing how to make the Mona Lisa.

Re:Post-Apocalyptic Programming by vharuck on Monday August 08, 2022 @08:53AM (#32384828)
Sort of like how the valuable parts of math textbooks are the theorems and proofs, with the problem sets (i.e. implementations) being nice but arbitrary extras?
Re:Post-Apocalyptic Programming by jayhoon on Monday August 08, 2022 @09:26AM (#32385087)
This is an interesting angle on essentially the same problem. Can a set of theorems about the prime numbers lead another group of people to the RSA encryption, for example?

Considering that Clifford Cocks invented a similar system 4 years before Rivest, Shamir and Adleman (and even before Diffie and Hellman published their cryptosystem), the answer seems to be "yes". On the other hand, that 4 year difference means that people have to be ready for the idea, i.e., work on their "problem sets".

Re:Post-Apocalyptic Programming by qwerty456127 on Monday August 08, 2022 @09:06AM (#32384933)
I am most worried about the hardware. I am afraid we will have to start all the progress completely from scratch.
Re:Post-Apocalyptic Programming by speed_spread on Monday August 08, 2022 @10:56AM (#32386184)
IMHO, modern microcontrollers is where it's at when it comes to preserving the current technological base. They're 32 bits and relatively high powered, yet cheap and reliable enough. They don't need cooling and are robust to be fed from different power sources. If you base your software stack on, say, the ARM Cortex M4 or even M0+, you should be good for long time. You can stash a lot of spare parts and can maintain boards using simple soldering techniques.
Re:Post-Apocalyptic Programming by kevin_thibedeau on Monday August 08, 2022 @03:22PM (#32389816)
Devices running on high density flash will not be reliable long term. None of these devices have ECC to reduce the probability of catastrophic failure from accumulated bit flips.
Re:Post-Apocalyptic Programming by speed_spread on Monday August 08, 2022 @04:38PM (#32390702)
I was thinking more about devices that can be repaired by changing a failed CPU than devices that have a lower failure rate. I believe STM (and others surely) has a line of "process critical" MCUs that may have additional reliability features but these chips are built in much lower quantity and are much pricier. It's a tradeoff that would need to be evaluated for sure. Preferring external flash to on-chip storage would also help. Some ECC can also be performed in software where warranted.
Re:Post-Apocalyptic Programming by makapuf on Monday August 08, 2022 @07:15PM (#32392294)
Problem is that stm32 parts are currently in a kind of post apocalyptic state, speaking of supply chain
Re:Post-Apocalyptic Programming by elcritch on Tuesday August 09, 2022 @01:51AM (#32394608)
Many modern MCU's do have ECC flash, and I'm seeing many claiming 20 year stability. It's also common to have backup firmware images in case the primary firmware image gets corrupted. It's trivial to re-flash an MCU to fix a corrupted image.
Re:Post-Apocalyptic Programming by AeroNotix on Monday August 08, 2022 @09:01AM (#32384899)
It's called a disk snapshot.
Re:Post-Apocalyptic Programming by mtlmtlmtlmtl on Monday August 08, 2022 @09:13AM (#32384977)
I don't know about you, but I don't normally have the source code lying around on disk for:

the compiler and its dependencies

Any dynamically linked dependencies and whatever extra compilers they might need

Other potentially necessary things like build tools and source control systems

Re:Post-Apocalyptic Programming by danieldk on Monday August 08, 2022 @09:24AM (#32385078)
I am not sure if this is still the case, but the FreeBSD (and OpenBSD) CD sets and DVD used to contain the full source code of the base system and it’s easy to rebuild the system from source. BSD also works on relatively modest hardware.
Re:Post-Apocalyptic Programming by elcritch on Tuesday August 09, 2022 @01:55AM (#32394630)
There are also https://bellard.org/tcc/ and https://github.com/jserv/amacc that contain mostly complete C compilers.
Re:Post-Apocalyptic Programming by int_19h on Friday August 12, 2022 @12:50AM (#32434811)
It's not hard to arrange these days, if one really cares. I have a local mirror of Debian main + contrib + non-free packages, source + i386 + amd64 for every package. It's 200 Gb - a $20 SD card can handle that. How many copies would you need to make for at least one to last N years?