DeepSeek R1 First Impressions
DeepSeek R1 is almost as good as me at belabored exhaustive analysis and application of C89 rules. For practical purposes, it's equally good.
I asked: "How would you implement zig-zag encoding in strictly portable C89?" It was spitting out thinking output for at least a minute, but it got a basically-perfect solution on first try:
unsigned int zigzag_encode(int n) {
return (((unsigned int)n << 1) ^ ((n < 0) ? -1 : 0);
}
It also provided a `zigzag_encode_long`.
Note that this code will optimize on modern C compilers to the best assembly you could write. There is no branch in the produced code with even just `-O1` (`clang`, `gcc`), the branch is how we portably tell the compiler the right idea.
The only thing DeepSeek did "wrong" vs the above, was redundantly add an `(unsigned int)` cast to the `-1`. I mentioned this as I would to a person: that the usual arithmetic conversions would take care of it at the `^`. It reasoned the rest on its own: yes, because the left operand is already at least an unsigned int, so integer promotion will make the left side an unsigned int as well.
We talked at length about how we can prove that the above is portable to the most pathological C89-conformant implementations. It kept taking longer to "think", but it didn't show any weakness until the very last question.
I asked it to help me rigorously prove if the maximum value of unsigned integers is required by the C standard to be a Mersenne number (2^n-1). To have all bits one, that is.
What if an implementation just decided to arbitrarily not use one or more of the top values? I.e., why not `#define UINT_MAX 0xFFFFFFFE`?
DeepSeek R1 didn't seem to conceive of this possibility until I made it explicit. (But it did a great job of ruling out all others.)
Finally, it gave a longer, non-trivial argument, which I don't find convincing. Basically, it seemed to be saying that since integers used "pure binary representation", and every value bit could be either one or zero, well then the maximum value always has all value bits one - in other words, it seemingly assumed that just because each value bit individually was allowed to be one or zero, the possibility of them all being one at once must be both legal and used to represent a distinct value.
I see a shorter argument, which follows directly from what the standard does say: C89 has two definitions of `~`:
subtract from maximum value of that unsigned integer type.
The only way both can be true at once is if the maximum value is all value bits one. DeepSeek R1 agreed.
So what does this all mean?
This is an insane level of competence in an extremely niche field. Less than a year ago I tested LLAMA on this, and LLAMA and I didn't even get past me hand-holding it through several portability caveats. DeepSeek R1 and I just had a full-blown conversation that most devs I've talked to couldn't have with me. DeepSeek R1 managed to help me think in an extremely niche area where I'm basically a world-class expert (since the area in question is C89 portability, "world-class expert" is derogatory, but still).
If it's this good in one domain, it's this good in most domains. I bet it can do comparably well in Python, Go, JavaScript, C++, and so on.
In other words, it's already better than many devs in areas like this. I've seen plenty of devs making 6-figure USD salaries who didn't bother to know any of their day job tech stack this deeply. There's a market adjustment coming. Knowledge and expertise are about to become dirt-cheap commodities.
AI will eat current software dev jobs even faster than even I thought - and I already thought it would be sooner than most expect. Meanwhile, much of the industry is busy rationalizing from human intuition and ignorance that it just can't happen.
For years I've thought that the future is human devs delegating to teams of AI. That future is almost upon us, and this AI is good enough that I will be seriously experimenting with making that future a reality. I think if you hack together the right script to hook it up to a sandbox with dev tools, and prompt it just right... you might already be able to get this thing to actually do useful dev work.