top 50 comments

sorted by: hot top controversial new old
[–] 122 points 6 months ago* (last edited 6 months ago) (3 children)

Has the same vibes as anthropic creating a C compiler which passes 99% of compiler tests.

That last percent is really important. At least that last percent are some really specific edge cases right?

Description:
When compiling the following code with CCC using -std=c23:

bool is_even(int number) {
   return number % 2 == 0;
}

the compiler fails to compile due to booltrue, and false being unrecognized. The same code compiles correctly with GCC and Clang in C23 mode.

Source

Well fuck.

  • source
  • hideshow 6 child comments
  • [–] 28 points 6 months ago

    If this wasn't 100% vibe coded, it would be pretty cool.

    A c compiler written in rust, with a lot of basics supported, an automated test suite that compiles well known c projects. Sounds like a fun project or academic work.

  • source
  • parent
  • [–] 8 points 6 months ago (2 children)

    any llm must have several C compilers in its training data, so it would be a reasonably competent almost-clone of gcc/clang/msvc anyway, right?

    is what i would have said if you didn't put that last part

  • source
  • parent
  • hideshow 4 child comments
  • [–] 2 points 6 months ago* (1 child)

    You're still correct. The thing about LLMs is that they're statistical models that output one of the most likely responses, from the list of most likely responses. It still has some randomness though. You can tune this, but no randomness is shit, and too much randomness sometimes generates stupid garbage. With a large enough output, you're statistically likely, with any randomness, to generate some garbage. A compiler is sufficiently large and complex that it's going to end up creating garbage somewhere, even if it's trained on these compilers specifically.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 4 points 6 months ago*

    The incredible thing is this is actually the result of an explicit design decision.

    The compiler accepts most GCC flags. Unrecognized flags (e.g., architecture- specific -m flags, unknown -f flags) are silently ignored so ccc can serve as a drop-in GCC replacement in build systems.

    They're so committed to vibing that they'd prefer if the compiler just does random shit to make it easier to shove it haphazardly into a build pipeline.

  • source
  • parent
  • [–] 77 points 6 months ago

    The error is ~1/log(x), for anyone interested.

  • source
  • [–] 67 points 6 months ago (3 children)
  • [–] 42 points 6 months ago* (1 child)

    LLMs belong to the same category. Seemingly right, but not really right.

  • source
  • hideshow 2 child comments
  • [–] 35 points 6 months ago* (2 children)

    My favorite part of this is that they test it up to 99999 and we see that it fails for 99991, so that means somewhere in the test they actually implemented a properly working function.

  • source
  • hideshow 4 child comments
  • [–] 26 points 6 months ago (1 child)

    No, it's always guessing false and 99991 is prime so it isn't right. This isn't the output of the program but the output of the program compared with a better (but probably not faster) isprime program

  • source
  • parent
  • hideshow 2 child comments
  • [–] 36 points 6 months ago (2 children)

    Yes, that's what I said. They wrote another test program, with a correct implementation of IsPrime in order to test to make sure the pictured one produced the expected output.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 43 points 6 months ago (2 children)

    Plot twist: the test just checks to see if the input exists in a hardcoded list of all prime numbers under 100000.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 21 points 6 months ago (1 child)

    I mean people underestimate how usefull lookup tables are. A lookup table of primes for example is basically always just better except the one case where you are searching for primes which is more maths than computer programming anyways. The modern way is to abstract and reimplement everything when there are much cheaper and easier ways of doing it.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 4 points 6 months ago (1 child)

    more maths than computer programming anyways

    Computer programming is a subset of maths and was invented by a mathematition, originally to solve a maths problem...

  • source
  • parent
  • hideshow 2 child comments
  • [–] 3 points 6 months ago (4 children)

    Yeah but they slowly develop to be their own fields. You wouldnt argue that physics is math either. Or that chemistry could technically be called a very far branch of philosophy. Computer programing, physics, etc are the applied versions of math. You are no longer studying math, you are studying something else with the help of math. Not that it matters much, just makes distinguising between them easier. You can draw the line anywhere but people do generally have a somewhat shared idea of where that lies.

  • source
  • parent
  • hideshow 5 child comments
  • load more comments (1 reply)
  • [–] 25 points 6 months ago*

    you can increase its accuracy by changing the parameter type to long

  • source
  • [–] 17 points 6 months ago

    I have seen that algorithm before. It's also the implementation of an is_gay(Image i) algorithm with around 90% accuracy.

  • source
  • [–] 15 points 6 months ago (3 children)

    I'm struggling to follow the code here. I'm guessing it's C++ (which I'm very unfamiliar with)

    bool is_prime(int x) {
        return false;
    }
    

    Wouldn't this just always return false regardless of x (which I presume is half the joke)? Why is it that when it's tested up to 99999, it has a roughly 95% success rate then?

  • source
  • hideshow 6 child comments
  • [–] 35 points 6 months ago (1 child)

    I suppose because about 5% of numbers are actually prime numbers, so false is not the output an algorithm checking for prime numbers should return

  • source
  • parent
  • hideshow 2 child comments
  • [–] 11 points 6 months ago (1 child)

    Oh I'm with you, the tests are precalculated and expect a true to return on something like 99991, this function as expected returns false, which throws the test into a fail.

    Thank you for that explanation

  • source
  • parent
  • hideshow 2 child comments
  • [–] 14 points 6 months ago* (3 children)

    If you scaled it based on the size of the integer you could get that up to 99.9% test accuracy. Like if it's less than 10 give it 50% odds of returning false, if it's under 50 give it 10% odds, otherwise return false.

  • source
  • hideshow 5 child comments
  • load more comments (1 reply)
    [–] 10 points 6 months ago (1 child)

    It has actually 100% accuracy

  • source
  • hideshow 2 child comments
  • [–] 9 points 6 months ago

    If you think this is bad and not nearly enough accuracy to be called correct, AI is much worse than this.

    It's not just wrong a lot of times or hallucinates but you can't pinpoint why or how it produces the result and if you keep putting the same data in, the output may still vary.

  • source
  • [–] 7 points 6 months ago

    100% of the time, baby =)

  • source
  • [–] 6 points 6 months ago

    Pssh, mine uses a random number generator for odd numbers to return true 4% of the time to achieve higher accuracy and a bettor LLM metaphor

  • source
  • load more comments
    view more: next ›