Describes the features of programming languages and the complexities they incur in the compilers and virtual machines. Illustrates with examples from Java, Python, Swift and Node. Also introduces Open Managed Runtime (OMR)
2. Agenda
❊ Machine and the Machine Code
❊ Language Classification
❊ Abstraction types and their implications
❊ Major Language paradigms
❊ Java Perspectives
❊ Stories from Scripts
❊ Expressiveness plus Efficiency
3. Introduction to the speaker
❊ 14 years of experience: Developing, Porting, and Debugging large and
complex System software modules
❊ Virtual machines, Language Runtimes, Compilers, Web Servers
❊ Active Contributor to Open source Projects
❊ Interests: Language semantics, Subroutine linkage, Code optimization,
Virtual machines, Process runtime, PaaS, Core file debugging
❊ Focus area: PaaS
linkedin: gireeshpunathil
Twitter : @gireeshpunam
Github : gireeshpunathil
Email : gpunathi@in.ibm.com
4. Machine and the Machine Code
❊ Logic implemented by Circuits
❊ Behavior specified by Architecture
❊ Capability abstracted by Instructions
❊ Instructions encoded in bits
❊ Code and Data referred by address
💻
6. Benefits
❊ Fast and Powerful
❊ Direct access to devices
❊ Little code transformation
❊ Low resource consumption
Drawbacks
♨ Lacks portability
♨ Code maintenance difficult
♨ Hard to read
♨ Un-named data
♨ Hard to debug issues
♨ Very little runtime checks
💉 🔌
7. C – A thin wrapper around Assembly
❊ Arithmetic: +, -, *, /, +=, ++
❊ Copy: =, memset(), strcpy()
❊ Compare: ==, !=, <, >, >=
❊ Control: if, for, switch, (), return
❊ Port access: read(), write()
❊ CAS: mutex, semaphore, conditions
🚀
8. C – Often as powerful as Assembly
unsigned long mytime()
{
unsigned long time;
__asm__ volatile (”rdtsc”:"=A" (time));
return time;
}
http://www.tldp.org/HOWTO/text/IO-Port-Programming ⏱
9. Domain based
❊ Focus on problem domain
❊ Validation at business level
❊ Used in limited scope
❊ 3rd level of Abstraction
❊ HTML, SQL, SED, AWK
Paradigm based
Programming Language Classification
Script based
❊ General purpose
❊ Focus on S/W domain
❊ Rules on code & data
❊ 1st level of Abstraction
❊ C, C++, C#, Java
❊ Discrete commands strung
into a coherent whole
❊ Automate repeatable tasks
❊ 2nd level of Abstraction
❊ Py, PHP, JS, Ruby, Bash
💊🃋 🗡
17. Synchronization
Synchronization intrinsic
to language
Locks intrinsic to Objects
Granular at function and
block level
Syntax and Semantics
validation
Lock word management
Implement sync. primitives
Fast path sync.
Slow path sync.
Exception handling
Expressiveness Compiler Pressure Runtime Pressure
18. Threading
Abstracts execution sequence
Flexible creation models
Lifecycle management
Backbone of concurrency
Backbone of Multicore exploitation
Cost of Native threading
Cost of stack management
Cost of context switching
Cost of synchronization
Expressiveness Compiler Pressure Runtime Pressure
19. Garbage Collection
Automatic Object
memory management
Cost of the Stopped World
Cost of Copy Collection
Cost of Stack walk
Cost of Marking
Cost of Sweeping
Cost of Compaction
Features Compiler Pressure Runtime Pressure
20. Native Interfacing
Special cases to descent
into a low level language
Fill the gap in platform
abstraction
Syntax validation
Type verification
Call semantics validation
Stub creation
Dynamic loading
Dynamic linking
Type conversion/validation
Environment management
Stack management
Context switching
Memory management
Expressiveness Compiler Pressure Runtime Pressure
22. Class
Custom Types
Glues Code with Data
Implements OO
Models real world entities
with attributes and
behaviors
Syntax validation
Hierarchy validation
Access validation
Semantic validation
Constant pool creation
Bytecode generation
Unitization
Class loading cost
Class loader cost
Class initialization cost
Reflection cost
Object header cost
Field access cost
Method access cost
Invocation cost
Expressiveness Compiler Pressure Runtime Pressure
23. Bytecode aka. Portability
Write Once Run Everywhere
Forget the real machine,
learn only language spec.
and virtual machine spec.
Syntax validation
Hierarchy validation
Access validation
Semantic validation
Constant pool creation
Bytecode generation
Unitization
Interpretation cost
Dynamic Compilation cost
Classloading cost
Runtime verification cost
Exception handling cost
Expressiveness Compiler Pressure Runtime Pressure
25. Dynamic Typing
Model more real-world
like data
Data bound to Object not
with the Class
Data access cost
Type inference cost
Object Lookup cost
Data access cost
Type inference cost
Heterogeneous type
management cost
Features Compiler Pressure Runtime Pressure
26. Runtime Evaluation
Executable in a String
Run arbitrary,
unprepared code
Code verification
Data verification
Consistency check
Entire process of parsing,
compilation,
transformation,
interpretation initiated at a
call site
Features Compiler Pressure Runtime Pressure
28. Python: Analytics
Packing and Zipping
Generator expressions
Tuples, Sets and Queues
OS module: thinnest wrapper
around platforms
•Beautiful is better than ugly
•Explicit is better than implicit
•Simple is better than complex
•Complex is better than complicated
•Readability counts
…
• Practicality beats purity
Deep learning Semantics Zen of Python
31. Summary
❊ Ideal feature balances expressiveness with commutability
❊ A Seamless, Silky route from the feature to the platform
❊ It is OK to be Polyglot
❊ Each language specializes around a central theme
❊ Keep one eye on the intended workload, and other on the
underlying system
❊ Find the right tool for each jobs, and fuse them
32. Want to build a new Language?
❊ Obvious Challenge: Huge Initial Investment
❊ Build Language Runtime before building a Language:
Platform Abstraction
Memory management
Dynamic Compiler
Diagnostic support
❊ Eclipse OMR (Open Managed Runtime): (https://developer.ibm.com/open/omr)
Create and supply all common infrastructure components
Effort is better spent on Language features
Reduces (Relegates) the complexity
33. References
Java Virtual Machine Specification
https://docs.oracle.com/javase/specs/jvms/se8/jvms8.pdf
Intel Architecture Specification
http://www.intel.in/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-
manual-325462.pdf
Programming Language Classification
https://en.wikipedia.org/wiki/Category:Programming_language_classification
Python Language Reference
https://docs.python.org/3/reference/index.html
Swift Language Reference
https://swift.org/documentation/TheSwiftProgrammingLanguage(Swift3).epub
Node.js API reference
https://nodejs.org/api
Eclipse OMR
https://developer.ibm.com/open/omr/