Java
- Object-Oriented + Computing Platform
- Safe, Fast, Reliable
- Source → Bytecode → JVM (Java Virtual Machine)
- Bytecode เก็บใน
.classfiles - ไม่มี associative arrays ตรงๆ ใช้
HashMap,Hashtable,ConcurrentHashMap - Source files:
.java - Statically typed - type checking ตอน compile-time
- Single-line comment:
// - Multi-line comment:
/* ... */ - Documentation:
/** ... */(Javadoc) - Statement ends with
;
Perl
- Statement ends with
; - General-purpose High-level Language
- สร้างมาแทน Shell scripts ที่ซับซ้อน
- Perl 5 และก่อนหน้า: Interpreted language
- Perl 6 (Raku): Compile → Parrot Bytecode (
.pbc) - Associative arrays (Hashes) เป็น built-in syntax:
%hash = (key => value) - Source files:
.pl - Dynamically typed - type checking ตอน runtime
- Comment:
# ... - Documentation:
=pod ... =cut(POD format)
ตารางเปรียบเทียบสรุป
| คุณสมบัติ | Java | Perl |
|---|---|---|
| Type System | Static, Strong | Dynamic, Weak |
| Paradigm | OOP (multi-paradigm จำกัด) | Multi-paradigm (Procedural, OO, Functional) |
| Execution | Compile → Bytecode → JVM | Interpret (Perl 5) / Compile to VM (Raku) |
| Associative Arrays | Library (Map) | Built-in syntax (%) |
| Regex | java.util.regex (verbose) | Built-in syntax (/pattern/) |
| Performance | High (JIT, AOT) | Moderate |
| Ecosystem | Enterprise, Android, Big Data | Sysadmin, Text processing, Bioinformatics |
| Learning Curve | Moderate | Steep (sigils, context, TMTOWTDI) |