arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2601.02060cs.PLcs.AIcs.SE
收藏

perish 或 flourish? 对于函数式编程中代码生成的大型语言模型的全面评估

Perish or Flourish? A Holistic Evaluation of Large Language Models for Code Generation in Functional Programming

Hanoi University of Science and Technology(河内科学技术大学);The University of Melbourne(墨尔本大学)

Nguyet-Anh H. Lang, Eric Lang, Thanh Le-Cong, Bach Le, Quyet-Thang Huynh

AI总结:

本文提出FPEval框架,评估大型语言模型在函数式编程语言中的代码生成能力,发现模型性能随进步而提升,但纯函数式语言错误率较高,且生成代码风格问题。

摘要:

函数式编程为开发可靠且安全的软件系统提供了坚实的基础,但其采用仍然不广泛,这是因为学习曲线陡峭。近年来,大型语言模型(LLMs)在代码生成方面的进步为降低这些障碍提供了新的机会。然而,对LLMs的广泛评估大多集中在命令式编程语言上,而在函数式编程语言(FP)中的能力仍然缺乏深入研究。为解决这一差距,我们引入了FPEval,一个基于FPBench的全面评估框架,FPBench是一个包含721个编程任务的新基准,涵盖三种难度级别,针对三种主流的函数式编程语言:Haskell、Ocaml和Scala。FPEval提供了全面的评估基础设施,包括与全面的测试套件和静态分析工具相结合的测试验证,以评估功能正确性和代码风格及可维护性。使用此框架,我们评估了最先进的LLMs,包括GPT-3.5、GPT-4o和GPT-5,在函数式编程语言和Java(作为命令式语言的基线)中的代码生成能力。我们的结果表明,LLMs在函数式编程中的性能随着模型的进步显著提高;然而,纯函数式语言(Haskell和Ocaml)中的错误率明显高于混合(Scala)或命令式(Java)语言。此外,LLMs经常生成非惯用的函数式代码,遵循命令式模式,这引发了关于代码风格和长期可维护性的担忧。最后,我们展示LLMs在提供静态分析反馈和手写指令以解决常见问题类型时,可以部分自行修复正确性和质量问题。

英文摘要:

Functional programming provides strong foundations for developing reliable and secure software systems, yet its adoption remains not widespread due to the steep learning curve. Recent advances in Large Language Models (LLMs) for code generation present new opportunities to lower these barriers. However, extensive evaluations of LLMs largely focus on imperative programming languages, and their capabilities in functional programming languages (FP) remain underexplored. To address this gap, we introduce FPEval, a holistic evaluation framework built on FPBench, a new benchmark of 721 programming tasks across three difficulty levels on three mainstream FP languages: Haskell, Ocaml and Scala. FPEval provides compehensive evaluation infrastructures with both test validations with comprehensive test suites and static analysis tools to assess both functional correctness and code style and maintainability. Using this framework, we evaluate state-of-the-art LLMs, including GPT-3.5, GPT-4o, and GPT-5, for code generation in functional programming languages and Java as an imperative baseline. Our results demonstrate that LLM performance in functional programming improves substantially with model advancement; however, error rates remain significantly higher in purely functional languages (Haskell and OCaml) than in hybrid (Scala) or imperative (Java) languages. Moreover, LLMs frequently generate non-idiomatic functional code that follows imperative patterns, raising concerns about code style and long-term maintainability. Finally, we show that LLMs can partially self-repair both correctness and quality issues when provided with static analysis feedback and hand-crafted instructions for common types of issues.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑