I overpowered AI by inventing 'Brilliant' code by AI opinion itself

Published: (March 7, 2026 at 04:35 PM EST)
3 min read
Source: Dev.to

Source: Dev.to

Background

I started by describing a simple API client and then began experimenting with mixins. I wanted to create my own mixins library that would be faster than ts-mixer. After setting up benchmarks, I grew tired of hours of testing and turned to a large language model (LLM) for help.

Experiment with AI

I asked the AI to make the implementation as fast as possible and set up proper tests and benchmarks so the AI could “deprive me of my job.” While I was out buying bread, the model iterated on the code. It did improve performance, but it also suggested sacrificing some specifications and correctness—something I found unacceptable.

Repeated attempts showed the AI cycling through a few similar implementations, ignoring my notes, and repeatedly introducing and then fixing mistakes. Eventually I gave up on the AI and continued the work myself, spending many more hours without any additional bread.

My Own Implementation

With a fresh mindset the next day, I built a CompositeMap in just 40 lines that is extremely fast. The map treats key ordering specially: [A, B] is not equal to [B, A]. Existing libraries and a TC39 proposal for composite keys exist, but they are not fast enough for my needs.

How It Works

  • Each object receives an incremental ID.
  • All keys are hashed into a bitmask, making look‑ups super fast and order‑insensitive.
  • The bitmask technique is common in flag handling and game development.
  • If the number of mixins exceeds the 32 bits of a standard integer, the implementation escalates to BigInt, which remains faster than other libraries.
  • In practice, having more than 32 mixin variations is rare, so the solution works well for most cases.

The source code is available here:

Reflections on AI

The AI praised the final code as “brilliant” and called it a “Performance Masterclass,” yet it could not generate the solution on its own. This illustrates that AI, trained on past human work, cannot invent truly novel approaches that no one has documented.

  • Can you be better than AI? Yes—human creativity and deep understanding still surpass what current LLMs can produce.
  • Is coding skill replaceable? You become replaceable only if you cannot code without relying on an LLM.
  • Did I save time using the LLM? In this case, no. Prompting the model required long, exhausting sessions, and I could have reached the result faster by coding directly.

Conclusion

While AI can assist with incremental improvements, groundbreaking performance gains often still require human insight. Combining practical experimentation with a bit of humor (memes) can make these “serious” topics more engaging.

0 views
Back to Blog

Related posts

Read more »