Comparison of programming languages

From Wikipedia, the free encyclopedia

This article is part of
the Programming Language Comparison
series.
General Comparison
Basic Syntax
String Operations
String Functions

Evaluation strategy
List of "hello world" programs

Compatibility of C and C++
Comparison of C and Pascal
Comparison of C++ and Java
Comparison of C# and Java
Comparison of C# and Visual Basic .NET

Programming languages are used for controlling the behavior of a machine (often a computer). Like human languages, programming languages have syntactic and semantic rules used to define meaning.

There are thousands of programming languages[1] and new ones are created every year. Few languages ever become sufficiently popular that they are used by more than a few people, but many professional programmers use dozens of different languages during their career.

Contents

[edit] General comparison

The following table compares general and technical information for a selection of commonly used programming languages. See the individual languages' articles for further information.

Language General model of execution Influences Paradigm(s) Typing discipline Introduced
Ada Compilation Algol, Pascal, C++ (Ada 95), Smalltalk (Ada 95), Java (Ada 2005) concurrent, distributed, generic, imperative, object-oriented static, strong, safe, nominative 1983
APL Usually interpreted, some compilers exist array-oriented programming "types" are basically characters and numbers 1964
BASIC Interpreted and compiled
C Compilation Algol, B imperative, flow-driven static, weak, unsafe 1973
C++ Compilation C, Simula, Algol 68 imperative, object-oriented, generic,multi-platform static, strong, unsafe, nominative 1985
C# JIT compilation Delphi, Java, C++, Ruby imperative, object-oriented, generic, multi-platform static, strong, both safe and unsafe 2000
Clean Compilation Haskell functional, generic static, strong, type inference 1987
COBOL Compilation FLOW-MATIC, COMTRAN imperative, object-oriented weak/strong 1959
ColdFusion JIT compilation HTML procedural, functional, object-oriented dynamic (duck), weak 1995
Common Lisp Compilation Lisp, Smalltalk imperative, functional, object-oriented dynamic, strong, safe 1984
D Compilation C , C++, Java, C# imperative, object-oriented, generic static, strong, unsafe, contracts 2000
Eiffel Compilation Ada, Simula imperative, object-oriented, generic static, strong, safe, nominative, contracts 1985
Erlang Compilation / Interpretation / JIT compilation Prolog, Ericsson Pascal, CSP functional, concurrent, distributed, multi-platform dynamic, weak 1987
Forth Interpretation / Compilation RPN, Assembly imperative, stack-oriented typeless 1977
Fortran Compilation APL (Fortran 90), Algol 68 (Fortran 90), C (Fortran 2003) imperative, procedural, object-oriented static, strong, safe, nominative 1957
Haskell Interpretation / Compilation Miranda, ML, λ-calculus functional, generic static, strong, type inference 1990
Io Interpretation Smalltalk, Self, Lua, NewtonScript, Act1 imperative, object-oriented dynamic 2002
Java Interpretation / JIT compilation C++, Objective-C, C#[2] imperative, object-oriented, multi-platform, generic static, strong 1994
JavaScript Interpretation C, Self, awk, Perl imperative, object-oriented, functional dynamic 1995
Lisp Interpretation, Compilation λ-calculus functional dynamic, strong 1958
Lua Interpretation, JIT compilation Python, Icon, Lisp, Scheme procedural, imperative, reflective dynamic, strong, safe 1993
Mathematica Interpretation Lisp, APL functional, procedural dynamic, strong 1986
Objective-C Compilation C, Smalltalk imperative, object-oriented static/dynamic hybrid, strong 1986
Objective Caml Interpretation / Compilation ML, Lisp object-oriented, functional, imperative, generic static, safe, structural, type inference 1996
Object Pascal Compilation Pascal imperative, object-oriented static, strong, safe (but unsafe allowed), nominative 1985
Perl Interpretation C, shell, awk, sed, Lisp functional, object-oriented, procedural dynamic 1987
PHP Interpretation Perl, C, C++, Java imperative, object-oriented dynamic, weak 1995
Prolog 1972
Python Interpretation / JIT compilation ABC, C, Perl, Modula-3 imperative, object-oriented, functional, aspect-oriented dynamic (duck), strong 1991
Ruby Interpretation Smalltalk, Perl, Python, Lisp imperative, object-oriented, functional, aspect-oriented dynamic (duck), strong 1995
Scala Interpretation / Compilation Java object-oriented, functional, generic static, strong, partial type inference 2003
Scheme Interpretation / Compilation Lisp, Algol 60 functional dynamic 1975
Smalltalk JIT compilation Sketchpad, Simula object-oriented, functional, concurrent, event-driven, imperative, declarative dynamic, strong, safe, duck 1971
Visual Basic Compilation QuickBASIC component-oriented, event-driven static/dynamic hybrid, weak/strong hybrid, safe, nominative 1991
Visual Basic .NET JIT compilation Visual Basic object-oriented, event-driven static, strong 2001

[edit] Expressiveness

Language Statements ratio[3] Lines ratio[4]
C 1 1
C++ 2.5 1
Fortran 2.5 .8
Java 2.5 1.5
MS Visual Basic 4.5  ?
Perl 6 6
Smalltalk 6 6.25
Python 6 6.5

The literature on programming languages contains an abundance of informal claims about their relative expressive power, but there's no framework for formalizing such statements nor for deriving interesting consequences.[5] This chart provides two measures of expressiveness from two different sources. An additional measure of expressiveness, in GZip bytes, can be found with the Compare to tool on the Computer Languages Shootout.

[edit] Benchmarks

Benchmarks are designed to mimic a particular type of workload on a component or system. The computer programs used for compiling some of the benchmark data in this section may not have been fully optimized, and the relevance of the data is disputed. The most accurate benchmarks are those that are customized to your particular situation. Other people's benchmark data may have some value to others, but proper interpretation brings many challenges. See this page about flawed benchmarks and comparisons. The Computer Language Shootout Benchmarks site contains a large number of micro-benchmarks of reader-contributed code snippets, with an interface that generates various charts and tables comparing specific programming languages and types of tests.

[edit] See also

[edit] References

  1. ^ As of May 2006 Diarmuid Pigott's Encyclopedia of Computer Languages hosted at Murdoch University, Australia lists 8512 computer languages.
  2. ^ In Java 5.0, several features (the enhanced for loop, autoboxing, varargs, annotations and enums) were introduced, after proving themselves useful in the similar (and competing) language C#. [1][2][3]
  3. ^ Data from Code Complete. The Statements ratio column "shows typical ratios of source statements in several high-level languages to the equivalent code in C. A higher ratio means that each line of code in the language listed accomplishes more than does each line of code in C.
  4. ^ The ratio of line count tests won by each language to the number won by C when using the Compare to feature at http://shootout.alioth.debian.org/debian/c.php. Last updated May, 2006. C gcc was used for C, C++ g++ was used for C++, Fortran G95 was used for Fortran, Java JDK Server was used for Java, and Smalltalk GST was used for Smalltalk.
  5. ^ From On the Expressive Power of Programming Languages, Matthias Felleisen, ESOP '90 3rd European Symposium on Programming.

[edit] External links

In other languages