tags:

views:

263

answers:

3

im preparing for my exam. i got this question and i read several articles about this. but still i cant get a proper idea about this question

what Paradigm means is that different programming styles ( as far as i think)

in the question they ask explain it by taking two paradigms

so this explanation should be done using two styles of programming

"List Comprehnsions or Primitive Recursion, Higher order functions " is these styles are programming paradigms??

please help me

+2  A: 

Wiki defition for Programming Paradigm: http://en.wikipedia.org/wiki/Programming_paradigm

As for Haskell, it's categorize under functional paradigm.

"List Comprehnsions or Primitive Recursion, Higher order functions" are features of Haskell which makes it a Functional Paradigm language.

mcabral
so this Higher order functions and list comprehensions are functional paradigms.. is it
Nubkadiya
No. A paradigm (in a quick and simple definition) is a way to solve a problem. For a language to match the functional paradigm, it has to provide referential transparency and high order functions, features Haskell provides.
mcabral
+3  A: 

Paradigm means functional, imperative, object-orientated etc.

That is, whether you write a program as

-- Functional : Prefer stateless functions, recursion, etc.
fac 0 = 1
fac 1 = 1
fac n = fac (n-1) * n

or

// Imperative : Prefer mutable states, loops, etc.
int fac (int n) {
   if (n <= 1) return 1;
   int val = 1;
   for (int i = 2; i < n; ++ i) val *= i;
   return val;
}

List comprehensions, higher order functions are just features of a language. You may also have these in an imperative-biased language e.g. Python and Javascript.

KennyTM
oh. so when i have to take 2 examples i have to talk about functional programming and imperative programming
Nubkadiya
+8  A: 

"Paradigm" is a word used by people who would rather put things in neat boxes than think deeply about what's going on. Use it only under duress. People talk about "imperative", "functional", "object-oriented", and "logic" paradigms. Some people talk about a "scripting" paradigm. Why don't people talk about a "concurrent" paradigm? I don't know. "Paradigms" might be useful for passing examinations. I know they are useful for selling textbooks. They are not especially useful for thinking about programming languages, or for learning how to use programming languages effectively.

"List Comprehnsions or Primitive Recursion, Higher order functions " is these styles are programming paradigms??

These are neither styles nor paradigms.

  • List comprehensions is a kind of syntactic sugar that originated in functional languages, was made popular by Haskell, and has been copied by Python. They are inspired by informal set notation as used by mathematicians, and they are very powerful, concise ways of notating the computation of some lists. But list comprehensions easily reduce to applications higher-order functions like map and filter.

  • Higher-order functions are a fundamental feature, found in all languages that call themselves "functional". (There is not complete agreement on exactly what "a functional language" means, but whatever it means, it is agreed that the meaning includes higher-order functions.) In a language with higher-order functions, a function can return a new function as a result. For example, this is the compose function:

    compose f g = \x -> f (g x)
    

    If a function takes a function as argument, this is also higher-order, but to be called proper higher-order functions, the language must be able to return new functions as results.

  • Primitive recursion is a computational technique, and "primitive recursive" characterizes a set of mathematical functions that can be computed using that techique. The classification is extremely restrictive: functions written using only primitive recursion (as opposed to general recursion) always terminate. Primitive recursion is not normally associated with any particular programming language or (ugh) paradigm.

Norman Ramsey