Programming Languages

From Exterior Memory
Jump to: navigation, search
This article was originally published at http://www.science.uva.nl/research/air/wiki/ProgrammingLanguagesby me. The original page is no longer updated


Quick overview

Feature C '99 C++ '03 Objective C C# 4 Visual Basic .NET Eiffel 5 Java 6 Smalltalk PHP 5 Perl 5 Python 3 Ruby 1.9 JavaScript Lua
Compiler / Interpreter Compiler Compiler Compiler Compiler Compiler Compiler Bytecode Bytecode/Interpreter Interpreter Interpreter Interpreter/Bytecode Interpreter Interpreter Bytecode/Interpreter
Static / Dynamic Typing Static Static Static / Dynamic Static Static Static Static Dynamic Dynamic Dynamic Dynamic Dynamic Dynamic Dynamic
Introspection / Reflection No No Yes Yes No No? Library Yes Yes Yes Yes Yes Yes Yes?
Pre-processor templates Yes Yes Yes Yes No No? No No No No No No No No
Garbage Collection None None Reference Counting (from 2.0) Mark and Sweep or Generational Reference Counting Mark and Sweep or Generational Mark and Sweep or Generational Mark and Sweep or Generational Reference Counting Reference Counting Reference Counting Mark and Sweep Mark and Sweep Incremental Mark and Sweep
Class / Prototype based None Class based Class based Class based Class based Class based Class based Class based Class based Class based Class based Class based Object based Object based
Object-Orientation No, pure procedural Partial Partial Partial Partial Full Partial Full Partial Partial Partial Full Partial Partial
Encapsulation / Access Control No Yes (public, protected, private, friends) Yes (public, protected, private, package) Yes (public, protected, private, internals (=friends)) Yes (public, private) Yes (selective export) Yes (public, protected, private, friends, package) Yes (protected data, public methods) Yes (public, protected, private) No (underscore convention) No (name mangling) Yes (public, protected, private) No, but work-around exists No
Inheritance N/A Yes, class based Yes Yes, class based No Yes, class based Yes, class based Yes, class based Yes, class based Yes Yes, class based Yes, class based Yes, object based Yes
Dynamic Dispatch (Polymorphism) N/A Yes Yes Yes Yes (through delegation) Yes Yes Yes Yes Yes Yes Yes Yes Yes?
All pre-defined types are Objects N/A No No No No Yes No Yes No No Yes Yes No No
All operations performed by sending messages to Objects N/A No Yes No No Yes No Yes No No No Yes No No
All user-defined types are Objects N/A No No? Yes No Yes Yes Yes No? No Yes Yes Yes No?
Multiple Inheritance N/A Multiple Single Single class, multiple interfaces None Multiple Single class, multiple interfaces Single Single Multiple Multiple Single class, multiple "mixins" N/A N/A
Class Variables / Methods N/A Yes No Yes No No Yes Yes No? No Yes Yes N/A N/A
Parametric Types (subtyping) N/A Yes No No No Yes No No? No No No No No No
Built-in Classes Mutable N/A No No, but provides Proxies and Categories Yes, using Extension Methods No No No Yes No No? No, but provides abstract base class mixins Yes N/A N/A
Method Overloading N/A Yes Allows methods with different selectors Yes No No Yes No No No No No No No
Operator Overloading Yes Yes No Yes No Yes No Yes, as binary messages Yes Yes Yes Yes No Yes
Named Parameters No No Yes Yes (from 4.0) Yes No? No Yes No No Yes Yes (from 2.0) No No
Uniform Access No No Yes (for 1.0 properties) No Yes Yes No N/A No No No, but property() can mimick getter/setter as variable Yes No No
Design by Contract No No No Yes No Yes No No No Yes (from 6) No Add-on No No
Higher Order Functions No Lambda (from '11) Blocks Lambda (from 3.0) Lambda (from 9) Agents No, planned for Java 8 Blocks Lambda Expression (from 5.3) Lambda (from 5), Block (from 6) Lambda (no statements) Blocks, Proc, Lambda Lambda Lambda
Functional Programming No std::transform (=map), std:remove_if (=filter), std::accumulate (=fold) No, but can be added using valueForKey, filteredArrayUsingPredicate Select (=map), Where (=filter), Aggregate (=fold) (from 3.0) Select (=map), Where (=filter), Aggregate (=fold) No, but can be achieved with agents and do_all and do_if No collect (=map), select (=filter), inject (=fold) array_map, array_filter, array_reduce map, grep, reduce map, filter, functools.reduce (=fold), list comprehension. map, reject (=filter), inject (=fold) map, filter, reduce No, but can easily be written
Lexical Closures No No Yes (blocks) No No Yes (inline agents) No Yes (blocks) No Yes Yes Yes (blocks) Yes? Yes
Symbols No, enum only No No, NSString* const comes close No, enum only No? No? No, interned Strings come close Yes? No No No Yes No No?
0 is True No No No No No N/A N/A N/A No No No Yes No Yes
Namespaces No Yes No Yes Yes No Yes, DNS-based Yes Yes Yes Yes, File-based Yes No No
Namespace Collision Prevention N/A No None? No None N/A Hierarchical Namespace None None? None? Renaming No N/A N/A
Feature Renaming No No No Yes No No No No Yes
Multithreading Libraries Yes Libraries Yes No Implementation-Dependent Yes Implementation-Dependent Yes No Global Lock Global Lock No Collaborative Multitasking
Regular Expressions No No External Library Standard Library No No Standard Library No Standard Library Built-in Standard Library Built-in Built-in Built-in
Pointer Arithmetic Yes Yes Yes Yes No No No No No No No No No NO
Language Integration Assembler C, Assembler C All .NET Languages C (via DCOM) C, C++, Java C, some C++ C Java C, C++ C, C++, Java C, C++, Java Java C
Source Origin Security No No No Yes No No Yes No? No Yes (perlsec) No Yes Yes No?
Exceptions No Partial Partial Yes Yes Yes? Yes, strict checking Yes Partial Partial Yes Yes Partial Partial
Build-in Unicode strings No Yes (from '11) No Yes (from 2.0) Yes (from 1.9)
All strings are Unicode No No No Yes (from 3.0) Yes (from 1.9)
Explicit encode/decoding enforced No No No Yes (from 3.0) No
Supplemental plane support Libraries Yes (from '11) No Yes (from 3.3, optional from 2.0) Yes
Block Syntax Curly brackets Curly brackets Curly brackets Curly brackets Curly brackets Indentation if/endif
Capers Jones Language Level* 3 6 12 6 11 15 6 15 15 15 15 15 10
Lines of Code per Function Point (Assembly = 320) 60 53 27 59 29 21 53 21 21 18 18 18 54 18
Execution speed (Fortran = 1.00) 1.3 1.3 2.9 1.9 19 50 82 51 47 5.7 30
Popularity (1000 Google hits on <LANG> code OR source OR script) 22300 5140 1350 3560 2840 64 34900 43 102000 4570 5390 1240 44600 572

Object Oriented

modules
refers to programming languages which have the concept of a set of a group of functions that manipulates private data, but which have no thorough protection of either the data (e.g. PHP 4), or do not have the concept of private functions (e.g. Pascal, Python).

Strict Typing

Strict typing means that you explictly need to typecast variables from one type into the other, rather then that is done automatically for you by the compiler. Note that strict typing is only possible for static typed languages (in which the type checking is done at compile time), but not for dynamically typed language, such as Objective-C and SmallTalk (in which type checking is done during runtime).

Exception handling

mixed
means that while you can make try{} constructs yourself, most built-in function instead still return a mixed type (for example, a positive integer on success and the boolean false or "-1" on failure) or require you to call a separate error function, instead of throwing an exception itself. This is often the case for languages in which exception handling was added later.

Garbage Collection

Automatic garbage collection; unused variables are automatically free()'d, so there are no memory leaks. This is important, because in most programmers are not up to handling memory management. Note that it is still possible to have other leaks, like socket leaks or file descriptor leaks.

Name Spaces

Name spaces prevent name collisions. For example, it allows one to distinguish between sys.log() and math.log(). Name spaces became well known with Java.

Smart Block Syntax

Most programming languages use curly brackets { } to group statements, forming a block. However, this has the inherent problem that it is often a fight between style fanatics to either save space and write it on the same line as the condition, or style fanatics to write it on a seperate line, aligning the opening and closing brackets. There are better alternatives for curly brackets (most language designers feel that curly brackets where a terribly idea in the first place). The Block Syntax page lists some alternatives.