News for hackers. Stuff that matters.
Re:Why Does Software Rot? by jussaskin on Friday June 24, 2016 @04:27PM (#11973184)
Software rots if you can no longer set up the exact tool chain and environment (compiler, build tool, OS version, external database, etc) required to build and run it. Even interpreted languages suffer from this problem as features are subtlely changed - by design or accident. It doesn't matter if your project is using an ancient version of VC++ or a two year old version of NodeJS. If it doesn't keep up with the latest releases of the tools then it's already got one foot in the grave.
Re:Why Does Software Rot? by codemac on Friday June 24, 2016 @05:49PM (#11973766)
I think this is an interesting argument for something like scheme (r5rs or r7rs-small) where you could hypothetically implement an interpreter later for the same code base with much less trouble.

Mind you, it probably won't perform well or do everything, but you can imagine it'd be easier than implementing an entire VM.

Unless it's video games.

People will write mountains of software to play an old video game.

Re:Why Does Software Rot? by joe_the_user on Friday June 24, 2016 @05:42PM (#11973725)
Your claim does not really follow the standard meaning.

Bit Rot is usually defined as all the ways that software can appear to stop serving it's function despite remaining the same, in the sense of being the same bits (or bytecode or interpreted code) run by the same computer.

"the software does not actually decay, but rather suffers from a lack of being responsive and updated with respect to the changing environment in which it resides."

See: https://en.wikipedia.org/wiki/Software_rot

Edit: Not being able to recreate or modify a given piece of software would an example of the bit of your tools/environment and this is one (but the only) source of bitrot in a piece of code.

Re:Why Does Software Rot? by beat on Friday June 24, 2016 @04:45PM (#11973318)
Some smart dude, don't remember who, said that every single line of code becomes technical debt the moment it is written.
Re:Why Does Software Rot? by bostik on Friday June 24, 2016 @05:17PM (#11973549)
Legacy software is the code you wrote before lunch.[0]

0: http://www.russmiles.com/essais/dont-think-legacy-software-t...

Re:Why Does Software Rot? by beat on Friday June 24, 2016 @05:23PM (#11973586)
That's not the one I was thinking of, but it's a similar sentiment.
Re:Why Does Software Rot? by crucini on Friday June 24, 2016 @07:27PM (#11974287)
But strstr() doesn't seem rotten or "legacy" in a bad way.
Re:Why Does Software Rot? by xyzzyz on Friday June 24, 2016 @10:09PM (#11974858)
strcpy() does, though.
Re:Why Does Software Rot? by kazinator on Friday June 24, 2016 @10:56PM (#11974978)
What's wrong with strcpy?

In a nutshell, we can only safely use it if we somehow know that the source string fits into the destination buffer. Those situations are few: basically, they involve fixed-length string literals being moved into buffers that are "obviously" larger. E.g. some widget_t object has a char name[256] field, and we initialize it by default with strcpy(new_widget->name, "<unnamed widget>"), or some bullshit like that. The literal is way shorter than 256 and nobody in their right mind will ever make it that long, or shorten [256] in widget_t so that this literal doesn't fit.

In situations when we don't know the length of the source string, there are two cases: it is going into some buffer that is already allocated, or else we will be allocating one. In either situation, we must measure the length of the source string, to test whether it fits or to determine how much to allocate for it.

In the case when the string doesn't fit into the target buffer, we cannot use strcpy, obviously, since it copies the entire string. We use some truncating-copying function, or we handle the situation in some other way (diagnose the problem and abort or whatever).

In the case when we allocate, because we have calculated the length, we still should not use strcpy to finally copy the string. We should use memcpy, because memcpy doesn't wastefully examine every byte to see whether it is null.

So the opportunities for a correct, non-wasteful use of strcpy are few.

Re:Why Does Software Rot? by kd5bjo on Saturday June 25, 2016 @06:10AM (#11975854)
You're correct about the problems, and I would always recommend strncpy over strcpy for safety, but it's not quite as limited as you portray: You only need to ensure an upper bound on the string length that will fit into your destination buffer. In addition to literals, this can also be guaranteed by copying a string that's already stored in a container that's smaller than the target, such as a fixed-size buffer or database field.
Re:Why Does Software Rot? by kazinator on Saturday June 25, 2016 @01:32PM (#11977130)
strncpy is strcpy's daft cousin that wastefully writes extra null characters---except when there is no room; then it neglects to null-terminate at all.

strncpy was not needed even in C90, because of sprintf, which is less clumsy to use, doing everything in one step:

  char array[64];
  sprintf(array, "%.63s", some_string);
If we replace the 63 with * , we can pass a dynamic size:

  sprintf(array, "%.*s", (int) sizeof array - 1, some_string);
Re:Why Does Software Rot? by gohrt on Saturday June 25, 2016 @01:38AM (#11975376)
Re:Why Does Software Rot? by kazinator on Monday June 27, 2016 @03:24PM (#11988741)
People say that gets is fundamentally broken as an API, beyond repair.

However, gets could have been "rescued" in C by requiring every implementation to publish a constant, say in <limits.h>, which indicates a maximum of how many bytes (including null terminator) the gets function will place into the target buffer, and ensuring that gets observes this constant.

Indeed, evidently, there was talk of this, and supposedly Doug Gwyn proposed that simply BUFSIZ be re-used for this purpose.

With such a constant in place, programs using gets could be wrenched out of the jaws of undefined behavior by sizing the input array according to that constant, ensuring that there cannot be overflow.

Rather than introducing this requirement, in the end the function was simply removed from the language.

Re:Why Does Software Rot? by Vintila on Saturday June 25, 2016 @02:12AM (#11975441)
Similarly, there are no bugs in code that isn't written.
Re:Why Does Software Rot? by ArkyBeagle on Friday June 24, 2016 @04:36PM (#11973268)
Through the miracle of virtual machines, this is much less so. VMs are the NAT of computer systems.
Re:Why Does Software Rot? by nickpsecurity on Saturday June 25, 2016 @11:46AM (#11976707)
As jussaskin said, it can happen to them too. For example, VM/370 was among first virtualization schemes that could do all kinds of things PC/server virtualization bragged on later. Many key apps/OS's might be put in it. Yet, you'd be hard-pressed to run one of those with today's IT budgets if you couldn't afford a mainframe. Likewise, quite a lot of PC virtualization vendors came and went. The survivors occasionally have compatibility issues or corporations start going in different directions with less support of the older product. The product itself is often tied to a specific OS or HW combination that might go away.

One can use virtualization to help future-proof apps. IBM's System/38 (later AS/400, iSeries, and IBM i) did this for decades. However, to be fully future-proof (esp for vendor level), the virtualization SW/HW solution itself needs to be immune to the problem. That means legally, easily-cloned HW with same for software and virtualization layer. Closest thing maybe NOVA microhypervisor on Loongson-style OSS CPU with x86 emulation if it's x86 apps. RISC-V w/ virtualization support otherwise.

Guess what future-proof virtualization all the mainstream approaches aren't using, though? ;)

Re:Why Does Software Rot? by hueving on Friday June 24, 2016 @10:02PM (#11974838)
If devs have to download a VM running an old OS with old tooling, the barrier to entry is getting quite high. I wouldn't touch an OSS project that made me do that, I would assume it was effectively dead.
Re:Why Does Software Rot? by imtringued on Saturday June 25, 2016 @07:07AM (#11975947)
It would be dead without the VM anyway.
Re:Why Does Software Rot? by jussaskin on Friday June 24, 2016 @04:44PM (#11973315)
Less so, I agree. But give it time - older VM image and container formats will probably rot as well.
Re:Why Does Software Rot? by smilekzs on Friday June 24, 2016 @04:47PM (#11973344)
VM formats are easier to migrate than the actual software they run.

On the other hand this is a valid concern for containers.

Re:Why Does Software Rot? by specialist on Saturday June 25, 2016 @10:08AM (#11976355)
Extending the digital entropy analogy: decay rate, half-lives.
Re:Why Does Software Rot? by johannes1234321 on Friday June 24, 2016 @07:50PM (#11974397)
While for current software, which depends to at least some degree on remote services (cloud?) This won't help at all.
Re:Why Does Software Rot? by jussaskin on Friday June 24, 2016 @04:49PM (#11973352)
Even though the VM image and tooling may still be runnable, the world around it with which it must interact continues to evolve and can leave your software obsolete.
Re:Why Does Software Rot? by ArkyBeagle on Friday June 24, 2016 @04:54PM (#11973380)
One for one thing, another for another.
Re:Why Does Software Rot? by jussaskin on Friday June 24, 2016 @05:09PM (#11973501)
Fair enough.
Re:Why Does Software Rot? by specialist on Saturday June 25, 2016 @10:06AM (#11976351)
Digital entropy.

Preserving order requires constant energy investment.

Just an analogy, but I find it useful.

Re:Why Does Software Rot? by wwweston on Saturday June 25, 2016 @12:48PM (#11976930)
I think the big question with the storage space we've come into is... why don't we have all the toolchains/environments available? Why isn't having multiple versions of every dependency just part of how we do things now?