Abstract
Code and reasoning recently exhibit a mutually reinforcing relationship in large language models (LLMs): Code is abstract, modular, highly structured and has strong logic, guiding reasoning in training and inference. While reasoning translates high-level goals into small executable steps, enable more sophisticated code intelligence, solving real-world challenging software development problems. In this study, we examine how code serves as a structured medium for enhancing reasoning - providing verifiable execution paths, enforcing logical decomposition, and enabling runtime validation, and how advances in reasoning have transformed code intelligence from basic completion to sophisticated agent - enabling models to tackle complex software engineering tasks through deliberate planning and systematic debugging. Finally, we identify key challenges and propose future research directions may deepen the synergy, ultimately advancing LLM performance in both complex reasoning and code intelligence.
Introduction
While LLMs have shown remarkable capabilities in both natural language and programming, the intrinsic link between these two domains is often treated as a happy accident of scale. Researchers have noticed that models trained on code perform significantly better at non-coding tasks like mathematical deduction and logical inference. This survey addresses the lack of a systematic framework for understanding this "code-reasoning synergy," exploring how code representations influence reasoning and how advanced reasoning, in turn, reshapes code intelligence systems.
Taxonomy of the Interplay
The research landscape is categorized into two primary directions: Code-enhanced Reasoning ("Code to Think") and Reasoning-enhanced Code Intelligence ("Think to Code").
- Code-enhanced Reasoning: This involves using code as a medium for logic. Key techniques include Program-aided Reasoning, which translates word problems into code (e.g., Program-of-Thoughts) to offload computation to a deterministic interpreter, and Code-centric Training, which incorporates execution traces into pre-training to bake structured logic into model weights.
- Reasoning-enhanced Code Intelligence: This focuses on using advanced reasoning to solve complex software engineering tasks through Interactive Programming (iterative loops of reason-generate-execute-debug) and Agentic Frameworks (autonomous agents like SWE-agent that navigate entire repositories).
The Synergy: Mapping Code Properties to Reasoning
A core insight of this research is the direct mapping of specific code properties to cognitive reasoning capabilities. Unlike ambiguous natural language, code provides an objective "ground truth" through execution, allowing models to perform self-reflection by testing hypotheses against an interpreter.
- Deterministic Output & Executability: Guarantees executability and builds reliability, supporting systematic planning.
- Structured Syntax & Modular Design: The rigid requirements of code force task decomposition. Learning this "enforced modularity" helps models break down complex logical problems in any domain.
- Error Feedback: The REPL (Read-Eval-Print Loop) cycle serves as a natural training ground for planning and error handling, highlighting logical gaps that natural language might obscure.
Empirical Evidence and Results
Synthesized results show that code-centric methods consistently outperform pure natural language approaches across various benchmarks:
- Mathematical Reasoning: On the GSM8K benchmark, models using "Program of Thoughts" (PoT) with GPT-4 achieved 97.2%, significantly higher than standard Chain-of-Thought (CoT) prompting. Training with code-related data, such as the MARIO dataset, led to massive jumps, improving a baseline 34B model's score by +26.7 points.
- Code Intelligence: Agentic methods like AgentCoder (96.3% on HumanEval) far surpass baseline direct generation (48.1% for Codex), proving that iterative reasoning is more critical than raw model size for complex tasks.
Challenges and Future Directions
Despite significant progress, several hurdles remain. LLM-generated code does not always faithfully reflect the model's internal thought process, leading to interpretability issues. Furthermore, code-based reasoning excels at algorithmic problems but can struggle with subjective or common-sense tasks where "executability" is ill-defined.
Future research should focus on Blended Code-and-Language Reasoning, where models dynamically decide when to use structured code for precision and when to use natural language for nuanced judgment. Additionally, improving data quality by including the reasoning behind the code, rather than just raw scripts, remains a priority for the next generation of intelligent systems.
Summary updated