5 ms·
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 i
by groovy2shoes 12y ago
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.
- calibraxis 12y agoWould 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.)
- groovy2shoes 12y agoYes, 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.
- deleted 12y ago[deleted]
- acron0 12y ago>> 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 http://www.purelyfunctional.tv/intro-to-clojure
- lynndylanhurley 12y agoThis 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.
- MonkeyIsNull 12y agoYou can reference a function before it's defined, just as he did in the C example: http://clojuredocs.org/clojure_core/clojure.core/declare http://clojuredocs.org/clojure_core/clojure.core/declare
- ericn 12y agoThat'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 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/informal-semantics.html 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.
- seancorfield 12y agoThis 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.
- groovy2shoes 12y ago> 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".
- craigching 12y ago> 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 ;)
- MonkeyIsNull 12y ago> 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.
- cygx 12y ago> 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.