Best AI for coding / head-to-head
Claude Opus 4.8 vs Gemini 3.1 Pro Previewfor coding
Claude Opus 4.8 wins, 89–88
Same 18 coding tasks, marked blind by three rival labs. Claude Opus 4.8 took 8 tasks, Gemini 3.1 Pro Preview took 2, 8 tied. Tested 16 Aug 2026.
Where they differed most
Write a debounce function in TypeScript that preserves the argument types of the wrapped function, returns a function with a .cancel() method, and does not use 'any'. Explain in one sentence why the naive generic signature loses type information.
# Debounce Function
```typescript
type Debounced<TArgs extends unknown[]> = {
(...args: TArgs): void;
cancel(): void;
};
function debounce<TArgs extends unknown[]>(
fn: (...args: TArgs) => unknown,
delay: number
): Debounced<TArgs> {
let timer: ReturnType<typeof setTimeout> | undefined;
const debounced = (...args: TArgs): void => {
if (timer !== undefined) {
clearTimeout(timer);
}
timer = setTimeout(() => {
timer = undefined;
fn(...args);
}, delay);
};
debounced.cancel = (): void => {
if…```typescript
function debounce<This, Args extends unknown[]>(
func: (this: This, ...args: Args) => void,
wait: number
): ((this: This, ...args: Args) => void) & { cancel: () => void } {
let timeoutId: ReturnType<typeof setTimeout> | null = null;
const debounced = function (this: This, ...args: Args) {
if (timeoutId !== null) {
clearTimeout(timeoutId);
}
timeoutId = setTimeout(() => {
func.apply(this, args);
}, wait);
};
debounced.cancel = function () {
if (timeoutId !== null) {
clearTime…Task by task
| Task | Claude Opus 4.8 | Gemini 3.1 Pro Preview |
|---|---|---|
| Duration parser | 9 | 8 |
| Find the bug | 10 | 9 |
| SQL without window functions | 10 | 10 |
| Infinite useEffect | 10 | 8 |
| Typed debounce | 5 | 9 |
| Leftmost binary search | 10 | 9 |
| Security review | 9 | 9 |
| Safe migration | 8 | 8 |
| Fix the code not the test | 10 | 10 |
| Race condition | 9 | 9 |
| Retry with backoff | 9 | 9 |
| Recursive type | 10 | 10 |
| Bash one-liner | 9 | 8 |
| Explain and cost | 10 | 10 |
| Regex with limits | 9 | 8 |
| Callback to async | 9 | 8 |
| Diagnose from a trace | 9 | 8 |
| Idempotency | 6 | 8 |
Full receipts: Claude Opus 4.8, Gemini 3.1 Pro Preview · judges gemini-3.1-pro-preview, gpt-5.6-terra, grok-4.5
Questions people ask
Which is better for coding: Claude Opus 4.8 or Gemini 3.1 Pro Preview?
Claude Opus 4.8 — it scored 89/100 against 88/100 on our 18-task coding suite, winning 8 tasks to 2 with 8 tied. Every answer was marked blind by three judges from three rival AI labs.
How was this tested?
Both models answered the identical published coding tasks. Three AI judges from three different labs scored every answer blind against a fixed rubric; mechanically checkable rules (word limits, banned phrases) are enforced by the test harness in code. The raw outputs and judge verdicts are downloadable.
More coding head-to-heads: Claude Opus 4.8 vs GPT-5.6 Luna · Gemini 3.1 Pro Preview vs GPT-5.6 Luna · Claude Opus 4.8 vs GPT-5.6 Sol · Gemini 3.1 Pro Preview vs GPT-5.6 Sol · Claude Opus 4.8 vs GPT-5.6 Terra · Gemini 3.1 Pro Preview vs GPT-5.6 Terra
Full ranking: Best AI for coding · model pages: Claude Opus 4.8, Gemini 3.1 Pro Preview