Jump to content

Talk:Declarative programming

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Nythar (talk | contribs) at 23:14, 16 June 2022 (Removed 11 threads to Talk:Declarative_programming/Archive 1). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Template:Vital article

WikiProject iconComputing C‑class High‑importance
WikiProject iconThis article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
CThis article has been rated as C-class on Wikipedia's content assessment scale.
HighThis article has been rated as High-importance on the project's importance scale.
WikiProject iconComputer science C‑class Top‑importance
WikiProject iconThis article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
CThis article has been rated as C-class on Wikipedia's content assessment scale.
TopThis article has been rated as Top-importance on the project's importance scale.
Things you can help WikiProject Computer science with:

Anyone else think that the link to business rules seems a bit out of place? AliaGemma 04:20, 12 January 2007 (UTC)[reply]


HTML is not a programming language

Based on this (rather) simple affirmation, I just don't understand why HTML is cited as an example in that article: an example such this could be misleading for all the non-experts (Oh, then HTML is a declarative programming language? Cool!) —Preceding unsigned comment added by 87.17.195.204 (talk) 10:43, 19 September 2007 (UTC)[reply]

Why do you not provide a different example then? Insisting on HTML not being a proper programming language does not help anyone, it is just the usual "I am a true programmer" attitude. The HTML example is very good; you can immediately understand what declarative definitions are about. Anyone in doubt about HTML being a programmin language will be cured by a quick click on the referenced page. 129.187.228.194 (talk) 13:30, 6 May 2008 (UTC)[reply]

Another angle on this

This article is written as if declarative programming were strictly a property of languages. In fact, it is also a technique that can be deployed in an imperative language. For example, you can write a C++ function that does some task (or tasks) based on the contents of a (typically static const) array (or other structure) initialized as part of the code. A developer can then effectively accomplish certain programming tasks by changing the content of that array: effectively, declarative programming. I've certainly used this technique, but I am not offhand familiar with a citable reference. If someone has something citable, this probably would merit mention. - Jmabel | Talk 22:00, 1 February 2008 (UTC)[reply]

Like table-driven methods in Code Complete? Skilldrick (talk) 10:36, 29 July 2010 (UTC)[reply]

Merged and rewritten

I merged declarative programming language into this article, and rewrote huge parts of it. There were some pretty horrible things in both articles. Factually wrong things ("Purely declarative languages don't compute anything") to obnoxious things (parts of the article seemed to be written by someone I can only assume was well-meaning but didn't understand the topic) or just horribly written or irrelevant. Hopefully my replacement is better!

Article still badly in need of references for things, though.

Would someone more enterprising than me consider refactoring this (and the the talk page from Talk:declarative programming language) or archiving them or something? This talk page is excessively long and discussions exist on things that seem to be long dead. Tejoka (talk) 06:58, 5 October 2008 (UTC)[reply]

Functional programming is not declarative

To quote the relevant section from the article:

"Functional programming, and in particular purely functional programming, attempts to minimize or eliminate side effects, and is therefore considered declarative. Most functional languages, such as Scheme, Objective Caml and Unlambda, however, do permit side effects in practice.
While functional languages typically do appear to specify "how", a compiler for a purely functional programming language is free to extensively rewrite the operational behavior of a function, so long as the same result is returned for the same inputs. This can be used to, for example, make a function compute its result in parallel, or to perform substantial optimizations (such as deforestation) that a compiler may not be able to safely apply to a language with side effects."

These two paragraphs are completely bogus. Let's take them apart:

  • "Functional programming, [...], attempts to minimize or eliminate side effects, and is therefore considered declarative."
    No, that's neither a sufficient, nor a necessary, condition for declarative programming! For example, a side-effect, like setting a memory location or writing to a file, could be described in a declarative way (e.g. using pre- and post-conditions).
  • "While functional languages typically do appear to specify "how" [...]"
    They don't just appear to specify "how", they actually do! Every valid functional program represents an algorithm, and algorithms describe how to compute a result.
  • "a compiler for a purely functional programming language is free to extensively rewrite the operational behavior of a function, so long as the same result is returned for the same inputs."
    So does a compiler for an imperative programming language; in fact, for basically every language, the compiler is allowed to do that (it's generally called "optimization").
  • "or to perform substantial optimizations (such as deforestation) that a compiler may not be able to safely apply to a language with side effects."
    Most FP languages are not side-effect free, so the same limitations exist for them as for imperative languages.

The main problem with this section is that it tries to demonstrate that FP languages are declarative, which is not the case (although I often read this false claim). If no one objects, I'll remove it completely. – Adrian Willenbücher (talk) 09:39, 22 September 2011 (UTC)[reply]

While I personally agree with the view that functional languages (especially the impure/strict variants) are not declarative (nor do I consider Prolog to be), these languages are overwhelmingly described as such in reliable sources. You would need to find some equally reliable sources that support your reasoning. —Ruud 07:31, 27 September 2011 (UTC)[reply]
Some arguments that functional languages are declarative would be that in lazy functional languages the programmer does not have to worry in which order the computations are performed, they are automatically executed in an order that "just works". —Ruud 07:37, 27 September 2011 (UTC)[reply]
I would like to see this "overwhelming" evidence in reliable sources. Further points:
  • By your reasoning, only pure, non-strict functional programming languages are declarative. That's quite a difference to functional programming languages in general.
  • In what way is Prolog not declarative? That's the archetype of declarative programming languages.
  • "Some arguments that functional languages are declarative would be that in lazy functional languages the programmer does not have to worry in which order the computations are performed, they are automatically executed in an order that 'just works'."
That argument doesn't work:
  • Just because the order of evaluation isn't determined by the programmer, doesn't mean that the programmer doesn't define the "how". Consider the following Haskell code:
fac 0 = 0
fac n = n * fac (n - 1)
This is purely functional code, but it still defines how to compute the factorial, even if it is evaluated in a lazy, out-of-order, way.
  • C doesn't define an order of evaluation either, and yet you wouldn't say that it is declarative, would you?
My point is not that functional programming is completely distinct from declarative programming; rather that FP it is not a subset of DP. Even if some functional programming languages are considered declarative, that doesn't mean that FP in general is declarative; you could design an object-orient language with pure semantics (i.e., no state, only non-destructive update), and yet you don't consider OO to be a subset of declarative programming. – Adrian Willenbücher (talk) 09:24, 27 September 2011 (UTC)[reply]
In th factorial example the order of evaluation is very obvious to infer from the definition, this is no longer the case in, for example, the rep-min problem or when working with attribute grammars. And yes, compilers for imperative languages have some room when deciding the order of evaluation for simple expressions, but in the end most side-effect have to happen in the order the programmer dictated. If you have done any substantial programming in Prolog, you'll know that for solving any non-trival problem you'll have to heavily rely on the order in which the backtracking algorithm tries to unify Horn-clauses (the order of which is determined by the order in the source code) and ofcourse the usual reliance on the cut operator. To me Prolog has an even more imperative feel than Haskell. I don't know of any truly declarative language in the ideal sense of the word. Perhaps CPLEX linear programming problem instances come close, but it's a bit of a stretch to call that a programming language. My and your personal opinion aside, pick up a few book listed Programming language#Further reading and they will likely divide the language landscape into imperative and declarative language, with declarative languages being composed of functional and logic programming languages. —Ruud 09:47, 27 September 2011 (UTC)[reply]
I agree that our personal opinions don't really matter, but reliable sources do (and I shouldn't push my agenda here). I found at least one source that lists FP alongside declarative programming (Finkel: Advanced Programming Language Design), without any mention of one being a subset of the other. However, I also acknowledge that some sources make this classification. How about we present the complete picture: some authors consider FP to be a subset of DP, some don't? That would be the way to do it in an encyclopedia. – Adrian Willenbücher (talk) 11:31, 27 September 2011 (UTC)[reply]
Sure, as a tertiary source Wikipedia articles should simply summarize secondary sources. So any statement about functional languages being or not being declarative languages you can find in reliable source, would be good additions to the article. Simply removing the section on functional languages didn't seem like an improvement though. —Ruud 11:38, 27 September 2011 (UTC)[reply]
Also, while I'm not completely sure about the etymology of imperative vs. declarative, I think it's because languages like COBOL and FORTAN programs are lists of imperatives (statements), while LISP and Prolog programs are lists of declarations (definitions, equalities, implications, ...) The part about declarative languages allowing you to state only what the problem is and not explicitly how to solve it, is probably only some (academic) marketing-speak invented later and which doesn't fully hold for any declarative language. —Ruud 11:38, 27 September 2011 (UTC)[reply]
Actually, as far as I know, LISP is very imperative for a functional language. Regarding terminology: calling a language "declarative" just because it contains a lot of declarations is not very useful today, since basically all languages (except for those that are strongly based on the lambda calculus or Turing machines) contain a lot of declarations (variables, functions, classes, etc.). Some authors call a language "declarative" iff variables are explicitly declared. As for your last sentence ("...which doesn't fully hold for any declarative language."): the boundary between "how" and "what" is rather fuzzy; for example, does this function state an algorithm ("how"), or a declaration ("what"), assuming that product is a function defined earlier:
fac n = product [1 .. n]

Adrian Willenbücher (talk) 12:44, 27 September 2011 (UTC)[reply]

It even claims that functional is declarative because the compiler might rewrite the functions. Well in that case, C is declarative too! Whoopsie. 2001:470:1F04:3DF:0:0:0:2 (talk) 22:07, 5 July 2013 (UTC)[reply]

Hello fellow Wikipedians,

I have just added archive links to one external link on Declarative programming. Please take a moment to review my edit. If necessary, add {{cbignore}} after the link to keep me from modifying it. Alternatively, you can add {{nobots|deny=InternetArchiveBot}} to keep me off the page altogether. I made the following changes:

When you have finished reviewing my changes, please set the checked parameter below to true to let others know.

This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}} (last update: 5 June 2024).

  • If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
  • If you found an error with any archives or the URLs themselves, you can fix them with this tool.

Cheers. —cyberbot IITalk to my owner:Online 08:30, 17 October 2015 (UTC)[reply]

vandalism

In the page-preview for the first mention of "SQL" — Preceding unsigned comment added by 142.161.137.88 (talk) 23:32, 12 June 2019 (UTC)[reply]