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.

I have heard several times that every programmer should learn one of each type of language. Now, this is not necessarily true, but I believe it is a good idea.

I've learned a Procedural Language (Perl), but what are the other types?

What are the differences between them and what are some examples of each?

share|improve this question
7  
You should be aware that there are countless overlapping ways to categorize languages. The most common is by programming paradigm, but even then there are major and minor distinctions, many completely seperate axis, and many languages fall into several paradigms. –  delnan Oct 31 '11 at 19:34
1  
I'd forget about the categories--if you are really interested in learning from a language I'd suggest both Lisp and Scala, if you can handle those two you've covered a lot of ground. –  Bill K Oct 31 '11 at 21:13
2  
Peter Norvig's advise: Learn at least a half dozen programming languages. Include one language that supports class abstractions (like Java or C++), one that supports functional abstraction (like Lisp or ML), one that supports syntactic abstraction (like Lisp), one that supports declarative specifications (like Prolog or C++ templates), one that supports coroutines (like Icon or Scheme), and one that supports parallelism (like Sisal). –  legends2k Feb 11 at 8:06
add comment

4 Answers 4

up vote 25 down vote accepted

Even though terminology is far from standardized, a common way to is categorize major programming paradigms into

  • Procedural
  • Functional
  • Logical
  • Object-Oriented
  • Generic

You seem to already know what procedural programming is like.

In functional languages functions are treated as first-class objects. In other words you can pass a function as an argument to another function, or a function may return another function. Functional paradigm is based on lambda calculus, and examples of functional languages are LISP, Scheme, and Haskel. Interestingly, JavaScript also supports functional programming.

In logical programming you define predicates which describe relationships between entities, such as president(Obama, USA) or president(Medvedev, Russia). These predicates can get very complicated and involve variables, not just literal values. Once you have specified all your predicates, you can ask questions of your system, and get logically consistent answers.

The big idea in logical programming is that instead of telling the computer how to calculate things, you tell it what things are. Example: PROLOG.

Object-oriented paradigm is in some ways an extension of procedural programming. In procedural programming you have your data, which can be primitive types, like integers and floats, compound types, like arrays or lists, and user-defined types, like structures. You also have your procedures, that operate on the data. In contrast, in OO you have objects, which include both data and procedures. This lets you have nice things like encapsulation, inheritance, and polymorphism. Examples: Smalltalk, C++, Java, C#.

Generic programming was first introduced in Ada in 1983, and became widespread after the introduction of templates in C++. This is the idea that you can write code without specifying actual data types that it operates on, and have the compiler figure it out. For example instead of writing

void swap(int, int);
void swap(float, float);
....

you would write

void swap(T, T);

once, and have the compiler generate specific code for whatever T might be, when swap() is actually used in the code.

Generic programming is supported to varying degrees by C++, Java, and C#.

It is important to note that many languages, such as C++, support multiple paradigms. It is also true that even when a language is said to support a particular paradigm, it may not support all the paradigm's features. Not to mention that there is a lot of disagreement as to which features are required for a particular paradigm.

share|improve this answer
2  
Which category would SQL fall into? –  Kirk Kuykendall Oct 31 '11 at 22:46
    
@KirkKuykendall SQL would be a specialist, or "little", language. –  lacqui Oct 31 '11 at 23:22
12  
SQL is a Declarative language. You tell it what you want, it figures out how to get it. ("Logical" languages like Prolog are a different subset of Declarative languages) –  Izkata Nov 1 '11 at 1:47
1  
Could we have a description of procedural, in order to make the answer more complete? –  deworde Nov 2 '11 at 13:50
3  
@Dima Nice summary. However, a relatively minor nitpick: "generic programming" didn't came about from the use of templates in C++, and is also very frequently used in functional languages such as Haskell. –  Andres F. Jan 30 '12 at 1:02
show 2 more comments

Programming languages have a number of mostly orthogonal features; the most prominent one lies in the paradigm or paradigms they support. The wikipedia article covers paradigms exhaustively; the most important paradigms are probably these:

  • Procedural / Structured
  • Functional
  • Object-Oriented
  • Event-Driven and Aspect-Oriented
  • Generic
  • Logic

But languages differ in other ways as well:

  • Typing system (dynamic vs. static typing, and strong vs. weak types)
  • Build process and runtime environment (interpreted, bytecode-compiled, fully compiled)
  • Memory management (manual like C / C++, mandatory automatic garbage collection like Java, optional GC like D, ...)
  • Evaluation discipline (eager vs. lazy; most languages are eager by default, but many provide lazy constructs)
  • Scoping rules (compare how scope works in PHP, Javascript and C, three languages that are otherwise quite similar in terms of syntax)
share|improve this answer
add comment

There are several different programming paradigms that are currently in vogue:

  • Object Oriented - VB.NET, C#, Java fall into this category. Code is arranged around objects that have behavior and related data and that communicate with each other by passing messages.
  • Functional - Haskel, Scheme, Lisp and F# fall into this category. Pure functions that do not have side-effects. Think functions like in maths. Often one can extend the language itself through its constructs.
share|improve this answer
    
Are these the only other types? –  Dynamic Oct 31 '11 at 19:25
    
@perl.j - No, but these are the main ones that see wide spread use these days. See wikipedia - Programming paradigm. –  Oded Oct 31 '11 at 19:26
    
@perl.j there is also Stack-based: such as Forth and Postscript. Logic: such as Prolog. –  Jetti Oct 31 '11 at 19:27
2  
And the zeroth type is C ;) –  yati sagade Oct 31 '11 at 19:44
    
@Downvoter - care to comment? –  Oded Oct 31 '11 at 20:40
show 1 more comment

Prolog is a logic programming language and is relatively easy to get started with. It requires a completely different thinking than procedural programming therefore it is good to explore when you are trying to stretch your brain.

If you go to college, you should take a course on Programming Languages as it is geared towards introducing the different types of programming languages and what they are best used for.

share|improve this answer
add comment

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.