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

前端 未结 11 1949
眼角桃花
眼角桃花 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:13

    Wikipedia has a bit about the concept. I myself take it to mean that a language can accomplish more with less (the so called "informal usage" in the Wikipedia article).

    I consider JavaScript expressive (though this could be because Douglas Crockford drilled that idea into my noggin) because it can do so much with just a few keywords. For instance, the function keyword is a function, as well as a method, a class, and a lambda.

    Some code illustration (leaving out some details for brevity) in JavaScript. It's an event class I wrote:

    SJJS.util.Event = (function() {
        var _listeners = [];
        var _listenerReturns = [];
    
        return {
            addDomListener: function(element, eventName, listener) {
            },
            trigger: function(element, eventName) {
            },
            removeListener: function(eventlistener) {
            }
        }
    })();
    

    With just function, var, and some curly braces and parentheses I made a static class with methods and private variables.

提交回复
热议问题