# Eiffel（编程语言）

**Eiffel** 是一种面向对象的编程语言，由贝特朗·迈耶（Bertrand Meyer）于1985年在交互式软件工程公司（Interactive Software Engineering，ISE，现为Eiffel Software）设计，同时配套一套围绕契约式设计（Design by Contract）构建的开发方法。在契约式设计中，每个软件组件的义务与保证都以可执行断言的形式写入源代码。<sup>[1](https://www.eiffel.com/resources/faqs/eiffel-language/)</sup><sup> • </sup><sup>[2](https://archive.eiffel.com/doc/eiffel.html)</sup> 该语言以ISO/IEC 25436:2006进行国际标准化，并在EiffelStudio环境中进行商业实现。<sup>[3](https://www.iso.org/standard/42924.html)</sup><sup> • </sup><sup>[4](https://www.eiffel.com/company/about-us/)</sup>

| 关键事实 | 详情 |
|---|---|
| 设计时间 | 1985年，由贝特朗·迈耶在ISE（Eiffel Software）设计，最初是作为构建软件工程工具的内部工具<sup>[1](https://www.eiffel.com/resources/faqs/eiffel-language/)</sup><sup> • </sup><sup>[5](https://se.inf.ethz.ch/old/people/meyer/publications/eiffel/eiffel_jss.pdf)</sup> |
| 公开亮相 | 1986年10月首届OOPSLA会议；1986年12月做出商业发布决定<sup>[1](https://www.eiffel.com/resources/faqs/eiffel-language/)</sup> |
| 标准化 | ECMA-367（第1版2005年6月，第2版2006年6月）；ISO/IEC 25436:2006，2006年12月发布，2026年确认仍为现行标准<sup>[6](https://ecma-international.org/publications-and-standards/standards/ecma-367/)</sup><sup> • </sup><sup>[3](https://www.iso.org/standard/42924.html)</sup> |
| 核心特征 | 契约式设计：前置条件（`require`）、后置条件（`ensure`）和类不变式（`invariant`）写入代码，可在运行时监控<sup>[7](https://www.eiffel.com/values/design-by-contract/)</sup><sup> • </sup><sup>[8](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1866.html)</sup> |
| 类型与结构 | 完全静态类型；多重继承与重复继承；自动存储管理<sup>[5](https://se.inf.ethz.ch/old/people/meyer/publications/eiffel/eiffel_jss.pdf)</sup> |
| 并发 | SCOOP（简单并发面向对象编程），推荐的高级机制，旨在避免数据竞争<sup>[9](https://www.eiffel.org/doc/solutions/Concurrency)</sup> |
| 主要实现 | EiffelStudio，由Eiffel Software生产和发行的集成开发环境<sup>[4](https://www.eiffel.com/company/about-us/)</sup> |

## 历史

Eiffel最初是加利福尼亚州戈莱塔（Goleta）的交互式软件工程公司的内部开发项目。公司创始人迈耶在1985年考察了当时可用的语言，认为没有一种能达到他的产品所要推行的现代软件工程标准，于是设计了一种新语言来构建公司自己的工具。<sup>[5](https://se.inf.ethz.ch/old/people/meyer/publications/eiffel/eiffel_jss.pdf)</sup> Eiffel开发者贝伦德·德·布尔（Berend de Boer）编纂的一份历史记录显示，迈耶和让·马克·内尔松（Jean Marc Nerson）当年开始了这种新语言的开发。<sup>[10](https://www.berenddeboer.net/eiffel/archive/halstenbach_eiffel_history.html)</sup>

该实现从1986年初起可供内部使用，1986年12月做出商业发布决定；公司将公开亮相时间定在1986年10月的首届OOPSLA会议。<sup>[5](https://se.inf.ethz.ch/old/people/meyer/publications/eiffel/eiffel_jss.pdf)</sup><sup> • </sup><sup>[1](https://www.eiffel.com/resources/faqs/eiffel-language/)</sup> 该技术传播到北美、加拿大、欧洲和[远东](https://www.edgepedia.org/zh/far-east)的工业界与学术机构，该环境的后续版本以大约每年一个的速度出现。<sup>[5](https://se.inf.ethz.ch/old/people/meyer/publications/eiffel/eiffel_jss.pdf)</sup><sup> • </sup><sup>[1](https://www.eiffel.com/resources/faqs/eiffel-language/)</sup>

名称来自[古斯塔夫·埃菲尔](https://www.edgepedia.org/zh/gustave-eiffel)（Gustave Eiffel），即[埃菲尔铁塔](https://www.edgepedia.org/zh/eiffel-tower)的工程师；公司将铁塔以少量稳健的设计模式反复组合变化而成的方式，与用可复用库构建系统的方式作类比。<sup>[1](https://www.eiffel.com/resources/faqs/eiffel-language/)</sup>

迈耶的书《面向对象软件构造》（*Object-Oriented Software Construction*）于1988年出版，被译为八种语言，用Eiffel来解释面向对象技术和契约式设计，成为畅销书。<sup>[1](https://www.eiffel.com/resources/faqs/eiffel-language/)</sup> 语言本身在迈耶1992年的著作《Eiffel：语言》（*Eiffel: The Language*，Prentice Hall）中有详细描述。<sup>[2](https://archive.eiffel.com/doc/eiffel.html)</sup>

## 契约式设计

Eiffel的核心方法是契约式设计，这一术语由迈耶引入并推广。每个组件受一份契约约束：前置条件，即组件使用前必须为真的条件；后置条件，即执行后保证成立的条件；以及不变式，即系统要保持有效就必须始终成立的条件。<sup>[7](https://www.eiffel.com/values/design-by-contract/)</sup> 在Eiffel中，这些是语言构造，而非注释或外部标注：ISE实现使用关键字`require`、`ensure`、`do`、`require else`、`ensure then`、`invariant`、`old`、`result`和`variant`，违反契约会抛出异常。<sup>[8](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1866.html)</sup>

Eiffel中的契约同时服务于三个目的：它们是可执行的规格说明、运行时检查和从代码生成的文档。断言监控由编译选项控制，可按类选择级别，从不检查到仅检查前置条件、检查前置条件和后置条件，或检查全部。<sup>[7](https://www.eiffel.com/values/design-by-contract/)</sup><sup> • </sup><sup>[1](https://www.eiffel.com/resources/faqs/eiffel-language/)</sup> `old`关键字让后置条件可以引用例程运行前表达式的值，在C++和D语言提出类似方案之前，Eiffel实现就已具备这一特性。<sup>[8](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1866.html)</sup>

[异常处理](https://www.edgepedia.org/zh/exception-handling)遵循同样的纪律。每个例程可以在其主体后带一个`rescue`子句；如果主体引发异常，控制转到rescue子句，后者尝试恢复主体可以再次运行的状态。一个隐式局部变量`Retry`决定主体是重新执行还是将异常传播给调用者。<sup>[11](https://arxiv.org/abs/1106.4700)</sup>

## 语言特性

Eiffel是静态强类型的：每个实体在源代码中声明单一静态类型，类型错误在编译时而非运行时捕获。<sup>[5](https://se.inf.ethz.ch/old/people/meyer/publications/eiffel/eiffel_jss.pdf)</sup><sup> • </sup><sup>[1](https://www.eiffel.com/resources/faqs/eiffel-language/)</sup> 1988年的语言描述列出了四种预定义的“简单”类型：BOOLEAN、CHARACTER、INTEGER和REAL，其他所有类型都由类定义。<sup>[5](https://se.inf.ethz.ch/old/people/meyer/publications/eiffel/eiffel_jss.pdf)</sup>

**类与继承。** 类既是类型也是模块，类是系统唯一的结构化设施。Eiffel支持多重继承和重复继承，即一个类通过两条或更多路径继承同一个祖先；语言允许开发者为共同祖先的每个特性分别决定在后代中产生一个还是两个特性。<sup>[5](https://se.inf.ethz.ch/old/people/meyer/publications/eiffel/eiffel_jss.pdf)</sup><sup> • </sup><sup>[1](https://www.eiffel.com/resources/faqs/eiffel-language/)</sup>

**内存管理。** 存储自动管理；原始实现使用自己的垃圾回收，而非标准`malloc`系统调用。<sup>[5](https://se.inf.ethz.ch/old/people/meyer/publications/eiffel/eiffel_jss.pdf)</sup><sup> • </sup><sup>[12](https://archive.eiffel.com/doc/manuals/technology/internal/gc/page.html)</sup>

**编译。** 原始Eiffel环境使用C作为中间语言，支持类的分离编译和良好的空间与时间运行时性能，并在修改后自动重新编译类。<sup>[5](https://se.inf.ethz.ch/old/people/meyer/publications/eiffel/eiffel_jss.pdf)</sup>

**并发。** 除了较低层的EiffelThreads库，Eiffel还提供SCOOP，即简单并发面向对象编程，一种旨在简化并发应用并避免数据竞争等典型陷阱的高级机制；它是并发Eiffel编程的推荐方法。<sup>[9](https://www.eiffel.org/doc/solutions/Concurrency)</sup>

## 标准化

该语言是非专有的，已经过两次标准化。<sup>[2](https://archive.eiffel.com/doc/eiffel.html)</sup> [Ecma国际](https://www.edgepedia.org/zh/ecma-international)于2005年6月发布ECMA-367《Eiffel：分析、设计与编程语言》第一版，2006年6月发布第二版；该标准规定了Eiffel文本的词法、语法、有效性和语义属性，以及对符合性实现的一些要求，例如能够生成某些形式的自动文档。<sup>[6](https://ecma-international.org/publications-and-standards/standards/ecma-367/)</sup> 相同内容成为国际标准ISO/IEC 25436:2006，于2006年12月在[ISO/IEC JTC 1](https://www.edgepedia.org/zh/iso-iec-jtc-1)/SC 22下发布；该标准最近于2026年复审并确认，因此该版本仍为现行版本。<sup>[3](https://www.iso.org/standard/42924.html)</sup> Eiffel Software的文档将该标准视为语言的最终权威，并以其在线文档“差异”章节中列出的偏差为修正。<sup>[13](https://www.eiffel.org/doc/eiffel/Quick_reference_to_the_Eiffel_programming_language)</sup>

## 环境、库与工具

EiffelStudio是由Eiffel Software生产和发行的集成开发环境，该公司还围绕标准化工具提供培训、咨询和支持。<sup>[4](https://www.eiffel.com/company/about-us/)</sup> 该环境附带一套包含数千个类的可复用库，包括用于数据结构的EiffelBase、用于图形的EiffelVision、用于网络的EiffelNet和EiffelWeb，以及用于解析的EiffelParse和EiffelLex。<sup>[1](https://www.eiffel.com/resources/faqs/eiffel-language/)</sup>

Eiffel赋予一等公民地位的契约也为一个研究工具链提供了支持。AutoProof将带有契约标注的Eiffel程序转换为Boogie，并使用Boogie验证器进行证明，处理异常处理、多态、继承和函数对象（在Eiffel中称为代理）等特性。<sup>[11](https://arxiv.org/abs/1106.4700)</sup> 一项关于契约演化的实证研究——COAT项目——分析了21个Eiffel、C#和Java软件项目，总共覆盖122年的开发历史，考察契约如何在真实项目中作为轻量级规格说明使用，以及其使用方式如何随时间变化。<sup>[14](https://se.inf.ethz.ch/data/coat/)</sup> 最近，Eiffel-tools——一个Eiffel的[语言服务器协议](https://www.edgepedia.org/zh/language-server-protocol)实现——使用大型语言模型结合静态验证器来生成和检查代码与规格说明；在其评估中，该工具根据所用模型和提示的不同，可以修复76%到95%的缺陷。<sup>[15](https://arxiv.org/abs/2609.03086)</sup>

## 使用与影响

据其供应商称，Eiffel已用于从金融系统到国防和保险应用的工业环境，许多大学将其作为主要教学语言。<sup>[4](https://www.eiffel.com/company/about-us/)</sup><sup> • </sup><sup>[1](https://www.eiffel.com/resources/faqs/eiffel-language/)</sup> 其更广泛的影响通过契约式设计传播：该方法起源于Eiffel，被普遍接受为构建可靠软件的实用方法，此后契约式构造出现在其他语言中，包括针对C++的提案以及D语言，后者采用了`in`、`out`和`invariant`等关键字。<sup>[16](https://www.jstage.jst.go.jp/article/transinf/E91.D/11/E91.D_11_2685/_article/-char/en)</sup><sup> • </sup><sup>[8](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1866.html)</sup> 一份2006年关于用Eiffel构建的敏捷项目的实证报告指出，契约式设计效果良好，是该项目缺陷率低的原因之一，大多数缺陷在单元测试期间通过前置条件捕获。<sup>[17](https://www.researchgate.net/publication/4091546_Evaluating_the_XP_customer_model_and_Design_by_Contract)</sup>

## References

1. [Eiffel Language FAQ, Eiffel Software](https://www.eiffel.com/resources/faqs/eiffel-language/)
2. [About Eiffel, Eiffel Software archive](https://archive.eiffel.com/doc/eiffel.html)
3. [ISO/IEC 25436:2006, Information technology — Eiffel: Analysis, Design and Programming Language, ISO](https://www.iso.org/standard/42924.html)
4. [About Us, Eiffel Software](https://www.eiffel.com/company/about-us/)
5. [Bertrand Meyer (1988). Eiffel: A Language and Environment for Software Engineering. Journal of Systems and Software 8, 199–246](https://se.inf.ethz.ch/old/people/meyer/publications/eiffel/eiffel_jss.pdf)
6. [ECMA-367, Eiffel: Analysis, design and programming language, Ecma International](https://ecma-international.org/publications-and-standards/standards/ecma-367/)
7. [Design by Contract, Eiffel Software](https://www.eiffel.com/values/design-by-contract/)
8. [Proposal to add Contract Programming to C++ (revision 3), N1866, ISO/IEC JTC 1/SC 22/WG21](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1866.html)
9. [Concurrency, Eiffel documentation](https://www.eiffel.org/doc/solutions/Concurrency)
10. [Eiffel History, Berend de Boer](https://www.berenddeboer.net/eiffel/archive/halstenbach_eiffel_history.html)
11. [Tschannen, Furia, Nordio, Meyer (2011). Verifying Eiffel Programs with Boogie. arXiv:1106.4700](https://arxiv.org/abs/1106.4700)
12. [Garbage Collection for ISE Eiffel, Eiffel Software archive](https://archive.eiffel.com/doc/manuals/technology/internal/gc/page.html)
13. [Quick reference to the Eiffel programming language, Eiffel documentation](https://www.eiffel.org/doc/eiffel/Quick_reference_to_the_Eiffel_programming_language)
14. [Contract Evolution Data Mined by the COAT Tool, ETH Zurich](https://se.inf.ethz.ch/data/coat/)
15. [Schena, Mustafin, Kotovich (2026). Large Language Models and Language Server Protocol: a match made in context. arXiv:2609.03086](https://arxiv.org/abs/2609.03086)
16. [Contract Specification in Java: Classification, Characterization, and a New Marker Method, Transactions of IEICE](https://www.jstage.jst.go.jp/article/transinf/E91.D/11/E91.D_11_2685/_article/-char/en)
17. [Evaluating the XP customer model and Design by Contract, ResearchGate](https://www.researchgate.net/publication/4091546_Evaluating_the_XP_customer_model_and_Design_by_Contract)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Programming languages › Individual programming languages › C-family and imperative languages

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/eiffel-programming-language

English original: https://www.edgepedia.org/eiffel-programming-language
