How to Measure Programming Language Complexity


Here’s a useful metric for programming language complexity: the number of keywords or reserved words in the language. This corresponds roughly to the number of language features and, hence, the size of the language.

  1. F# — 69 + 8 from OCaml + 26 future = 103
  2. C# — 79 + 23 contextual = 102
  3. C++ — 93
  4. Swift — 93
  5. Kotlin — 30 + 17 soft + 29 modifiers + 2 special = 78
  6. PHP — 67
  7. JavaScript (or ECMAScript)—64 (or 34 + 7 future = 41)
  8. Dart — 56
  9. Rust — 35 + 17 future = 52
  10. Java — 50
  11. Perl — 40
  12. Scala — 40
  13. Ruby — 39
  14. Julia — 38
  15. Objective-C — 37
  16. Scheme — 37
  17. Haskell — 36
  18. Python — 33
  19. C — 32
  20. Go (or Golang )— 25
  21. Elixir — 18
  22. Smalltalk — 6

Note that for JavaScript, if you’re working with legacy code, you may have to deal with the larger language (64 keywords).

The metric isn’t perfect but it provides a reasonable indicator of complexity. Obviously, C++ and Swift are very large and complex languages. F# has the potential to be the most complex language on the list.

JavaScript is considerably more complex than Java, and ECMAScript is certainly more complex than Python.

Smalltalk. What can I say? Languages don’t get any simpler than this one (except for Forth).