Hey folks! I think this request is right up this comm’s alley. I’m sure that we all know bogo sort but, what other terrible/terribly inefficient algorithms, software architecture, or design choices have you been horrified/amused by?

I, sadly, lost a great page of competing terrible sorting algorithms, but I’ll lead with JDSL as a terrible (and terribly inefficient) software architecture and design. The TL;DR is that a fresh CS guy got an internship at a company that based its software offering around a custom, DSL based on JSON that used a svn repo to store all functions in different commits. The poor intern had a bad time due to attempting to add comments to the code, resulting in customer data loss.

  • sus@programming.dev
    link
    fedilink
    arrow-up
    12
    ·
    edit-2
    7 months ago

    slow inverse square root:

    float slowinvsqrt(float x)
    {
        const long accuracy = 100000000;    // larger number = better accuracy
        if (x <= 0.0f) {
            return NAN;
        }
        if (x == 1.0f) {
            return 1.0f;
        }
        if (x < 1.0f) {
            return 1.0f / slowinvsqrt(1.0f/x);
        }
    
        int max_power = log(accuracy) / log(x);
        long pow1 = pow(x, max_power - 1);
        long pow2 = pow(x, max_power);
        double current = 1.0;
        double previous = 1.0;
    
        for (long i = 0; i<10*accuracy; i++) {
            current = sin(current);
            if (i == pow1) {
                previous = current;
            }
            if (i == pow2) {
                return current / previous;
            }
        }
    }