imperative-programming

Are we in a functional programming fad?

I use both functional and imperative languages daily, and it's rather amusing to see the surge of adoption of functional languages from both sides of the fence. It strikes me, however, that it looks rather like a fad. Do you think that it's a fad? I know the reasons for using functional languages at times and imperative languages in oth...

What is meant by imperative and interrogative code

My Manager asked me to code in ASP.net. What is meant my imperative and interrogative code. How it related to programmers? ...

Mixing object-oriented and functional programming

What languages are available that promote both object-oriented and functional programming? I know that any language that supports first-class functions can be considered functional, but I'm looking for a syntax that's specifically targeted for both coding styles. Using such a language, I'm imagining isolating all state changes to a sing...

Haskell vs. procedural programming in the real world

These days I'm getting seriously into functional programming. While I'm really excited about Haskell and the possibilities it seems to offer, I can also see now that it is going to take me a while to learn. In an SO question on How to learn Haskell an answer states that it'll take months if not years to actually "master" it. Now, I kn...

Are programs in functional languages more likely to have stack overflows?

I am starting to learn ocaml, and am really appreciating the power of recursion in the language. However, one thing that I am worried about is stack overflows. If ocaml uses the stack for function calls, won't it eventually overflow the stack? For example, if I have the following function: let rec sum x = if x > 1 then f(x - 1) + x...

F# remove imperative code - quick help

I'm new to functional world and appreciate help on this one. I want to SUPERCEDE ugly imperative code from this simple function, but don't know how to do it. What I want is to randomly pick some element from IEnumerable (seq in F#) with a respect to probability value - second item in tuple (so item with "probability" 0.7 will be picked...

How is Java an 'imperative' programming language and not a 'declarative' one?

Specially in comparison to C/C++ (which are declarative), how is Java imperative? ...

Is functional Clojure or imperative Groovy more readable?

OK, no cheating now. No, really, take a minute or two and try this out. What does "positions" do? Edit: simplified according to cgrand's suggestion. (defn redux [[current next] flag] [(if flag current next) (inc next)]) (defn positions [coll] (map first (reductions redux [1 2] (map = coll (rest coll))))) Now, how about this vers...

Is functional programming a subset of imperative programming?

One of the main characteristics of functional programming is the use of side-effectless functions. However, this can be done in an imperative language also. The same is true for recursion and lambda functions (for example C++0x). Therefore I wonder whether imperative programming languages are a superset of functional ones. ...

what is the difference between declarative and imperative 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 any one have a real world example that they could show me that might bring some perspective...

Idiomatic clojure for progress reporting?

How should I monitor the progress of a mapped function in clojure? When processing records in an imperative language I often print a message every so often to indicate how far things have gone, e.g. reporting every 1000 records. Essentially this is counting loop repetitions. I was wondering what approaches I could take to this in cloj...

Statements and state

Is there any deeper meaning in the fact that the word "statement" starts with the word "state", or is that just a curious coincidence? Note that english is not my native language, so the answer might be obvious to you, but not me ;) ...

Does anyone else think instance variables are problematic in database-backed applications?

It occurs to me that state control in languages like C# is not well supported. By this, I mean, it is left upto the programmer to manage the state of in-memory objects. A common use-case is that instance variables in the domain-model are copies of information residing in persistent storage (i.e. the database). Clearly this violates the ...

Declarative / Imperative Cross Over

I'm looking for a way to gain reference to a class that was instanciated via XML, but I need reference to it in imperative code. I usually do this via the datacontext of the control, but in this case, the user control does not have declaritive reference to the class that I require. I know I have seen how to gain a reference to a class ...

Fascinated by FP but still think imperative, how do I think functional ?

Like most ppl, I started with and still do a lot of imperative code(mostly Java, Ruby, Javascript). I've never been a big fan of OO, either because I never understood it properly or because I don't think OO. Got my first glimpse of FP via javascript, passing functions around, closures, etc. Have been in love with FP since then. Rece...