DEV Community

Mishka
Mishka

Posted on • Originally published at Medium

3 Code Snippets that Changed History

Three code snippets which I think are truly fascinating and have changed the world in recent history.

I don't know about you, but back in school when we would study History it was the history of civilizations. From Alexander the Great to the rise and fall of the British Empire, I learned all there was about great leaders of the past and how each era impacted history.

But the inventors who really changed the way we live were just names to memorize in Science class. Graham Bell invented the telephone in 1876. Thomas Edison built the first lightbulb in 1879. The Wright Brothers pioneered aviation in 1903. All fascinating people that each deserved a class of their own.

However in recent history, some big defining moments that have changed us aren't even physical inventions, but just a few lines of code. While there are so many that have impacted our reality, three in particular stood out to me.

1. Apollo 11's BAILOUT Code (1969)

POODOO    INHINT\
    CA  Q\
    TS  ALMCADR

    TC  BANKCALL\
    CADR  VAC5STOR  # STORE ERASABLES FOR DEBUGGING PURPOSES.

    INDEX  ALMCADR\
    CAF  0\
ABORT2    TC  BORTENT

OCT77770  OCT  77770    # DONT MOVE\
    CA  V37FLBIT  # IS AVERAGE G ON\
    MASK  FLAGWRD7\
    CCS  A\
    TC  WHIMPER -1  # YES.  DONT DO POODOO.  DO BAILOUT.

    TC  DOWNFLAG\
    ADRES  STATEFLG

    TC  DOWNFLAG\
    ADRES  REINTFLG

    TC  DOWNFLAG\
    ADRES  NODOFLAG

    TC  BANKCALL\
    CADR  MR.KLEAN\
    TC  WHIMPER

The BAILOUT code built in the the Apollo Guidance Computer would get triggered if there was a risk of running out of space. By scheduling less important operations, it would keep more critical processes up and running.

Interestingly, it was triggered 3 times before Neil Armstrong safely landed and famously said, "the Eagle has landed," without him even knowing.

Reference

2. Bitcoin (2009)

double AttackerSuccessProbability(double q, int z)\
{\
    double p = 1.0 - q;\
    double lambda = z * (q / p);\
    double sum = 1.0;\
    int i, k;\
    for (k = 0; k <= z; k++)\
    {\
        double poisson = exp(-lambda);\
        for (i = 1; i <= k; i++)\
            poisson *= lambda / i;\
        sum -= poisson * (1 - pow(q / p, z - k));\
    }\
    return sum;\
}

This piece of code is not only why Bitcoin exists, but it's also the reason why millions trust it. It makes the chances of somebody attacking and taking over the network extremely unlikely.

This code essentially gave birth to the era of cryptocurrency.

Reference

3. Google's PageRank Algorithm (1996)

import numpy as np

def pagerank(M, num_iterations=100, d=0.85):\
    N = M.shape[1]\
    v = np.random.rand(N, 1)\
    v = v / np.linalg.norm(v, 1)\
    iteration = 0\
    while iteration < num_iterations:\
        iteration += 1\
        v = d * np.matmul(M, v) + (1 - d) / N\
    return v

Google's PageRank algorithm to "organize the world's information" put it on the map. Nobody could've imagined the way it would revolutionize the way we browse the internet and the giant of a company it would soon become. Today Google is the world's 3rd most valuable company at $315.5 billion.

All because of a search algorithm. Imagine that...

Reference


If you found this interesting, check out other great code snippets in history at:
https://www.thiscodeworks.com/tag/historicalcode

Top comments (0)