contrasting java and dynamic languages
DESCRIPTION
Contrasting Java with Dynamic Languages (Python, Ruby and to some extent PHP)TRANSCRIPT
![Page 1: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/1.jpg)
Contrasting Java and Dynamic Languages
Dhananjay NeneSessions @ Java Pune Java Group
July 5, 2008
(c) : Dhananjay Nene blog : http://blog.dhananjaynene.com contact / mail : link available on blog
![Page 2: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/2.jpg)
What are Dynamic Languages
”Dynamic programming language is a term used broadly in computer science to describe a class of high level programming languages that execute at runtime many common behaviors that other languages might perform during compilation” Wikipedia
![Page 3: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/3.jpg)
Characteristics of dynamism
eval – ability to execute any text or nonmachine code data
runtime data structure alteration – ability to modify the type system at runtime altering the way existing types behave
functional characteristics closures and continuations
reflection
![Page 4: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/4.jpg)
Popular Dynamic Languages
Python Ruby PHP Perl Note: Not all have the same capabilities or
characteristics (Python / Ruby are much more dynamic, PHP is much easier to get started off with)
![Page 5: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/5.jpg)
Scripting languages ?
A highlevel programming language that is interpreted by another program at runtime rather than compiled by the computer’s processor
Most dynamic languages meet the above definition of scripting languages
![Page 6: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/6.jpg)
Scripting languages ? (2)
A scripting language, is a programming language that controls a software application. Wikipedia Most languages will not meet the above definition.
In context of Java these mean languages that can control or be controlled by Java code (and are JVM based)
![Page 7: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/7.jpg)
Scripting Languages using Java
Groovy Scala Beanshell Javascript (Rhino) Jython JRuby
![Page 8: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/8.jpg)
Dimensions of comparisons Developer Productivity
Brevity Impact of Build & Deploy Cycle Capability
Maintainability Readability, Refactorability, Verbosity
Framework Support Performance Enterprise / Library API Support
![Page 9: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/9.jpg)
Brevity
public class HelloWorld{ public static void main (String[] args) { System.out.println("Hello, world!"); }}
BufferedReader myFile = new BufferedReader(new FileReader(”a.txt”));
print 'Hello World'
myFile = open(”a.txt”)
![Page 10: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/10.jpg)
Brevity .. 2
What helps brevity No variable declarations Simpler Object Models Lesser Cruft (white space / braces) Compact structures (eg. code blocks, closures, functors) No getters / setters (properties are supported) Classes / Modules / Global code (not classes alone)
Our brain implements paging algorithms. Putting more logic on one page helps our brain deal with more logic at a time.
![Page 11: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/11.jpg)
Build and Deploy Cycle
Dependency management is much simpler No compile cycle. No build cycle during development Hot deploy means no startup / shutdown of web
apps This is a huge huge time saver for development
times
![Page 12: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/12.jpg)
Maintainability
In general system APIs are much simpler Code is much more readable / understandable Generally training required is much lower Compact code makes for easier maintenance I have found refactoring much tougher Dynamic typing takes away many of the checks
(possibility of more errors)
![Page 13: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/13.jpg)
Framework Support
All languages have decent framework support Ruby – Ruby on Rails, Merb Python – Django, Pylons, TurboGears, WebOb PHP – Zend, CodeIgniter, CakePHP etc
It is much easier to use frameworks Lesser code to write. Lesser places to write it in
![Page 14: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/14.jpg)
Performance
Java is likely to be much much faster than these languages especially if if you are focused on writing performant code if you have sufficiently CPU intensive code (ie. your
code isn't doing db or network access all the time) Raw code performance is often at least 10x.
Effective application performance may be 3x5x (gut feel not specifically benchmarked)
![Page 15: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/15.jpg)
Enterprise API / libraries support
Many years ago I believed this to be a major strength of Java. This competitive advantage is coming down with each passing year. API coverage of dynamic languages is now nearly close to that of Java.
![Page 16: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/16.jpg)
Characteristic strengths DLs
Code the same features faster ... sometimes much much much faster.
No compile / build / deploy downtime Get developers up the curve much faster One developer can more easily understand other's code Fewer options to evaluate may mean faster development Defect recording to Fix release time (not MTBF) can be cut
down
![Page 17: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/17.jpg)
Characteristic strengths Java Complex algorithms : Can be developed and maintained
much faster in DLs, will run much faster under Java Java is much better at handling high speed pipelines (eg.
messaging), highly concurrent applications and ability to leverage multicores (no GIL), has more architectural and deployment flexibility (vertical and horizontal scaling), strong multilingual capabilities
DLs are cost efficient at lower end. JEE is likely to be more efficient as you scale up.
JEE has more flexibilities at scaling. eg. jgroups, memcached, app server based session configurations etc.
![Page 18: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/18.jpg)
Internet full of DL based apps
DL based architectures may be more expensive at higher scales, but provide much much better risk management
If you are the architect and if it is your own money on the line .. what would you choose ?
For internet startups, the architect and entrepreneur role is often much closer or even merged .. one's own money on the line
This to me is the most compelling argument for DLs (rapid development + lower initial cost + agility + risk management)
![Page 19: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/19.jpg)
Analogies
Java
Developer Productivity Car Ferrari Runtime Performance Ferrari Truck Code Size Truck Enterprise Support Truck LCV Complex Handling Car
Dynamic Langs
Nano
Nano* Nano : An extremely compact low cost Indian car (US$ 2500) meeting all regulatory and emission standards likely to offer very efficient and nimble handling through crowded Indian roads* Truck : In Indian contexts a truck is a really large sized vehicle meant for hauling cargo. LCV is a light truck
![Page 20: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/20.jpg)
Candidate aplications for DLs Simple : Blogs, Wikis, Task Management Moderate : Issue Tracking, Project
Management, Network Monitoring, Social Networking, Content Management
Complex Algorithms: Metadata / DSL based processing, Complex algorithms (eg. operations research) not requiring extreme performance
Typical web based form processing apps riding on a relational database
![Page 21: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/21.jpg)
Candidate applications for Java Airline Ticketing Core Banking Telecom Switching Messaging Infrastructures Intrusion Detection Department level databases Any applications requiring extreme performance, or scaling
under modest budgets (especially those with high write %) Note : As hardware performance improves, more of these will
start becoming candidates for DL based development
![Page 22: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/22.jpg)
When Java
Requirements somewhat stable More predictable customer availability High Performance Required Developer Availability Existing Architecture Standards Initial Hardware and Hosting costs are not an
issue
![Page 23: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/23.jpg)
When Java Scripting Languages Want to use Groovy / Scala in standalone mode Java based development environment. May want to do say
20% outside java Java based hosting environment Architectural decision to make JVM the standard runtime Script around Java based software DO NOT BELIEVE because these are on the JVM or since
they compile to java bytecode, they are likely to be as fast as Java. They often arent.
![Page 24: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/24.jpg)
When Dynamic Languages Rapid Development is essential High Agility required in meeting changing requirements Customer (revenue) availability is less predictable Performance requirements are not extreme Low budgets for deployment / hosting Budgets not an issue for internet level scaling Prototyping Simple / moderate scale or high algorithmic complexity or
high risk applications
![Page 25: Contrasting Java And Dynamic Languages](https://reader034.vdocuments.mx/reader034/viewer/2022051817/54881a8cb4af9f730d8b55ed/html5/thumbnails/25.jpg)
Thank You for your patience !
Questions ??