Best AI for coding / head-to-head
Gemini 3.1 Pro Preview vs GLM 5.2for coding
GLM 5.2 wins, 92–88
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
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…
### 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
| Task | Gemini 3.1 Pro Preview | GLM 5.2 |
|---|---|---|
| Duration parser | 8 | 8 |
| Find the bug | 9 | 10 |
| SQL without window functions | 10 | 10 |
| Infinite useEffect | 8 | 10 |
| Typed debounce | 9 | 8 |
| Leftmost binary search | 9 | 10 |
| Security review | 9 | 9 |
| Safe migration | 8 | 7 |
| Fix the code not the test | 10 | 10 |
| Race condition | 9 | 9 |
| Retry with backoff | 9 | 10 |
| Recursive type | 10 | 10 |
| Bash one-liner | 8 | 10 |
| Explain and cost | 10 | 9 |
| Regex with limits | 8 | 8 |
| Callback to async | 8 | 10 |
| Diagnose from a trace | 8 | 8 |
| Idempotency | 8 | 9 |
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