Perbandingan bahasa pengaturcaraan komputer

Dari Wikipedia Bahasa Melayu, ensiklopedia bebas.

  Eiffel Smalltalk Ruby Java C# C++ Python Perl Visual Basic
Object-Orientation Pure Pure Pure Hybrid Hybrid Hybrid / Multi-Paradigm Hybrid Add-On / Hybrid Partial Support
Static / Dynamic Typing Static Dynamic Dynamic Static Static Static Dynamic Dynamic Static
Generic Classes Yes N/A N/A No No Yes N/A N/A No
Inheritance Multiple Single Single class, multiple "mixins" Single class, multiple interfaces Single class, multiple interfaces Multiple Multiple Multiple None
Feature Renaming Yes No Yes No No No No No No
Method Overloading No No No Yes Yes Yes No No No
Operator Overloading Yes Yes? Yes No Yes Yes Yes Yes No
Higher Order Functions Agents (with version 5) Blocks Blocks No No No Lambda Expressions Yes (???) No
Lexical Closures Yes (inline agents) Yes (blocks) Yes (blocks) No No No Yes (since 2.1) Yes No
Garbage Collection Mark and Sweep or Generational Mark and Sweep or Generational Mark and Sweep Mark and Sweep or Generational Mark and Sweep or Generational None Reference Counting Reference Counting Reference Counting
Uniform Access Yes N/A Yes No No No No No Yes
Class Variables / Methods No Yes Yes Yes Yes Yes No No No
Reflection Yes (as of version 5) Yes Yes Yes Yes No Yes Yes? No
Access Control Selective Export Protected Data, Public Methods public, protected, private public, protected, "package", private public, protected, private, internal, protected internal public, protected, private, "friends" Name Mangling None public, private
Design by Contract Yes No Add-on No No No No No No
Multithreading Implementation- Dependent Implementation- Dependent Yes Yes Yes Libraries Yes No No
Regular Expressions No No Built-in Standard Library Standard Library No Standard Library Built-in No
Pointer Arithmetic No No No No Yes Yes No No No
Language Integration C, C++, Java C C, C++, Java C, some C++ All .NET Languages C, Assembler C, C++, Java C, C++ C (via DCOM)
Built-In Security No No? Yes Yes Yes No No? Yes (perlsec) No
Capers Jones Language Level 15 15 N/A 6 N/A 6 N/A 15 11

[Sunting] * Based on number of source code lines per function point.

[Sunting] Object-Orientation

Many languages claim to be Object-Oriented. While the exact definition of the term is highly variable depending upon who you ask, there are several qualities that most will agree an Object-Oriented language should have:

  1. Encapsulation/Information Hiding
  2. Inheritance
  3. Polymorphism/Dynamic Binding
  4. All pre-defined types are Objects
  5. All operations performed by sending messages to Objects
  6. All user-defined types are Objects

For the purposes of this discussion, a language is considered to be a "pure" Object-Oriented languages if it satisfies all of these qualities. A "hybrid" language may support some of these qualities, but not all. In particular, many languages support the first three qualities, but not the final three.

So how do our languages stack up?

  Eiffel Smalltalk Ruby Java C# C++ Python Perl Visual Basic
Encapsulation / Information Hiding Yes Yes Yes Yes Yes Yes No Yes? Yes?
Inheritance Yes Yes Yes Yes Yes Yes Yes Yes? No
Polymorphism / Dynamic Binding Yes Yes Yes Yes Yes Yes Yes Yes? Yes (through delegation)
All pre-defined types are Objects Yes Yes Yes No No No Yes No No
All operations are messages to Objects Yes Yes Yes No No No No No No
All user-defined types are Objects Yes Yes Yes Yes Yes No Yes No No