Hacker News new | ask | show | jobs
by hackthefender 1769 days ago
> It is not even theoretically possible to write a piece of software which will behave the same no matter how and where it is run.

Can you elaborate on that? I'm sure it's both true and false depending on your definition of "how and where it is run," but wondering what you had in mind specifically.

3 comments

As for the "theoretically" part, it is enough to prove that at least one such a system exists that will yield another result than expected. There could be various reasons, from human/software errors to hardware errors like memory bit flips. Since we know these do exist, it is not even theoretically possible to write a piece of software which will behave the same no matter how and where it is run, although it is certainly possible to write it in such a way that it will behave the same in a vast majority of cases.
I'd say that containers are actually something that makes Unix shell a lot more valuable and predictable, and one reason that I'm working on https://www.oilshell.org/ .

A container is basically a "virtualenv" for shell, and it's honestly better than that because:

- it's more general (it isolates every language, not just Python), and

- not even bigger (e.g. an Alpine Linux container is not that much bigger than the Python install in every virtualenv!)

Traditionally you do indeed have the problem that copying a shell script from one machine to another basically guarantees you nothing about how it will work. These days we deploy containers, which solve the problem, and that's why shell is used so much in the cloud (e.g. anything with Github Actions has a boatload of shell)

Even more on that: https://www.oilshell.org/blog/2021/07/cloud-review.html

I remember reading (sorry, can't remember the source) that it's been proven mathematically that there's no way to write code which will run the same on any Turing-equivalent processor. Obviously that's not saying much since Bash is pretty far abstracted from the CPU, it's more of a caveat that I've hardly ever seen a discussion about Bash which doesn't involve at least one "well, actually" comment about how the suggested code doesn't do what the autor purports on some incredibly niche platform or with some highly unusual configuration.