Since its birth as a new scientific body of knowledge in the late 1950s, computer programming has become a fundamental skill needed in many other disciplines. However, programming is not easy, it is prone to errors and code re-use is key for productivity. This calls for high-quality documentation in software libraries, which is quite often not the case. Taking a few Haskell functions available from the Hackage repository as case-studies, and comparing their descriptions with similar functions in other languages, this paper shows how clarity and good conceptual design can be achieved by following a so-called easy-hard-split formal strategy that is quite general and productive, even if used informally. This strategy is easy to use in functional programming and can be applied to both program analysis and synthesis.
翻译:自 20 世纪 50 年代末作为一门新兴科学知识体系诞生以来,计算机编程已成为许多其他学科所需的一项基本技能。然而,编程并非易事,它容易出错,而代码复用是提高生产力的关键。这要求软件库具备高质量的文档,但实际情况往往并非如此。本文以 Hackage 代码库中提供的若干 Haskell 函数作为案例研究,通过比较其与其他语言中类似函数的描述,展示了如何通过遵循一种所谓“易难分离”的形式化策略来实现清晰性与良好的概念设计。该策略具有相当的通用性和高效性,即使非正式使用亦能奏效。此策略易于在函数式编程中应用,并可同时适用于程序分析与程序综合。