Take the 2-minute tour ×
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It's 100% free, no registration required.

I'm pretty fluent in C/C++, and can make my way around the various scripting languages (awk/sed/perl). I've started using python a lot more because it combines some of the nifty aspects of C++ with the scripting capabilities of awk/sed/perl.

But why are there so many different programming languages ? I'm guessing all these languages can do the same things, so why not just stick to one language and use that for programming computers ? In particular, is there any reason I should know a functional language as a computer programmer ?

Some related reading:

share|improve this question
1  
there is also a difference between OO and non-OO. Plus, some languages come with nice packages: R, Maple, Matlab, Mathematica that are often lacking from other languages. –  Artem Kaznatcheev Mar 17 '12 at 6:30
45  
i.stack.imgur.com/35yc5.png –  Dai Mar 17 '12 at 6:32
    
The articles you added are certainly interesting, especially the point made in the second one that there is no scientific evidence that one programming language is better (in terms of productivity) than another. But as someone who regularly tries new programming languages, I cannot deny the convenience of the abstractions offered by more modern languages. In terms of research still to be done: sure, all the main fruits have been picked and the paradigms have been defined, but there is definitely more to do. –  Dave Clarke Mar 17 '12 at 21:01
3  
Already ask on Programmers programmers.stackexchange.com/q/7551/45322 –  alain.janinm Mar 19 '12 at 21:39
1  
For implementing parallel algorithms, functional programming is better, in general when you have mutable objects, it's better to use OO paradigm, else (if you want deal with immutable objects) it's better change it to functional model. This scenario widely exists in parallel processing. Also some of excellent OO patterns, like fluent interface and method chaining are working like functional paradigm. –  user742 Aug 20 '12 at 0:16

11 Answers 11

up vote 67 down vote accepted

Programming languages evolve and are improved with time (innovation).

People take ideas from different languages and combine them into a new languages. Some features are improved (inheritance mechanisms, type systems), some are added (garbage collection, exception handling), some are removed (goto statements, low-level pointer manipulations).

Programmers start using a language in a particular way that is not supported by any language constructs. Language designers identify such usage patterns and introduce new abstractions/language constructs to support such usage patterns. There were no procedures in assembly language. No classes in C. No exception handling in (early) C++. No safe way of loading new modules in early languages (easy in Java). No built-in threads (easy-peasy in Java).

Researchers think about alternative ways of expressing computations. This lead to Lisp and the functional language branch of the language tree, Prolog and the logic programming branch, Erlang and other actor-based programming models, among others.

Over time language designers/researchers and researchers come to better understand all of these constructs and how they interact and design languages that include many of the popular constructs, designed to work seamlessly together. This results in wonderful languages such as Scala, which has objects and classes (expressed using traits instead of single or multiple inheritance), functional programming features, algebraic data types integrated nicely with the class system and pattern matching, and actor-based concurrency.

Researchers who believe in static type systems strive to improve their expressiveness, allowing things such as typed generic classes in Java (and all of the wonderful things in Haskell), so that a programmer gets more guarantees before running a program that things are not going to go wrong. Static type systems often impose a large burden on the programmer (typing in the types), so research has gone into alleviating that burden. Languages such as Haskell and ML allow the programmer to omit all of the type annotations (unless they are doing something tricky). Scala allows the programmer to omit the types within the body of methods, to simplify the programmer's job. The compiler infers all the missing types and informs the programmer of possible errors.

Finally, some languages are designed to support particular domains. Examples include SQL, R, Makefiles, the Graphviz input language, Mathmatica, LaTeX. Expressing what these languages express in a general purpose language would be cumbersome. These languages are based on abstractions specific to their particular domain.

Without evolution in programming language design, we'd all still be using assembly language or C++.

As for knowing a functional programming: functional languages allow you to express computations differently, often more concisely than using other programming languages. Consider about the difference between C++ and Python and multiply it by 4. More seriously, as already mentioned in another answer, functional programming gives you a different way of thinking about problems. This applies to all other paradigms; some a better suited to some problems, and some are not. This is why multi-paradigm languages are becoming more popular: you can use constructs from a different paradigm if you need to, without changing language, and, more challengingly, you can mix paradigms within one piece of software.

share|improve this answer
1  
Fully agree. I am interested in where multi-paradigm languages (e.g. Scala) will be in a couple of years. If they allow easy DSL integration, we might actually see a gradual decline in language numbers. –  Raphael Mar 17 '12 at 11:11
2  
Very detailed answer! We could acknowledge that most programming languages might be Turing Equivalent, but that doesn't mean that the abstraction they support is suitable for every problem domain. –  CyberFonic Mar 21 '12 at 1:42

tldr: There is no silver bullet language.

I hope they won't sue me, but here is a pic from one of the Stanford presentations.

enter image description here

When you decide to pick a language, you can pick only 2 of these 3 features.

And that is why people are sad and want to invent a superlanguage that will cover all 3 of them.

Actually, there is a huge list of requirements (some of them you can see in other answers) but they just add details to the core features. Additionally, there are historical and political reasons to prefer one language over another.

Combinations of such factors yield a new language.

(And I've heard that every good programmer should make their own new language ;))

share|improve this answer
6  
Over time the triangle is shrinking, in the sense that the corners are getting closer together..... I hope/dream. –  Dave Clarke Mar 21 '12 at 12:25
    
Performance and Generality, can more o less be compared but I will add that experience in a language gives you more productivity than a certain language itself, it's not fair to compare "productivity of languages" alone, because you need the supposition of knowing and expertise them all, a very unlikely hypothesis. –  Hernan_eche May 23 '12 at 12:20
    
This is an interesting statement and kind of reminds me of the CAP theorem. Is this just an informal argumentation, or can the triangle be proven? –  evnu Aug 20 '12 at 10:29
    
@evnu, here's a quasiformal argument of one part: assuming generality means that valid programs of any length n in language L cover a larger problem space, each subspace of problems is only covered by some fractions of the length n programs. If the programs of length n outside your particular subspace were instead inside your subspace, you'd have greater odds of finding a shorter program which solved your problem (so you'd presumably be more productive), but the language would be less general---it'd solve problems in other subspaces less well (i.e. with longer programs). –  Jonas Kölker Feb 2 '13 at 15:35
    
This is a good argument that you need at least two programming languages, as well as a large number of domain-specific languages, thus covering all three sides of the triangle. We have many, many, many more than that. (And I'd put c at the top vertex of the triangle, but that's a fairly small niggle.) –  Peter Shor Oct 5 '13 at 23:31

The world is filled with things that have many different variations: word processors, cars, home designs, beverages, candy, pens, shovels, etc. The reasons why we have so many can be boiled down to a few principles:

  • Someone thinks they can improve on existing products
  • A different design is necessitated by local considerations (think: homes on stilts vs. homes on concrete slabs)
  • A new category of product fills a need where none existed before

Walk into any office supply store and look at the "writing instrument" section -- there are hundreds of varieties of pens. They all do roughly the same thing: deliver ink to a writing surface. But each pen you see displayed for sale is there because one of the three reasons above.

  • Cartridge fountain pens are an improvement on dipped fountain pens, which are themselves an improvement on feather quills.
  • NASA needed a pen that could write in the absence of gravity, so the pressurized rollerball pen was invented.
  • The very first pen itself may well have been a pointed stick dipped in tar or blood; prior to that people were scraping rocks together or smearing pigments on walls with fur. (Just a guess.)

The evolution of pens will continue since no one product fits the needs of every user. Some pens are cheap and disposable, some are expensive and built of high-quality materials; some use gels, some use ink, some use pigments; some have twist-off caps, some don't have caps at all; wide barrels, narrow barrels, round barrels, square barrels; short, long; red, white, black, blue. Etc, etc.

But enough about pens.

Our current myriad of programming languages can be traced back to the very first ones: the numeric machine codes for early computers back in the 1940s. Primitive, hard to use, and laborious to enter into the computer, but they did the job. It wasn't long after that programmers assigned mnemonic words (such as ADD, CALL, LOAD) to the machine codes, giving birth to the class of languages called "assembly languages."

Different processor architectures called for different mnemonic codes, depending on the specific features of the underlying machines. Taking these differences into account meant inventing different assembly languages.

(Perhaps by now you can see where this is going...)

Programmers looked at their assembly languages programs and saw patterns: the same sequences of instructions would be used to form loops, conditionals, variable assignment, function calls, and so forth. Thus, the procedural programming languages were born. These languages encapsulated groups of instructions under umbrella terms such as "if", "while", "let", etc.

Out of a mathematical analysis of computer programming came the functional languages -- a whole new way of looking at computation. Not better, not worse, just different.

And then there's object-oriented, statically typed, dynamically typed, late binding, early binding, low memory usage, high memory usage, parallelizable, languages for specific uses, and on and on.

Ultimately, we have different programming languages because we want different programming languages. Every language designer has their own ideas about how their "dream" language will look and operate. Diversity is a good thing.

share|improve this answer
    
I don't see any compelling reason given here for why we should have multiple languages besides that people want to for whatever reasons. –  Raphael Mar 21 '12 at 12:25
    
That's it exactly. Programmers are by nature problem-solvers. To solve problems, they need tools which often take the form of programming languages. If the tools can't help them solve their problem they way they want, they invent new tools. Think of it this way: since the tools are software and new software is written to solve new problems, the tools themselves can be problems to be solved. Those problems are solved by making new tools. –  Barry Brown Mar 21 '12 at 23:21

Functional programming languages are usually based on the different (but equivalent in power) model of computation: lambda-calculus. There are some untyped (has Python-like typing) languages such as LISP, Scheme (used in widely recognizable Structure and Interpretation of Computer Programs book/course) and statically-typed languages like Haskell, ML, F#.

SICP is what got me into functional programming, but other people recommend this paper by John Hughes and this interview with him.

Functional programming is now being push by Microsoft, for example, who have included F# (their functional language for .NET) in VS2010 and 11; they also employ some Haskell developers in MSR, IIRC.

Note, that there are also some non-lambda-calculus functional programming languages, such as Refal, which is based on pattern matching and rewriting.

Because the level of abstraction in functional languages is different, your attitude to solving problems changes, when you use functional programming techniques. Some say that it can make you a better programmer in general.

share|improve this answer
    
Another interesting class of languages is logic programming languages, such as Prolog. I only had a very limited experience with DataLog so maybe somebody else could write an answer about those? –  Daniil Mar 17 '12 at 6:30
2  
I agree that we need a programming language for each programming paradigm: imperative, OO, declarative, functional, etc. But this doesn't explain why we have so many, say, OO languages. –  Dai Mar 17 '12 at 6:36
    
@Dai, well, do we really? The theoretical foundation is not the only characteristic of a language. For example, one may say that a key feature of Java or C# is (comparing to C++) the virtual machine, which makes Java significantly different. –  Daniil Mar 17 '12 at 6:54
    
But then if C# and Java both use the virtual machine concept, why don't we use identical syntax for both languages? I think every designer has his/her strong ideas how his/her language should look like, and has the tendency to create his/her own standard. –  Dai Mar 17 '12 at 6:57
    
@Dai, there are a lot of minor differences between C# and Java, after all. Plus, I think there was some legal dispute over the Java VM for Windows or something of that sort. –  Daniil Mar 17 '12 at 6:59

There hardly could be a programmer who hasn't at some point in time become frustrated by the constraints of the language they were using and decided to scratch his itch. Thus a new language - or dialect of an existing one - is born.

Abadi and Cardelli in "A Theory of Objects" develop a whole family of programming languages from object-oriented foundations. They prove that functional programming is a special case of OO but not the converse.

Inventing something new is fun, that is why people are more likely to create yet another language than contribute to making an existing one better. Of course, there are custodians of languages who don't welcome changes to their vision. Best example being the chasm between Common Lisp and Scheme supporters.

share|improve this answer
2  
A Theory of Objects does not present a whole family of usable programming languages. It presents a foundation for object-oriented programming languages, and a strange one at that, being not based on classes. I don't see the connection between "A Theory of Objects" and functional programming. The object calculi have no notion of laziness, for example. There is also research encoding OO concepts in terms of functions and records, for example, the work by Pierce in the late 90s. –  Dave Clarke Mar 21 '12 at 20:14

In particular, is there any reason I should know a functional language as a computer programmer ?

Yes. Because haskell changed the way I think. It might change the way you think too.

Story: I used to think that I can learn any programming language in a day. One day I started Haskell. I finished everything that came before monads in half a day. Now its been a year since that day and I am still hopelessly stuck at Monads.

Read:

  1. Languages and thought wiki

  2. Notation as a tool for thought by Kenneth E. Iversion, Turing Award lecture

But why are there so many different programming languages ?

Notation is tool for thought. We need different tailor made notations to deal with different thoughts comfortably. So we create new languages.

Also, read. ;-)

share|improve this answer
1  
+1 for citing me to myself –  Suresh Mar 21 '12 at 1:53
2  
To recurse is divine! –  Pratik Deoghare Mar 21 '12 at 2:18
1  
to iterate is human ? –  Suresh Mar 21 '12 at 2:47
1  
Not sure if that was a good advert for Haskell. ;) –  Barry Brown Mar 21 '12 at 23:22
    
@Pratik Deoghare. Learning Haskell in a day was probably not a good idea. I would say, read a good text book on functional programming, such as Bird and Wadler, and take your time doing it. Then monads might not be so difficult. –  Uday Reddy Mar 22 '12 at 21:32

Since others have already given good answers for this question, I will just quote Alan Perlis.

Beware of the turing tar pit, in which everything is possible but nothing of interest is easy.

Also, http://weblog.raganwald.com/2004/10/beware-of-turing-tar-pit.html, is a good read.

share|improve this answer

Why are there so many different programming languages?

Because there are choices to be made:

  • Mode of specification: Imperative vs. functional
  • Typing: Statically typed vs. dynamically typed
  • Order of evaluation: call-by-value vs. call-by-name
  • Modularity: class-based vs. abstract data type-based
  • Execution model: sequential vs. concurrent

Fortunately, the last two are inessential dichotomies, i.e., one could put both the choices into a single programming language. But, the first three dichotomies give rise to 8 combinations. So, even in an ideal world, there would be at least 8 programming languages. When you drill down, there would be further nuanced design choices within particular paradigms. For instance, if one decides to do a class-based statically typed language, there are different ways of designing the type system. There is not yet a canonical way of doing it. If one decides to do a concurrent programming language, there are various ways of representing concurrency: semaphores, conditional critical regions, monitors, message-passing (synchronous vs. asynchronous). Within synchronous message-passing, there are two major paradigms determined by how nondeterministic choice is captured (as represented by CCS and CSP).

Part of the research we do in programming language theory is devoted to resolving these dichotomies. For instance, I worked on resolving the dichotomy between imperative and functional programming in a paper called "Assignments for applicative languages" and our method has now been adopted by Haskell, making it both a functional and imperative language. That doesn't mean that the dichotomy is fully resolved. A Haskell programmer is still faced with the choice of whether to solve his problem functionally or imperatively. Luca Cardelli worked on resolving static vs. dynamic typing dichotomy. Paul Levy worked on resolving the call-by-value vs. call-by-name dichotomy. Not all of these results have yet been implemented in real-life programming languages.


If all these languages can do the same things, why not just stick to one language and use that for programming computers?

Because for a programmer in the real world, it is not enough to just do something. It also matters how it is done. When it is done properly, the problem domain is represented faithfully in the program, modularity of the problem is retained, and the programs become easy to understand, modify and maintain. All these things affect the cost of program development and maintenance. They also affect the reliability and security of the software.

For instance, many people use a program called "Quicken" for financial accounts. The original program was developed in some in-house version of Visual Basic, and it was quite good. However, it has been hard to extend it and maintain it. Over the years, as the company attempted to extend it for newer features, the program became increasingly buggy with millions of dissatisfied customers everywhere. They will probably benefit from re-engineering the software in a strongly typed object-oriented programming language.


In particular, is there any reason I should know a functional language as a computer programmer ?

Historically, "functional programming" was invented by Godel, Kleene and Church following the standard mathematical practice, and "imperative programming" was invented by Turing to pin down the notion of mechanical computation. Before Turing, there is no evidence of mathematics ever having analysed imperative programming ideas. (While all traditional mathematical algorithms were expressed in an "imperative style," their essential content was still functional.) So, imperative programming is very very new to human civilization, and its mathematics is still not very well understood. The No. 1 reason why everybody should know some functional programming is to understand how programming can be mathematical. (I am not admitting that imperative programming is non-mathematical, which is what functional programmers would have you believe. But I would agree that, with the present state of art, we don't yet know how to do imperative programming mathematically. Many of us are working on precisely that problem.)

share|improve this answer

Why are there so many countries in the world? Wouldn't it be easier if we just had 5 or 6 superpowers, or even one universal kingdom of the Earth? It is easy to argue why it would not be better --- for a start, competition different countries may lead to progress, and from the point of view of democracy, human rights, etc., many countries may be better than one --- but this does not explain, why we have many countries. It only explains why many countries would be better.

Similarly, you can ask, why so many different human languages? Polish, Arabic, Mandarin... Wouldn't it be easier if there were just one language? You could argue either way, but those would be reasons as to why it would be better if life were one way or the other. It wouldn't explain the causes behind there being so many different human languages.

The thing is, there are many people on the planet, and we are all doing our thing, we all have our opinions, we all want to be in charge and have our own country or programming language, and we often think that we know better than others, or at least don't bother to understand what others have to offer.

Read this very enlightening blog post, Why so many Python web frameworks? Apparently, there are about 50 web frameworks in Python. This is just ridiculous; there is absolutely no sensible rational reason for that. But the author of the post answers: there are so many Python web frameworks because it is so easy to create one. You don't need a rational reason for there being more python web frameworks or more programming languages. People will go on creating new ones because they don't know what is already available, or because they hope they can make money, or just because creating new things is fun!

Let me describe a personal example. About 10 years ago I was writing some C++ code for a Finnish company. You know, in Finland they have those huge trucks that, well, travel long-distance and deliver a lot of stuff from one place to the other. I am sure, there are such trucks in America as well. So a typical problem is to make sure that all the 24 or so tires are fine. Of course, there is time-tested technology: pressure and temperature can be monitored, and drastic changes would indicate that something went wrong. Of course, all of this technology is proprietary, patented, with all the implications. (Remember: patents are supposed to promote innovation!) So this Finnish company wanted to detect the state of the tires by... sound. The idea was to install microphones to listen to the sound coming from all the tires and to do some kind of signal processing magic on those sounds in order to see if one of the tires had a problem of some kind, and I was doing a prototype of this madness. (They even had a dedicated lab for recording sample sounds; once they sent me an impressive video record of a particular occasion when they managed to explode a sample tire after subjecting it to 5 or 10 tons of pressure and heating it up to some ridiculous temperature.) Clearly, again, there was not a particular rational reason for this development, except that it was fun and some people wanted to make money. So also understand that there are so many reasons as to why somebody would start developing a new programming language. There is no need or even possibility to learn all of them.

Of course, all of this only applies if you believe in evolution. If you believe in some form of intelligent design, that God has also created all of the programming languages, then you would have to find a purpose behind this multitude. Perhaps God wanted to promote competition between different programming languages so that the art of software development would reach its highest possible state.

In conclusion, there are many people, many countries, many programming languages. This is just the nature of life! Let's be grateful for that: this just means that the field of programming/computer science is very much alive and flourishing.

share|improve this answer
    
very perfect answer,I don't know why it wasn't accepted! –  shekhar suman Jun 29 at 18:46

You might look at it as evolution.

In the beginning, computers were programmed purely with binary codes. After that mnemonics were introduced and assembly languages were introduced, mostly depending heavily on the CPU used.

After that higher level (3th level) languages was introduced (Pascal, C, ADA, Cobol), some very generic (like C), some more suitable for data handling (Cobol), some for calculations (Fortran).

After that 4th level languages arose, like logic languages (like Prolog). The most generic languages are successors of third level languages; some of them are Java, C#.

We also see languages specific for internet/web, like ASP.NET, PHP.

And languages for a specific domain (DSL), which mostly work together with a generic language.

Then there are languages for kids to learn programming, like LOGO.

Also languages for fastly writing code, like Python, Ruby etc, languages for handling XML (XSLT).

And I probably have forgotten a lot of languages and even categories of languages.

share|improve this answer

other answers are good, will add a few new angles. as DC writes languages evolve just like real human languages! and they borrow concepts and syntax from each other again like real human languages. in other words theres also a fairly real study of etymology of computer languages.

this also means theres been a long history and timeline which mainly started around the 1930s with lambda calculus.

there is a strong interplay/synergy/symbiosis between theory and application with programming languages. new applications are invented which leads to new theories and vice versa. a programming language is in many ways a bridge between theory and application.

an interesting case study from history is Fortran. it is not well known but earlier versions of Fortran (mostly before Fortran77) had an ambiguous grammar. this means that the same command could be legitimately "interpreted"/compiled different ways by the compiler because there were multiple valid "interpretations" (this is not the same technical sense of "interpreted" languages).

so the theory about formal grammars was being developed around the time that Fortran was invented, and it was a small crisis when the issue of language ambiguity was discovered. Fortan syntax was reformulated to avoid this ambiguity and later languages had more sensitivity to grammar ambiguity in their design. OOP is also a very important/foremost example of a theoretical concept/advance in programming languages that "impacts" or "ripples" into many existing languages, transforming them.

other case studies are the invention of new technologies. for example the invention of the relational database has had huge impact on computer languages eg with SQL and computer language interfaces to it (eg for example in java, "JDBC"). likewise the world wide web with even more massive impact. there seemed to be an explosion of languages timed right around the dotcom boom which largely coincided with the early growth of the WWW and might be compared with evolutionary explosions.

there also does seem to be a long trend of rise in new programming languages in conjunction with the massive exponentially increasing processing power of Moores law which some think may be slowing.

current longrange trends in programming languages seems to be toward Big Data and Parallelization eg with MapReduce. there is also a current interest in closures.

another key aspect of languages is that they represent increasing levels of abstraction. they build on lower-level abstractions to create higher level abstractions (similar to a pyramid). in this way the progress of computer language evolution is probably endless and we can be relatively sure important new ones will continue to be invented long into the future. this is probably analogous to a similar concept in psychology called chunking—roughly stated, building higher level mental concepts out of lower-level building blocks.

anyone who has studied many computer languages must admit that a herd mentality can be observed whereby some aspects of them turn out to be overhyped fads, ie not so critical as advocated, or even die out (in use) over time! some of the core ideas/changes remain but the (over-)hype fades. in this sense programming languages also fall in and out of fashion. two cases in my opinion from the last half-decade that are indeed useful but were overhyped:

increasingly a self-similarity can be observed across many major languages such that they all tend to be converging toward implementing many similar features in their own way, ie as with product comparison charts that "check off" many features in a grid.

share|improve this answer
    
see also design patterns which often cross languages and are implemented in languages. another key aspect of language study/functionality are features implemented in libraries –  vzn May 14 '13 at 20:05

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.