What do you mean by the expressiveness of a programming language?

前端 未结 11 1773
眼角桃花
眼角桃花 2021-01-31 07:56

I see a lot of the word \'expressiveness\' when people want to stress one language is better than the other. But I don\'t see exactly what they mean by it.

  • Is it
11条回答
  •  旧巷少年郎
    2021-01-31 08:30

    "Expressiveness" means the ability to say only what you want done:

    bad_event = events.find(&:bad)
    

    rather than how you want it done:

    i = 0
    bad_event = nil
    while i < events.size && bad_event.nil?
      event = events[i]
      if event.bad?
        bad_event = event
      end
      i += 1
    end
    

    Among the things that contribute to expressiveness are:

    • A lack of required syntactic sugar
    • First-class functions
    • Garbage collection
    • Either dynamic typing or type inference
    • The language core not being slavishly minimalistic
    • Good functionality in the standard library

    To some degree, the expressiveness of any language can be increased by shoving as much "how to do it" off into subroutines/objects as possible so that most of the remaining code is "what to do." The amount of "how to do it" code needed in the most abstract code is one measure of a language's expressiveness: The more the code looks like pseudocode, the more expressive it is of the programmer's intent.

    One can also think about the "meta-expressiveness" of a language: How expressive is the language at constructing Domain Specific Languages?

提交回复
热议问题