views:

716

answers:

7

I hear this word a lot in sentences like "javascript is a very expressive language". Does it just mean there aren't a lot of rules, or does "expressive" have a more specific meaning?

+4  A: 

http://en.wikipedia.org/wiki/Expressive_power

Yardena
+4  A: 

I take it to mean that it's capable of expressing ideas/algorithms/tasks in an easy-to-read and succinct way.

Usually I associate a language being expressive with syntactic sugar, although that's not always the case. Examples in C# of it being expressive would be:

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

A different example would be generics: before C# got generics, you couldn't express the idea of "an ArrayList containing only strings" in code. (You could document it, of course, or write your own StringList type, but that's not quite the same.)

Jon Skeet
+4  A: 

Neal Grafter has a blog with a good quote from it on the subject...

In my mind, a language construct is expressive if it enables you to write (and use) an API that can't be written (and used) without the construct.

I'd say that it means you can more naturaly express your thoughts in code.

TofuBeer
+1  A: 
TStamper
+1  A: 

That's a tough one.

For me, it has to do with the ease at which you can express your intent. This is different in different languages, and also depends a lot on what you want to do, so this is an area where generalizations are common. It's also subjective and personal, of course.

It's easy to think that a more high-level language is always more expressive, but I don't think that is true. It depends on what you're trying to express, i.e. on the problem domain.

If you wanted to print the floating-point number that has the binary pattern 0xdeadbeef, that is far easier to do in C than in Bash, for instance. Yet Bash is, compared to C, an ultra-high-level language. On the other hand, if you want to run a program and collect its output into a text file, that is so simple it's almost invisible in Bash, yet would require at least a page of code in C (assuming a POSIX environment).

unwind
+3  A: 

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

Two factors that make for expressiveness:

  • intuitively readable constructs
  • lack of boilerplate code

Compare this expressive Groovy, with the less expressive Java eqivalent:

3.times {
   println 'Hip hip hooray'
}

vs

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 stuff that Java makes you to specify explicitly.

slim
A: 

If you wanted to print the floating-point number that has the binary pattern 0xdeadbeef...

HA! I haven't heard that one.

Limited Atonement