What does expressive mean when it comes to programming languages?

I hear this word a lot in sentences like "javascript is a very expressive language." Does this mean that the rules do not exist, or “expressive” have a more specific meaning?

+53
programming-languages
Mar 12 '09 at 14:32
source share
7 answers

Expressive means it's easy to write code that is easy to understand for both the compiler and the reader.

Two factors that make for expressiveness:

  • intuitive designs
  • lack of template code

Compare this expressive Groovy with the less expressive Java equivalent:

3.times { println 'Hip hip hooray' } 

against

 for(int i=0; i<3; i++) { System.out.println("Hip hip hooray"); } 

Sometimes you trade precision for expressiveness - the Groovy example works because it assumes that Java allows you to explicitly specify.

+47
Mar 12 '09 at 14:41
source share

I believe that he is able to express ideas / algorithms / tasks in an easily readable and concise form.

I usually associate a language expressive with syntactic sugar, although this is not always the case. Examples in C # of this expression are:

  • foreach (instead of explicitly writing the iteration)
  • using statement (instead of explicitly writing try / finally)
  • query expressions (simpler syntax for writing LINQ queries)
  • extension methods (allowing chaining method calls, again primarily for LINQ)
  • anonymous methods and lambda expressions (simplifying the construction of the tree of delegates and expressions)

Another example would be generics: before C # got generics, you could not express the idea of ​​“a ArrayList containing only strings” in your code. (You could document it, or write your own StringList type, but this is not quite the same.)

+14
Mar 12 '09 at 14:36
source share

Neal Grafter has a blog with a good quote from this on the topic ...

In my opinion, a language construct is expressive if it allows you to write (and use) an API that cannot be written (and used) without a construct.

I would say that this means that you can more naturally express your thoughts in code.

+10
Mar 12 '09 at 14:37
source share
+4
Mar 12 '09 at 14:36
source share

It is heavy.

For me, this is due to the ease with which you can express your intention. These are different languages ​​in different languages, and also a lot depends on what you want to do, so this is an area where generalizations are common. It is also subjective and personal, of course.

It is easy to think that a higher level language is always more expressive, but I do not think that this is true. It depends on what you are trying to express, that is, in the problem area.

If you want to print a floating point number that has the binary 0xdeadbeef pattern, this is much easier to do in C than, for example, in Bash. However, Bash, compared to C, is a super-high-level language. On the other hand, if you want to run the program and collect its output into a text file, it is so simple that it is almost invisible in Bash, but for this you need at least a page of C code (provided that the POSIX environment).

+4
Mar 12 '09 at 14:39
source share

Here's a very controversial comparison:

http://redmonk.com/dberkholz/2013/03/25/programming-languages-ranked-by-expressiveness/

So what are the best languages ​​for these metrics?

If you select the top 10 players based on median and IQR rankings, then cross them, that's what remains. Median and IQR are listed immediately after the names:

Augeas (48, 28): domain specific languages ​​for configuration files

Puppet (52, 65): another DSL for REBOL configuration (57, 47): a language designed for distributed computing

eC (75, 75): Ecere C, derivative C with object orientation

CoffeeScript (100, 23): A higher-level language that transcribes into JavaScript

Clojure (101.51): Lisp dialect for functional, parallel programming

Vala (123, 61): An Object Oriented Language Used by GNOME

Haskell (127, 71): A purely functional, compiled language with strong static typing

+2
Oct 21 '14 at 2:39 on
source share

Maybe this site http://gafter.blogspot.com/2007/03/on-expressive-power-of-programming.html can help you

In short, he says . In my opinion, a language construct is expressive if it allows you to write (and use) an API that cannot be written (and used) without a construct. In the context of the proposed Closures for Java language extension, abstraction APIs are things that do not seem to be supported by competing sentences.

+1
Mar 12 '09 at 14:38
source share



All Articles