News for hackers. Stuff that matters.
Re:Clojure is imperative as opposed to declarative by groovy2shoes on Saturday August 23, 2014 @01:51PM (#8216366)
It's useless to categorize things as imperative or declarative without defining those words. There aren't any agreed-upon definitions for what it means to be imperative or declarative (or functional or object-oriented...).

At this point it's mostly an "I know it when I see it" kind of thing, sometimes accompanied by a nebulous explanation about what versus how. There is a difference that programmers can feel, but we find it very hard to communicate that difference. Even at that, virtually every language has some aspects that are imperative and some that are declarative.

Without definitions (preferably rigorous ones), the only thing a post like this will accomplish is starting a flame war.

Re:Clojure is imperative as opposed to declarative by seancorfield on Saturday August 23, 2014 @04:23PM (#8216774)
This comment, whilst perhaps accurate in and of itself, is missing the point of his article I think...

He's saying that a small, simple, imperative core is easy to understand (and the rest of the language is built on that), whereas more declarative languages tend to involve more complex compilers and more magic, making those languages harder to learn and comprehend.

Re:Clojure is imperative as opposed to declarative by groovy2shoes on Saturday August 23, 2014 @04:44PM (#8216819)
> He's saying that a small, simple, imperative core is easy to understand (and the rest of the language is built on that), whereas more declarative languages tend to involve more complex compilers and more magic, making those languages harder to learn and comprehend.

Yes, for some unstated definition of "imperative" and "declarative".

Re:Clojure is imperative as opposed to declarative by lynndylanhurley on Saturday August 23, 2014 @04:02PM (#8216739)
This is what I gathered from the context of the article:

Clojure is imperative in the sense that the code is evaluated and executed sequentially. For example, a function cannot be referenced before it is defined.

This is in contrast with (declarative) languages such as Haskell, in which the compiler will evaluate the entire file before executing any code.

Someone please correct me if I'm mistaken.

Re:Clojure is imperative as opposed to declarative by ericn on Saturday August 23, 2014 @05:05PM (#8216862)
That's close to what I meant.

Closer would be:

Clojure def is imperative because the semantics are defined mechanically, leaving fewer implementation details up to the implementer. http://clojure.org/special_forms#Special Forms--(def symbol init?)

Haskell toplevel function definitions are more declarative because the semantics are defined less concretely. https://www.haskell.org/ghc/docs/latest/html/users_guide/inf...

This is what I meant. I did not mean to start a flame war about the definition of declarative. It's more about different approaches to language design.

Re:Clojure is imperative as opposed to declarative by MonkeyIsNull on Saturday August 23, 2014 @04:55PM (#8216843)
You can reference a function before it's defined, just as he did in the C example: http://clojuredocs.org/clojure_core/clojure.core/declare
Re:Clojure is imperative as opposed to declarative by calibraxis on Saturday August 23, 2014 @02:26PM (#8216501)
Would you accept the claim though that Clojure is less declarative than Haskell, in the sense the author means? (Without necessarily a great definition of "declarative". Like how mathematicians could go far without a good definition of "function" until it got to be a problem.)
Re:Clojure is imperative as opposed to declarative by groovy2shoes on Saturday August 23, 2014 @04:37PM (#8216807)
Yes, I will accept that claim. However the definitions I inferred from the article are new to me (albeit similar to other definitions I'm familiar with). I gathered the same definition as lynndylanhurley.
Re:Clojure is imperative as opposed to declarative by craigching on Saturday August 23, 2014 @04:43PM (#8216816)
> It's useless to categorize things as imperative or declarative without defining those words.

Yes because his use of the terms "imperative" and "declarative" are not the way I generally use them. When talking languages, I always thought you had imperative, functional, and declarative. Clojure is functional because of it's use of concepts like "functions are first order objects", closure, higher order functions, etc. I would never consider Clojure imperative.

EDIT: Possibly with the use of core.logic you could argue that it is "declarative" if you wanted to ;)

Re:Clojure is imperative as opposed to declarative by MonkeyIsNull on Saturday August 23, 2014 @05:03PM (#8216859)
> Clojure is functional because of it's use of concepts like "functions are first order objects", closure, higher order functions, etc. I would never consider Clojure imperative.

I would agree with that. Putting Clojure in the imperative camp seems a little skewed.

From the front page of clojure.org "Clojure is predominantly a functional programming language, and features a rich set of immutable, persistent data structures."

But I don't think that's his point as seancorfield pointed out.

Re:Clojure is imperative as opposed to declarative by cygx on Saturday August 23, 2014 @05:35PM (#8216932)
> I always thought you had imperative, functional, and declarative

That's not how I see it (but of course this largely depends on your definitions).

The main paradigms are imperative and declarative (think Assembler vs. Prolog if you want to go to the extremes).

'Functional' describes the language at a different level, as does 'object-oriented'.

If you go down to the core ideas, being functional is a declarative concept (mathematical functions are relations between sets), and object-oriented an imperative concept (objects are an abstraction over mutable state).

However, that's not necessarily how these concepts appear in practice (a function call is an instruction to trigger a compuation, the set of messages understood by an object declares its interface), and almost all programming languages are multi-paradigm anyway.

Re:Clojure is imperative as opposed to declarative by acron0 on Saturday August 23, 2014 @03:42PM (#8216671)
>> the only thing a post like this will accomplish is starting a flame war.

And, possibly, help the author sell a few books [1].

[1] | http://www.purelyfunctional.tv/intro-to-clojure