Comparison of programming languages: Difference between revisions
Fixed typo (extra period) |
Malkom1989 (talk | contribs) |
||
Line 198: | Line 198: | ||
| [[functional programming|functional]], [[generic programming|generic]], [[lazy evaluation]] |
| [[functional programming|functional]], [[generic programming|generic]], [[lazy evaluation]] |
||
| {{yes}}, Haskell 98<ref>{{cite web|url=http://www.haskell.org/onlinereport/ |title=The Haskell 98 Language Report |accessdate=2009-03-07}} Most Haskell implementations extend the Haskell 98 standard.</ref> |
| {{yes}}, Haskell 98<ref>{{cite web|url=http://www.haskell.org/onlinereport/ |title=The Haskell 98 Language Report |accessdate=2009-03-07}} Most Haskell implementations extend the Haskell 98 standard.</ref> |
||
|- |
|||
! [[HyperNext]] |
|||
| Application, Education |
|||
| [[Procedural programming|procedural]], [[weak typing|weakly typed]], [[event-driven programming|event-driven]] |
|||
| {{no}} |
|||
|- |
|- |
||
! [[Io programming language|Io]] |
! [[Io programming language|Io]] |
Revision as of 16:35, 1 September 2009
Programming languages are used for controlling the behavior of a machine (often a computer). Like natural languages, programming languages conform to rules for syntax and semantics.
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 professional programmers can easily use dozens of different languages during their career.
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. Please note that the following table may be missing some information.
Type systems
Brief Definitions
- Compatibility among composite types is how functions are applied to data typed similarly to its intended type. Name-based compatibility means that functions work only on data of its intended type and declared subtypes. Property-based compatibility means that functions work on any data that has the same structure of its intended type.[clarification needed]
- Type checking is how type errors are checked. Static checking occurs at compile-time. Dynamic checking occurs at run-time.
Language | Type strength | Type safety | Expression of types | Compatibility among composite types | Type checking |
---|---|---|---|---|---|
ActionScript 3.0 | strong | safe | static | ||
Ada | strong | mostly safe [TS 1] | explicit | name-based | partially dynamic [TS 2] |
ALGOL 58 | strong | safe | explicit | static | |
ALGOL 60 | strong | safe | explicit | static | |
ALGOL 68 | strong | safe | explicit | property-based | static |
APL | strong | safe | dynamic | ||
AutoHotkey | none | ||||
BASIC | varies by dialect | ||||
BLISS | none | n/a | n/a | n/a | n/a |
BeanShell | strong | safe | name-based | dynamic | |
Boo | strong | safe | implicit with optional explicit typing | static with optional dynamic typing | |
C | weak | unsafe | explicit | name-based | static |
C++ (ISO/IEC 14882) | strong | unsafe | explicit | name-based | static [TS 3] |
C# | strong | safe2 | explicit | name-based | static [TS 4] |
Clean | strong | safe | implicit | static | |
Clojure | strong | safe | dynamic | ||
COBOL | strong | static | |||
ColdFusion | strong | safe | implicit | dynamic | |
Common Lisp | strong | safe | dynamic | ||
Curl | strong | safe | name-based | ||
D | strong | unsafe1 | explicit | name-based | static |
Dylan | strong | safe | dynamic | ||
Eiffel | strong | safe | name-based | static | |
Erlang | strong | dynamic | |||
F# | strong | safe | implicit | name-based | static |
Forth | none | n/a | n/a | n/a | n/a |
FORTRAN | strong | safe | explicit | name-based | static |
GraphTalk | weak | ||||
Groovy | strong | safe | implicit | dynamic | |
Haskell | strong | safe | implicit with optional explicit typing | property-based | static |
Io | strong | dynamic | |||
J | strong | safe | dynamic | ||
Java | strong | safe[24] | explicit | name-based | static |
JavaScript | weak | implicit | dynamic | ||
Joy | strong | safe | dynamic | ||
Lua | strong | safe | implicit | dynamic | |
Mathematica | strong | dynamic | |||
MATLAB M-code | dynamic | ||||
Modula-2 | strong | unsafe1 | explicit | name-based | static |
Modula-3 | strong | unsafe1 | explicit | property-based | static |
Oberon | strong | safe | explicit | name-based | partially dynamic[TS 5] |
Objective-C | weak | explicit | static and dynamic[25][clarification needed] | ||
Objective Caml | strong | safe | implicit with optional explicit typing | property-based | static |
Object Pascal (Delphi) | strong | unsafe1 | explicit | name-based | static |
Oxygene | strong | unsafe | implicit | static | |
Oz | dynamic | ||||
Pascal | strong | unsafe1 | explicit | name-based | static |
Perl 5 | weak | implicit | dynamic | ||
Perl 6 | partially implicit [TS 6] | dynamic with optional static typing | |||
PHP | weak | implicit | dynamic | ||
Prolog | strong | dynamic | |||
Python | strong | safe | implicit | property-based | dynamic |
REBOL | strong | safe | implicit | dynamic | |
Ruby | strong | safe | implicit | property-based | dynamic |
S | strong | dynamic | |||
S-Lang | strong | safe | implicit | dynamic | |
Scala | strong | partially implicit | static | ||
Scheme | strong | implicit | dynamic (latent) | ||
Simula | strong | safe | static [TS 7] | ||
Smalltalk | strong | safe | implicit | dynamic | |
Standard ML | strong | safe | implicit with optional explicit typing | property-based | static |
Tcl | dynamic | ||||
Visual Basic | strong | safe | implicit with optional explicit typing | name-based | static |
Visual Basic .NET | strong | unsafe1 | explicit | static | |
Visual Prolog | strong | safe | partially implicit | name-based | static |
Windows PowerShell | strong | safe | implicit | dynamic | |
XL | strong | safe | name-based | static | |
Language | Type strength | Type safety | Expression of types | Compatibility among composite types | Type checking |
- ^ Unsafe operations are well isolated by a "Unchecked_" prefix.
- ^ Dynamic type checking is used when type safety can not be determined staticly i.E. for tagged types (type extension / inheritance), numeric ranges and array bounds.
- ^ with optional dynamic type casting (see dynamic cast)
- ^ with optional dynamic type (see dynamic member lookup)
- ^ dynamic checking of type extensions i.e. inherited types
- ^ explicit for static types
- ^ optional for formal and virtual procedures
1It is almost safe, unsafe features are not commonly used.
2Safe, but supports unsafe code through an explicit declaration
Failsafe I/O and system calls
Most programming languages will print an error message and/or throw an exception if an input/output operation or other system call (e.g., chmod, kill) fails, unless the programmer has explicitly arranged for different handling of these events. Thus, these languages fail safely in this regard.
Some (mostly older) languages require that the programmer explicitly add checks for these kinds of errors. It is common for novice programmers to forget to add these checks, and even experts occasionally do so—these omissions can lead to erroneous behavior.
Language | Failsafe I/O |
---|---|
Ada | Yes (exceptions) |
AutoHotkey | No (global ErrorLevel must be explicitly checked) |
C | No (though gcc can warn on unchecked error status) |
C++ | No (though gcc can warn on unchecked error status) |
C# | Yes |
D | Yes ? |
Erlang | Yes |
Haskell | Yes |
Java | Yes |
Lua | No (some functions do not warn or throw exceptions) |
Mathematica | ? |
Objective Caml | Yes (exceptions) |
Object Pascal (Delphi) | Some |
Perl | Optional |
PHP | Yes |
Python | Yes |
REBOL | Yes |
Ruby | Yes |
S | ? |
Scala | Yes ? |
Standard ML | Yes ? |
Tcl | No |
Visual Basic | Yes |
Visual Prolog | Yes |
Language | Failsafe I/O |
Expressiveness
Language | Statements ratio[26] | Lines ratio[27] |
---|---|---|
C | 1 | 1 |
C++ | 2.5 | 1 |
FORTRAN | 2.5 | 0.8 |
Java | 2.5 | 1.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.[28] 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 Language Benchmarks Game [29]
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 Benchmarks Game 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.
See also
- Alphabetical list of programming languages
- Comparison of basic instructions of programming languages
- Educational programming language
- Programming language
References
- ^ As of May 2006 Diarmuid Pigott's Encyclopedia of Computer Languages hosted at Murdoch University, Australia lists 8512 computer languages.
- ^ Ada Reference Manual, ISO/IEC 8652:2005(E) Ed. 3, Section 6: Subprograms
- ^ Ada Reference Manual, ISO/IEC 8652:2005(E) Ed. 3, Section 9: Tasks and Synchronization
- ^ Ada Reference Manual, ISO/IEC 8652:2005(E) Ed. 3 Annex E: Distributed Systems
- ^ Ada Reference Manual, ISO/IEC 8652:2005(E) Ed. 3, Section 12: Generic Units
- ^ Ada Reference Manual, ISO/IEC 8652:2005(E) Ed. 3, 3.9 Tagged Types and Type Extensions
- ^ http://vak.ru/lib/exe/fetch.php/book/gost/pdf/gost-27831-88.pdf
- ^ ISO 1538:1984
- ^ http://vak.ru/lib/exe/fetch.php/book/gost/pdf/gost-27974-88.pdf
- ^ JSR 274
- ^ http://cm.bell-labs.com/cm/cs/who/dmr/chist.html
- ^ http://www.codeproject.com/KB/cs/intro_functional_csharp.aspx
- ^ ECMA-334; ISO/IEC 23270:2006
- ^ ECMA-367; ISO/IEC 25436:2006
- ^ "The Haskell 98 Language Report". Retrieved 2009-03-07. Most Haskell implementations extend the Haskell 98 standard.
- ^ Version releases are accompanied with a definitive Lua Reference Manual showing full syntax and semantics; a reference implementation, and a test suite. These are used to generate other Lua VM implementations and compilers such as Kahlua and LLVM-Lua.
- ^ ISO/IEC 10514-1:1996
- ^ http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Standards.html
- ^ ISO 7185
- ^ PHP Manual, Chapter 17. Functions
- ^ PHP Manual, Chapter 19. Classes and Objects (PHP 5)
- ^ Language changes are done using a formally documented procedure, starting with a Python Enhancement Proposal (PEP)s. Python version releases are accompanied with a Language Reference Manual showing syntax and semantics; a reference implementation, and test suite. These are used to generate other Python implementations such as Jython and IronPython.
- ^ http://www.smlnj.org/sml97.html
- ^ Sheng Liang, Gilad Bracha. Dynamic class loading in the Java virtual machine. Volume 33, Issue 10 of ACM SIGPLAN Notices, October 1998.
- ^ http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocStaticBehavior.html
- ^ 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.
- ^ 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.
- ^ From On the Expressive Power of Programming Languages, Matthias Felleisen, ESOP '90 3rd European Symposium on Programming.
- ^ Computer Language Benchmarks Game .
Further reading
- Cezzar, Ruknet. A Guide to Programming Languages: Overview and Comparison. ISBN 978-0890068120.
External links
- 99-bottles-of-beer.net — one program in over a thousand variations and multiple languages.
- The Computer Language Benchmarks Game at Alioth
- The speed, size and dependability of programming languages — narrative charts based on Alioth's benchmark data.
- Comparison of syntaxes with sample codes.
- Syntax Across Languages
- Programming Language Comparison — a comparison of nine programming languages and related information.
- Scriptometer scores — multiple comparisons of 26 programming languages.
- Template:PDFlink — research to fulfill Kristofer J. Carlson's master's degree requirements.
- PLEAC — Programming Language Examples Alike Cookbook.
- OHLOH Language Statistics — gives an indication of the popularity of programming languages in open-source projects.
- History of Programming Language Statements — history and comparison of programming languages.