Everything is An Expression

I've noticed many languages like Ruby and CofeeScript (well a transcompiler) support everything being an expression.

Now it makes the language somewhat simple to understand and definitely seems neat at the surface, but I was looking maybe for some scholarly publications about the positives and negatives of the two approaches.

It would be beneficial if the publications had clear examples that compared the benefits of having everything be an expression vs., well, not.

Examples in CoffeeScript vs Javascript would be nice, but not required.

The concept is definitely cool, but I'm still slightly unsure how revolutionary the whole idea really is (obviously something being revolutionary is somewhat an opinion).

Thanks!

Answers:

Answer

There is nothing revolutionary about this per se. The expression-oriented approach is a functional programming technique.

Expression-oriented code is simpler and less cluttered than statement-oriented code, because of fewer assignments and no explicit return statements. The lack of distinction between expressions and commands enables conceptual uniformity (see Referential transparency) and bottom-up structure.

Some modern languages have adopted functional programming concepts (e.g. C#, Python, Ruby).

Some scholarly insight on the benefits of functional practices:

Interesting articles:

As to the comment about performance concerns, the possible overhead related to choice of paradigm is probably negligible. Even in C, most statements evaluate as an expression - however, a comparison between a compiled language (C) and an interpreted language (CoffeeScript) is rather useless.

On a theoretical note, an imperative language represents the control flow in more of a machine-oriented way, which may allow for easier hand-optimization than a functional language.

Language performance and its significance depend heavily on the use case. Concerning JavaScript and whatever code transformation on top of it, this performance discussion is completely irrelevant. The gains in productivity outweigh any slight performance hit.

Answer

By "everything is an expression," I assume you mean what is described at http://jashkenas.github.com/coffee-script/

It kinda sounds like what you're asking about are functional languages. Consider, for example, Lisp, which did this sort of thing back in the '50s. This ultimately comes out of the Lambda Calculus, in which code and data are really the same thing, and you can pass code around as though it were data (because it is).

I don't know of any scholarly articles discussing this specifically, but now you at least have some more keywords to search for.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.