Best AI for coding / head-to-head

Claude Opus 4.8 vs GLM 5.2for coding

The verdict

GLM 5.2 wins, 9289

Same 18 coding tasks, marked blind by three rival labs. GLM 5.2 took 5 tasks, Claude Opus 4.8 took 5, 8 tied. Tested 16 Aug 2026.

Where they differed most

The task — Typed debounce

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…
Here is the TypeScript debounce function:

```typescript
function debounce<A extends unknown[]>(
  func: (...args: A) => unknown,
  wait: number
): ((...args: A) => void) & { cancel: () => void } {
  let timeoutId: ReturnType<typeof setTimeout> | undefined;

  const debounced = ((...args: A): void => {
    if (timeoutId !== undefined) {
      clearTimeout(timeoutId);
    }
    timeoutId = setTimeout(() => func(...args), wait);
  }) as ((...args: A) => void) & { cancel: () => void };

  debounced.cancel = () => {
    if (timeoutId !== undefined)…

Task by task

TaskClaude Opus 4.8GLM 5.2
Duration parser98
Find the bug1010
SQL without window functions1010
Infinite useEffect1010
Typed debounce58
Leftmost binary search1010
Security review99
Safe migration87
Fix the code not the test1010
Race condition99
Retry with backoff910
Recursive type1010
Bash one-liner910
Explain and cost109
Regex with limits98
Callback to async910
Diagnose from a trace98
Idempotency69

Full receipts: Claude Opus 4.8, GLM 5.2 · 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 GLM 5.2?

GLM 5.2 — it scored 92/100 against 89/100 on our 18-task coding suite, winning 5 tasks to 5 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: GLM 5.2 vs GPT-5.6 Luna · Claude Opus 4.8 vs GPT-5.6 Luna · GLM 5.2 vs GPT-5.6 Sol · Claude Opus 4.8 vs GPT-5.6 Sol · GLM 5.2 vs GPT-5.6 Terra · Claude Opus 4.8 vs GPT-5.6 Terra

Full ranking: Best AI for coding · model pages: Claude Opus 4.8, GLM 5.2