Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
"all the programs that could be written have already been written"
2 points by riazrizvi on Feb 20, 2012 | hide | past | favorite | 1 comment
1. Two colleagues offered the above chestnut as rationale for not writing new code, and instead always finding/reusing existing code.

2. A program = a set of mappings between input and output states.

ie. given input states {00,01,10,11} and the same output states, the set of possible programs with this signature can be composed like this:

program1 = 00 mapped to 00 only and nothing else defined, i.e. {(00,00)}

program2 = {(00,00),(00,01)} and nothing else defined ... etc. This sequence is called a Powerset

3. Given N input states, and M output states, the number of possible input-output mappings = NM

4. Given input-output mappings NM, the number of possible programs with this signature = the Powerset of NM, which has size = 2^NM (2 to the power of NM)

5. Consider a trivial program that merely takes and returns a single ASCII character (4 bits long). Number of possible such programs = 2^(128*128) = 10^77

6. Number of atoms in observable universe (is of the order of) = 3.2 x 10^79 = (atoms in typical star) X (stars in typical galaxy) X (galaxies in observable universe) = (1x10^57) X (400x10^9) X (80x10^9)

7. Given the range of interesting programs goes far beyond this trivial example, the probability that all the programs that could be written have already been written = 0



Well, they may have been written already, but there may be pitfalls beyond combinatorics (possibly exaggerated for dramatic effect): one part of the code you'd like to reuse works wonders, but it is written as an all-too-clever abuse of PHP4, under an unclear license; another is a closed-source library which may or may not exist for all your target platforms; and yet another is a custom-license Python 2.6 script. Now how do you reuse those; and btw what license will you use for the result? This is not Pokemon, where you just need to "catch 'em all" and you're set; integrating the pieces together could be the most expensive part.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: