Best AI for coding / head-to-head

Gemini 3.1 Pro Preview vs GLM 5.2for coding

The verdict

GLM 5.2 wins, 9288

Same 18 coding tasks, marked blind by three rival labs. GLM 5.2 took 7 tasks, Gemini 3.1 Pro Preview took 3, 8 tied. Tested 16 Aug 2026.

Where they differed most

The task — Infinite useEffect

Explain precisely why this React effect loops forever, then give the fixed version. const [items, setItems] = useState([]); useEffect(() => { fetch('/api/items').then(r => r.json()).then(setItems); }, [items]);

### Why it loops forever

The infinite loop occurs due to a combination of **React's dependency tracking** and **JavaScript's reference equality**. 

Here is the precise step-by-step breakdown of the loop:

1. **Initial Render:** The component mounts, and `items` is initialized to an empty array `[]`.
2. **Effect Runs:** Because it's the first render, the `useEffect` runs and triggers the `fetch` request.
3. **State Update:** The fetch resolves, parses the JSON, and calls `setItems()` with the fetched array.
4. **Re-render:** Updating the state…
GLM 5.210/10
### Why it loops forever

The infinite loop happens because of a combination of two things: the effect updates the state it is listening to, and JavaScript arrays are compared by reference, not by value.

Here is the precise step-by-step breakdown:

1. **Initial Render:** `items` is initialized to `[]`.
2. **First Effect Run:** Because `items` is in the dependency array, the effect runs. It fetches data from the API.
3. **State Update:** The fetch resolves, returning a JSON array (e.g., `[1, 2, 3]`). `setItems([1, 2, 3])` is called.
4. **Re-ren…

Task by task

TaskGemini 3.1 Pro PreviewGLM 5.2
Duration parser88
Find the bug910
SQL without window functions1010
Infinite useEffect810
Typed debounce98
Leftmost binary search910
Security review99
Safe migration87
Fix the code not the test1010
Race condition99
Retry with backoff910
Recursive type1010
Bash one-liner810
Explain and cost109
Regex with limits88
Callback to async810
Diagnose from a trace88
Idempotency89

Full receipts: Gemini 3.1 Pro Preview, GLM 5.2 · judges claude-sonnet-5, gpt-5.6-terra, grok-4.5

Questions people ask

Which is better for coding: Gemini 3.1 Pro Preview or GLM 5.2?

GLM 5.2 — it scored 92/100 against 88/100 on our 18-task coding suite, winning 7 tasks to 3 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 · Gemini 3.1 Pro Preview vs GPT-5.6 Luna · GLM 5.2 vs GPT-5.6 Sol · Gemini 3.1 Pro Preview vs GPT-5.6 Sol · GLM 5.2 vs GPT-5.6 Terra · Gemini 3.1 Pro Preview vs GPT-5.6 Terra

Full ranking: Best AI for coding · model pages: Gemini 3.1 Pro Preview, GLM 5.2