Questions tagged [imperative-programming]
The imperative-programming tag has no usage guidance.
35
questions
14
votes
7
answers
8k
views
Is declarative programming just imperative programming 'under the hood'?
From my understanding, in declarative programming, programmer only need to define the end result, but not how to compute it. But for execute that said function, the function must be pre-defined by the ...
0
votes
1
answer
95
views
How are asynchoronous problems handled with imperative programming?
Context
To level set, I've been working with OOP and FP for my whole career, so my experience with the imperative paradigm is limited. The team I joined is made up of very senior (20+ years xp) ...
3
votes
5
answers
826
views
Is assignment declarative or imperative?
On Wikipedia, the article Programming paradigms defines
declarative as a paradigm in which the programmer merely declares properties of the desired result, but not how to compute it;
imperative as a ...
7
votes
3
answers
909
views
Functional architecture with lots of I/O
I'm learning about "Functional Core, Imperative Shell" as espoused by Gary Bernhardt in his talk about "Boundaries". In reality, it seems like these ideas have been known for a ...
0
votes
1
answer
149
views
Imperative parallels to Haskell's Monad operations
Would it be (mostly) correct to say that the following are the parallels to the Haskell Monad operations in the imperative world?
Monad's >> ~ C/C++/JavaScript/etc. , operator
do expressions ~ ...
14
votes
6
answers
2k
views
Is "Low Code" declarative by default?
Something that has really be getting under my skin recently is that Salesforce uses the term "Declarative Development" to mean "Low Code" or "visual code".
For example, this article explains the ...
4
votes
1
answer
105
views
Is a generic data structure customary for use in a self contained program, or can I duplicate source files?
I have a project that does some Dijkstra searches on a graph, I implemented a red-black tree and priority queue that I use for the nodes, however I also need the same data structures for other things ...
1
vote
2
answers
323
views
What is the difference in the implementation of a monad in a purely functional language with respect in an imperative language?
For a long time, the use of these Monad structures has been restricted to a very small circle of languages, many of them purely functional (mainly due to problems related to the management of the IO). ...
12
votes
4
answers
2k
views
Why usage of assignment operator or loops discouraged in functional programming?
If my function meets the two requirements listed below, I believe that the function Sum returns the summation of the items in a list, where item evaluates as true for a given condition. Doesn't this ...
11
votes
3
answers
4k
views
Do functional programming languages disallow side effects?
According to Wikipedia, Functional programming languages, that are Declarative, they disallow side effects. Declarative programming in general, attempts to minimize or eliminate side effects.
Also, ...
4
votes
2
answers
644
views
Dynamic dispatch with captured data in C?
I'm trying to reconcile my object-oriented/functional mind with programming in a language with C. Let's say I want to achieve dynamic dispatch in C, say I want to have a collection of tasks to execute....
4
votes
1
answer
397
views
Can heavy use of the service pattern substitute pure functions without losing benefits?
There are huge benefits to pure functions in functional programming, but can the same benefits be obtained in imperative programming with heavy use of the service pattern?
I ask because I want to ...
1
vote
0
answers
309
views
What are the types of tasks for which Functional Programming paradigm really wins over imperative one? [closed]
During its evolution C# gradually gets more and more features which belong to functional paradigm.
Subjectively these features allow (at least me) to be more productive, fluent and write maintainable ...
3
votes
2
answers
198
views
What is the most idiomatic way to iterate collection with different action for first element?
Sometimes we meet a situation where we should iterate (or map) over a collection, applying the same procedure (function) for all elements except the first one. The simplest example is finding the max ...
3
votes
3
answers
548
views
Declarative programming for deterministic real time control
Let's say you want control a motor in real time. Normally you would use a microcontroller or PC with e.g. c-programming language. So you would use an imperative approach. You tell the microcontroller ...
5
votes
2
answers
4k
views
Is declarative programming overrated? [closed]
I've been programming for years with primarily-imperative languages (C++, C#, javascript, python), but have recently experimented with some functional langauges (Lisp, Haskell) and was excited to try ...
57
votes
4
answers
7k
views
Development process used for the code on Apollo 11 missions?
The Apollo missions had technology no more complicated than a pocket calculator.
From link here, there's an information about Apollo Guidance Computer (AGC)
The on-board Apollo Guidance Computer (...
11
votes
2
answers
2k
views
Functional programming, compared to the process of a computer [duplicate]
In functional programming, it is considered bad practice (at least from my observations) to use state changes. Since computers operate in an imperative-language-like matter (performing one operation ...
18
votes
5
answers
7k
views
What makes functional programming languages declarative as opposed to Imperative?
On many articles, describing the benefits of functional programming, I have seen functional programming languages, such as Haskell, ML, Scala or Clojure, referred to as "declarative languages" ...
3
votes
1
answer
4k
views
Advantages of the imperative style over the functional style [duplicate]
There's a lot of hype over functional languages right now, and I've spent the last year studying Haskell as my intro to FP as a result. Seeing the advantages FP provides is easy (such as referential ...
1
vote
1
answer
278
views
How do I enforce 'referential transparency' in this program?
Below is the python program written to follow the rule of thumb in functional programming.
The simple rule of thumb is: if you can replace any expression, sub-expression or subroutine call with the ...
8
votes
5
answers
54k
views
How to structure a loop that repeats until success and handles failures
I am a self-taught programmer. I started programming about 1.5 years ago. Now I have started to have programming classes in school. We have had programming classes for 1/2 year and will have another 1/...
0
votes
1
answer
414
views
How to encourage to write pure functions in imperative environments? [closed]
In functional programming languages, a developer is always cautious about writing pure functions. Some functional languages simply do not allow impure functions, and some other functional languages ...
3
votes
2
answers
316
views
Cognitive Modeling Programming vs Imperative Programming vs Declarative Programming
I'm reading this article by John Funge about Cognitive Modeling for Computer Games: http://www.qrg.northwestern.edu/resources/aigames.org/1999/fungegame99.pdf
And some further detailed reading about ...
2
votes
5
answers
2k
views
Is it possible to use functional paradigm in imperative languages?
If I understand the concept correctly the goal, which functional languages are trying to achieve is to eliminate any side effects from functions and to eliminate a state. The rationale behind this is ...
2
votes
3
answers
670
views
Inheritance in imperative programming
My first introduction to programming was Java, which was horrible so I learnt Actionscript3 which was nice... "The point is" OOP was my introduction to programming where by I went on to gain a career ...
4
votes
1
answer
5k
views
how to enumerate/generate all possible binary trees from N leaves and N-1 nodes?
I am trying to implement the 24 Game in ansi C. This game goes as follows:
For a list of four given numbers, try to find a solution involving these four numbers, that, using addition(+), subtraction(-...
40
votes
4
answers
13k
views
What is referential transparency?
I have seen that in imperative paradigms
f(x)+f(x)
might not be the same as:
2*f(x)
But in a functional paradigm it should be the same. I have tried to implement both cases in Python and Scheme, ...
1
vote
1
answer
1k
views
Mixing declarative & imperative code (Implicit 'unit tests' ?) [closed]
Well I'm no expert, but as a student, I'm curious about languages and their design patterns / goals.
I'd like to know, whether there are any points I miss in the following examples, and why ...
10
votes
5
answers
956
views
Can a pure-functional solution to this problem be as clean as the imperative?
I have an exercise in Python as follows:
a polynomial is given as a tuple of coefficients such that the powers are determined by the indexes, e.g.: (9,7,5) means 9 + 7*x + 5*x^2
write a function to ...
13
votes
1
answer
16k
views
Why is imperative programming preferred over functional programming? [closed]
Background: I am proponent of functional programming who works at a VB.NET shop where the prevailing mental model is imperative programming. Being that foundation of our system is WinForms I can ...
6
votes
2
answers
2k
views
Differences between imperative-language and functional-language debuggers
Up to now I have always worked with imperative languages like Pascal, C, C++, Java in a production environment, so I have experience with debuggers for these languages (Turbo Pascal, Turbo C, GDB / ...
5
votes
2
answers
359
views
Does the structured programming definition only consider imperative programming?
Does the structured programming definition only consider imperative programming? By this I mean does the definition of structured programming automatically exclude functional programming (in the most ...
13
votes
4
answers
18k
views
Example of where Functional Programming is Superior to Imperative or Object-Oriented Programming? [duplicate]
Possible Duplicate:
Which problems domains are more suited to functional programming solutions
I've been reading about functional programming. I've been using mostly C#.net recently, and I ...
113
votes
4
answers
72k
views
What's The Difference Between Imperative, Procedural and Structured Programming?
By researching around (books, Wikipedia, similar questions on SE, etc) I came to understand that Imperative programming is one of the major programming paradigms, where you describe a series of ...