网上看到一份各种编程语言保留关键字排行榜,摘录如下,保留关键字越多,需要记忆的越多,学习起来就会更复杂,相反保留关键字比较少,相对学习起来会更容易。这也体现了一个语言设计时是否足够简洁,相对简洁的语言才有较强的生命力。
- ANSI COBOL 85: 357
- SystemVerilog: 250 + 73 reserved system functions = 323
- VHDL 2008: 115 reserved words
- C#: 79 + 23 contextual = 102
- F#: 64 + 8 from ocaml + 26 future = 98
- C++: 82
- Dart: 54
- Java: 50 (48 without unused keywords
const
andgoto
) - PHP: 49
- Ruby 42
- JavaScript: 38 reserved words + 8 words reserved in strict mode only
- Python 3.7: 35
- C: 32
- Python 2.7: 31
- Go: 25
- Elm : 25
- Lua: 22
- CoffeeScript: 19, not necessarily "reserved", plus ~50 to avoid from JS
- Smalltalk: 6 pseudo-variables
- iota: 2
ABAP起源于COBOL,又需要兼容早期不同的版本,所以保留关键字越来越多,学习起来也挺费劲。