Originally Posted by Plan9
I know what pure functional means and I'm well aware that languages can support the function paradygm as well as other language paradigms. This is why I made the point of saying "pure functional" in terms of some languages to make the distinction between multi-paradigm languages and ones that are not. (ie the point you've now just reiterated).
I'm well aware they're not mutually exclusive. I've also made that point several times in this thread.
This thread was really the concepts I was trying to compare - and that was only because I'm still trying to wrap my head around the full complexities of functional programming (I keep reading that it's supposed to be very hard concept, yet I've found it remarkably easy to apply what I've understood to be functional paradigms to my projects (and have always written code that way). Which leads me to think that I've not completely understood the full complexities)
The arguments about which languages are of what paradigm is more a tangent that myself and hajile have taken - albeit one that I've also found quite interesting.
How would you describe the differences between writing functional and imperative code?
Great. Sorry for the confusion.
Basically, in functional code, you write the code as an expression that you want the computer to return, without caring how exactly the computer deals with it. The easiest way to describe is using an analogy of functional recursion. Functional languages (which are declarative) don't allow a sequence of instructions or standard while/for loops, and therefore, must rely on recursion. So, for example, if you're writing a number that finds the factorial of a number n, you wouldn't use a for loop with a counter that goes from 0 to n, but the standard recursion algorithm. So, essentially, your whole mindset should change when you switch to functional programming from imperative programming. You don't want to tell the computer how to do something, but what to return, in terms of the data you have.
Further points might be that, pure functional languages don't modify data or variables once they're set, and don't cause any external side effects. Also, since the whole code is basically just a set of functions, the code is much more re-usable and adaptable, allowing for libraries of pre-defined functions to be included with a language specification, making it higher level, in a sense.
In general, functional code is much more concise and easier to read than imperative code, and therefore, allows for spending less time coding, but more time thinking about a solution.
So, even though, the idea of functional programming might not be very hard to grasp, actually changing your mind to think in a completely different way is much harder.