Questions tagged [declarative-programming]

Declarative programming is a paradigm of expressing the logic of a computer program or computation without explicit describing its control flow.

78 questions
794
votes
21 answers

What is the difference between declarative and imperative paradigm in programming?

I have been searching the web looking for a definition for declarative and imperative programming that would shed some light for me. However, the language used at some of the resources that I have found is daunting - for instance at Wikipedia. Does…
Brad
  • 20,302
  • 36
  • 84
  • 102
121
votes
8 answers

What is the difference between declarative and procedural programming paradigms?

What is the difference between the declarative and procedural programming paradigms? Could you please provide some examples? What other programming paradigms exist?
Tarik
  • 79,711
  • 83
  • 236
  • 349
69
votes
3 answers

What are the Open Source alternatives to WPF/XAML?

If we've learned anything from HTML/CSS it's that, declarative languages (like XML) do a good job of describing User Interfaces because: It's easy to build code preprocessors that can template the code effectively. The code is in a well defined…
Evan Plaice
  • 13,944
  • 6
  • 76
  • 94
62
votes
6 answers

Functional Programming Vs Declarative Programming Vs Imperative Programming

I have been too used to Imperative Programming which is the usual way of telling the computer to perform step by step the procedure to get the final result. On the other hand, declarative programming just passes the input and expects the output…
53
votes
6 answers

What is PassthroughSubject & CurrentValueSubject

I happen to look into Apple's new Combine framework, where I see two things PassthroughSubject CurrentValueSubject Can someone explain to me what is meaning & use of them?
Nasir
  • 1,617
  • 2
  • 19
  • 34
15
votes
5 answers

Is C an imperative or declarative programming language

It is quite confusing to know difference between Imperative and Declarative programming can any one explain difference between both in real world terms? Kindly clarify whether C is an Imperative or Declarative Language?
AshrithGande
  • 351
  • 1
  • 10
  • 25
13
votes
7 answers

Translating Imperative Java to Functional Java (A Game)

I'm learning a lot more about Java 8 and its functional capabilities, and I wanted to do some more practice with it. Say, for example, I have the following imperative code which is for wrapping a circle around the bounds of the screen: if…
11
votes
2 answers

Is functional programming a type of declarative programming?

I am aware that declarative programming just passes the input and expects the output without stating the procedure how it is done. In functional programming, is a programming paradigm, which takes an input and returns an output. When I checked the…
MrRobot9
  • 2,402
  • 4
  • 31
  • 68
8
votes
7 answers

Java Functional Programming: How to convert a if-else ladder inside for loop to functional style?

The expectation is derive 3 lists itemIsBoth, aItems, bItems from the input list items. How to convert code like below to functional style? (I understand this code is clear enough in an imperative style, but I want to know does declarative style…
7
votes
2 answers

Why doesn't mxml support component constructors?

Why doesn't the Flex framework's mxml language support a constructor for components or accept constructor arguments for components? It's as far as I know not possible to declare an ActionScript object in mxml if it takes constructor arguments. I'm…
Gunnar Karlsson
  • 28,350
  • 10
  • 68
  • 71
4
votes
4 answers

How do I declaratively create a list in Scala?

In C# I can declare a list declaratively, in other words declare its structure and initialise it at the same time as follows: var users = new List { new User {Name = "tom", Age = 12}, new User {Name…
Rupert Bates
  • 3,041
  • 27
  • 20
4
votes
2 answers

All substrings with same begin and end

I have to solve a homework but I have a very limited knowledge of Prolog. The task is the following: Write a Prolog program which can list all of those substrings of a string, whose length is at least two character and the first and last character…
K. Nagy
  • 43
  • 2
4
votes
2 answers

Prolog loop after results

So I wrote this predicate to find all possible subsets + permutations of a list. I get the correct output but for some reason the program keeps looping after giving me all the (correct) results. What am I doing wrong? % Gets all subsets of a…
3
votes
3 answers

Replacing imperative PriorityQueue in my algorithm

I currently have a method that uses a scala.collection.mutable.PriorityQueue to combine elements in a certain order. For instance the code looks a bit like this: def process[A : Ordering](as: Set[A], f: (A, A) => A): A = { val queue = new…
3
votes
2 answers

Prolog ways to compare variables

I was trying to implement some graph algorithms in Prolog. I came up with an idea to use unification to build a tree from the graph structure: The graph would be defined as follows: A list of Vertex-Variable pairs where Vertex is a constant…
egst
  • 1,605
  • 3
  • 18
  • 25
1
2 3 4 5 6