What does "expressive" mean when referring to programming languages?

Programming Languages

Programming Languages Problem Overview


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?

Programming Languages Solutions


Solution 1 - Programming Languages

'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.

Solution 2 - Programming Languages

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.)

Solution 3 - Programming Languages

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.

Solution 4 - Programming Languages

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).

Solution 5 - Programming Languages

Here, a very controversial comparison:

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

> So, what are the best languages by these metrics? > > If you pick the top 10 based on ranking by median and by IQR, then > take the intersection of them, here’s what’s left. The median and IQR > are listed immediately after the names: > > Augeas (48, 28): A domain-specific languages for configuration files > > Puppet (52, 65): Another DSL for configuration REBOL (57, 47): A language designed for distributed computing > >eC (75, 75): Ecere C, a C derivative with object orientation > >CoffeeScript (100, 23): A higher-level language that transcompiles to JavaScript > >Clojure (101,51): A Lisp dialect for functional, concurrent programming > >Vala (123, 61): An object-oriented language used by GNOME > >Haskell (127, 71): A purely functional, compiled language with strong static typing

Solution 6 - Programming Languages

Solution 7 - Programming Languages

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

In short he says: 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. In the context of the Closures for Java proposed language extension, control abstraction APIs are the kind of thing that don't seem to be supported by the competing proposals.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmorgancodesView Question on Stackoverflow
Solution 1 - Programming LanguagesslimView Answer on Stackoverflow
Solution 2 - Programming LanguagesJon SkeetView Answer on Stackoverflow
Solution 3 - Programming LanguagesTofuBeerView Answer on Stackoverflow
Solution 4 - Programming LanguagesunwindView Answer on Stackoverflow
Solution 5 - Programming LanguagesAA.View Answer on Stackoverflow
Solution 6 - Programming LanguagesYardenaView Answer on Stackoverflow
Solution 7 - Programming LanguagesTStamperView Answer on Stackoverflow