Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.
  • Which are C# 4.0 programming paradigms?
  • In what category does extension methods fall into?

A programming language can support multiple paradigms. For example, programs written in C++ or Object Pascal can be purely procedural, or purely object-oriented, or contain elements of both paradigms.

In object-oriented programming, programmers can think of a program as a collection of interacting objects, while in functional programming a program can be thought of as a sequence of stateless function evaluations. When programming computers or systems with many processors, process-oriented programming allows programmers to think about applications as sets of concurrent processes acting upon logically shared data structures.

Just as different groups in software engineering advocate different methodologies, different programming languages advocate different programming paradigms.

Source: Wikipedia

share|improve this question
3  
This question is very vague. Could you be more specific? –  MatthewKing Mar 23 '11 at 8:10
    
@Joviee According to definition, en.wikipedia.org/wiki/Programming_paradigm there should be a handful of paradigms in any language. –  Amir Rezaei Mar 23 '11 at 8:21
add comment

1 Answer

up vote 2 down vote accepted

C# done right is to use it in an object oriented way as the object oriented paradigm is it's main pillar. This has a heavy impact on your program structure, much more than the functional elements of C#.

You can use the functional elements (LinQ) when they make a solution to a problem easier to express, to simplifiy implementations. This feature/paradigm is not meant to structure a whole program.

For easy tasks, you can use C# in a purely imperative way.

But: C# should never be programmed in a procedural way (for example methods with many out arguments).

So, to answer your questions: C# is based upon an imperative, object oriented paradigm with declarative/functional elements.

Extension Methods are just syntactic sugar to extend an existing class, so you don't need to derive from it. I'd say they're an element of object oriented programming, as they allow you to work on instances of objects and they allow you to extend existing classes with external components.

share|improve this answer
    
Unfortunately C# doesn't support some of the really interesting functional aspect like currying functions. Sometimes I just really wish that some of the languages I use all the times supported this one really cool idea natively. I also wouldn't compare LINQ to functional programming. It's a great declarative way to process data, but it's not really functional programming. –  Matthew Scharley Mar 23 '11 at 9:06
    
+1 For "imperative, object oriented paradigm with declarative/functional elements", and identifying functional part of C#. –  Amir Rezaei Mar 23 '11 at 9:10
1  
s\it's\its\g (I would edit it, but I don't find anything else substantial to edit, and one has to change 6 chars at least (stupid rule, isn't it ;-)) –  fretje Mar 23 '11 at 9:12
    
@Matthew You can do currying functions. –  Amir Rezaei Mar 23 '11 at 9:13
1  
@Amir you can do it, but it's a pain, and it's not supported as a first class citizen. In languages like F# you can for instance call a function with two parameters with one, and instead of a result you will get back a function pointer that takes one parameter. –  Matthew Scharley Mar 23 '11 at 9:20
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.