You're looking at Less Wrong's discussion board. This includes all posts, including those that haven't been promoted to the front page yet. For more information, see About Less Wrong.

DanArmak comments on More intuitive programming languages - Less Wrong Discussion

4 Post author: A4FB53AC 15 April 2012 11:35AM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (89)

You are viewing a single comment's thread. Show more comments above.

Comment author: DanArmak 19 April 2012 09:37:28PM 1 point [-]

Because a statement is the fundamental unit of an imperative language.

I don't believe this is true, at least not for the usual sense of "statement", which is "code with side effects which, unlike an expression, has no type (not even unit/void) and does not evaluate to a value".

You can easily make a language with no statements, just expressions. As an example, start with C. Remove the semicolon and replace all uses of it with the comma operator. You may need to adjust the semantics very slightly to compensate (I can't say where offhand).

Presto, you have a statement-less language that looks quite functional: everything (other than definitions) is an expression (i.e. has a type and yields a value), and every program corresponds to the evaluation of a nested tree of expressions (rather than the execution of a sequence of statements).

Yet, the expressions have side effects upon evaluation, there is global shared mutable state, there are variables, there is a strict and well-defined eager order of evaluation - all the semantics of C are intact. Calling this a non-imperative language would be a matter of definition, I guess, but there's no substantial difference between real C and this subset of it.