SlideShare a Scribd company logo
1 of 73
Download to read offline
Scripting in Java
JavaLand 2014
25.03.2014, Lars Gregori
Scripting in Java
JavaLand 2014
25.03.2014, Lars Gregori
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Lars Gregori
 msgGillardon AG
 CoC IT-Architekturen
 learn a new language every year
--- The Pragmatic Programmer
3
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 4
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 5
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Was sind Scriptsprachen?
Wikipedia:
„Scriptsprachen sind Programmiersprachen, die vor allem für kleine,
überschaubare Programme gedacht sind. Sie verzichten oft auf
bestimmte Sprachelemente, deren Nutzen erst bei der Bearbeitung
größerer Projekte zum Tragen kommen. So wird etwa in
Skriptsprachen auf den Deklarationszwang von Variablen meist
verzichtet - vorteilhaft zur schnellen Erstellung von kleinen
Programmen (siehe auch Prototyping), bei großen hingegen von
Nachteil, etwa wegen der fehlenden Überprüfungsmöglichkeit von
Tippfehlern in Variablennamen.“
6
http://de.wikipedia.org/wiki/Skriptsprache
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Was sind Scriptsprachen?
Wikipedia:
„Scriptsprachen sind Programmiersprachen, die vor allem für kleine,
überschaubare Programme gedacht sind. Sie verzichten oft auf
bestimmte Sprachelemente, deren Nutzen erst bei der Bearbeitung
größerer Projekte zum Tragen kommen. So wird etwa in
Skriptsprachen auf den Deklarationszwang von Variablen meist
verzichtet - vorteilhaft zur schnellen Erstellung von kleinen
Programmen (siehe auch Prototyping), bei großen hingegen von
Nachteil, etwa wegen der fehlenden Überprüfungsmöglichkeit von
Tippfehlern in Variablennamen.“
7
http://de.wikipedia.org/wiki/Skriptsprache
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Static vs. Dynamic Typing
 Most scripting languages are dynamically typed
 explicit type declarations not required
 type information is attached to values, not to variables
 Java is static-typed
 require variable type (declaration time)
 only data of declared type
8
https://confluence.deri.ie:8443/display/romulus/Scripting+Languages+and+java
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Weak vs. Strong Typing
 Java is a static, strongly typed language
 strongest possible constraint on the type of object at declaration time
 prevents mixing operations between mismatched types
 Many scripting languages are weakly typed
 allow operations on incompatible types
 implicit type conversion or ad-hoc polymorphism
9
https://confluence.deri.ie:8443/display/romulus/Scripting+Languages+and+java
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Weak vs. Strong Typing
 Java is a static, strongly typed language
 strongest possible constraint on the type of object at declaration time
 prevents mixing operations between mismatched types
 Many scripting languages are weakly typed
 allow operations on incompatible types
 implicit type conversion or ad-hoc polymorphism
10
https://confluence.deri.ie:8443/display/romulus/Scripting+Languages+and+java
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Quality and Performance
 Scripting languages are more compact and readable
 less lines of code
 weak typing not requiring the overhead of type declaration
 Fewer lines of code and less complexity means lower amounts of
bugs, thus reducing development and maintenance costs.
 The missing type information has some disadvantages.
 static, strongly typed languages ensure the robustness
 type errors will be detected at compile time
11
https://confluence.deri.ie:8443/display/romulus/Scripting+Languages+and+java
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Quality and Performance
 runtime performance
 extra overhead of the interpreter and runtime checks
 not performed at compile time
12
http://attractivechaos.github.io/plb/
https://confluence.deri.ie:8443/display/romulus/Scripting+Languages+and+java
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Quality and Performance
 runtime performance
 extra overhead of the interpreter and runtime checks
 not performed at compile time
13
http://attractivechaos.github.io/plb/
https://confluence.deri.ie:8443/display/romulus/Scripting+Languages+and+java
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 14
Motivation
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Motivation
 cool
 mal etwas anderes
 macht Spass
 JATUMBA
15
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Motivation
 elegant und einfach erweitern
 Konfigurationsdatei
 Datenbank
16
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Motivation
 elegant und einfach erweitern
 Konfigurationsdatei
 Datenbank
17
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
 passender
 Inner DSL
(JRuby)
 String Manipulation
(Jython, Perl)
 map / reduce
(Lisp, Clojure)
 GroovySQL,
GroovyMarkup
 Templates
Motivation
18
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
 passender
 Inner DSL
(JRuby)
 String Manipulation
(Jython, Perl)
 map / reduce
(Lisp, Clojure)
 GroovySQL,
GroovyMarkup
 Templates
Motivation
19
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Motivation
 selbe Technologie
Frontend und Backend
 Javascript Validierung
20
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Motivation
 selbe Technologie
Frontend und Backend
 Javascript Validierung
21
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Motivation
 langsamer als Java
 Entwickler muss
andere Sprache lernen
22
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Motivation
 langsamer als Java
 Entwickler muss
andere Sprache lernen
23
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 24
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Buch
25
http://www.scriptinginjava.net/
Scripting in Java:
Languages, Frameworks, and Patterns
by Dejan Bosanac
Publisher: Addison Wesley Professional
Pub Date: August 31, 2007 (est.)
Print ISBN-10: 0-321-32193-6
Print ISBN-13: 978-0-321-32193-0
eText ISBN-10: 0-321-50933-1
eText ISBN-13: 978-0-321-50933-8
Pages: 432
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Scriptsprachen in Java einbinden
 kompilieren
 eigene Engine
 Bean Scripting Framework (BSF)
 JSR 223 – Scripting for the Java Platform
26
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
kompilieren – groovyc
27
package my.groovy.jartest
class Answer {
def answer() {
42
}
}
package my.groovy.jartest;
import groovy.lang.GroovyObject;
public class Answer implements GroovyObject
{
...
public Object answer()
{
CallSite[] arrayOfCallSite = $getCallSiteArray();
return Integer.valueOf(42);
return null;
}
}
import my.groovy.jartest;
...
Answer answer = new Answer();
int a = (Integer) answer.answer();
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Script Engine
28
GroovyShell gs = new GroovyShell();
String script = "return 42";
int answer = (Integer) gs.evaluate(script);
Binding binding = new Binding();
binding.setVariable("foo", new Integer(2));
GroovyShell shell = new GroovyShell(binding);
Object value = shell.evaluate(
"println 'Hello World!'; x = 123; return foo * 10");
assert value.equals(new Integer(20));
assert binding.getVariable("x").equals(new Integer(123));
http://groovy.codehaus.org/Embedding+Groovy
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Bean Scripting Framework (BSF)
 http://commons.apache.org/proper/commons-bsf/
 Bean Scripting Framework (BSF) is a set of Java classes which
provides scripting language support within Java applications, and
access to Java objects and methods from scripting languages.
29
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Bean Scripting Framework (BSF) – Beispiel
30
BSFManager manager = new BSFManager();
manager.declareBean("a", 6, Integer.class);
manager.declareBean("b", 7, Integer.class);
String script = "var answer = a * b;" +
"bsf.registerBean("answer", answer)";
manager.eval("javascript", "blah", 0, 0, script);
Double answer = (Double) manager.lookupBean("answer");
assertEquals(42, answer.intValue());
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 31
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
JSR-223 – Scripting for the Java Platform
 The specification describe mechanisms allowing scripting language
programs to access information developed in the Java Platform …
https://jcp.org/en/jsr/detail?id=223
 Java 1.6+
 Rhino JavaScript for Java version 1.6R2
 javax.script.*
 jrunscript
 http://docs.oracle.com/javase/6/docs/technotes/tools/share/jrunscript.html
32
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
ServiceLoader
 Since: 1.6
 http://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html
 META-INF/services/javax.script.ScriptEngineFactory
 This file contains the single line:
de.torq.clojure.jsr223.ClojureScriptEngineFactory
 Clojure JSR 223 build.xml
 https://github.com/pmf/clojure-jsr223/blob/master/build.xml
33
<jar jarfile="${clojure_jsr223_bundle}" basedir="${build_osgi}">
<service type="javax.script.ScriptEngineFactory“
provider="de.torq.clojure.jsr223.ClojureScriptEngineFactory"/>
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
JSR-223 – script engines
34
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 35
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Beispiele
 JRuby
 Groovy
 Clojure
36
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 37
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
JDK 8 – Was ist neu?
 Nashorn
 Lambda
 …
38
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 39
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Nashorn
 JEP 174
 http://openjdk.java.net/jeps/174
 ECMAScript-262 Edition 5.1
 http://ecma-international.org/ecma-262/5.1/
 javax.script (JSR 223)
40
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Nashorn
41
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 42
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Lambda
 JSR 335
 Lambda Expressions for the Java Programming Language
 https://jcp.org/en/jsr/detail?id=335
 Final Specification
43
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 44
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 45
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
invokedynamic
 JavaScript
 4 + 2
 4 + “hallo”
  add(a, b)
46
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
 http://niklasschlimm.blogspot.de/2012/02/java-7-complete-
invokedynamic-example.html
47
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
 http://niklasschlimm.blogspot.de/2012/02/java-7-complete-
invokedynamic-example.html
48
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 49
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Invokedynamic – Jetzt und Zukunft?
 JRuby
 Groovy
 groovy-indy
 Clojure?
50
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 51
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Bytecode
 Bytecode Frameworks
 ASM : http://asm.ow2.org/
 Javassist : http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/
 Jitescript : https://github.com/qmx/jitescript
 …
52
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 53
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 54
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Da Vinci Machine
 a multi-language renaissance
for the Java Virtual Machine architecture
 http://openjdk.java.net/projects/mlvm/
 dynamic invocation
 continuations
 tail-calls
 interface injection
55
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 56
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Credits & making of
 Fotos
 Anja Gregori
 Font
 Chopin Script by ClaudeP
 http://www.dafont.com/chopin-script.font
 Eclipse Plugin
 Bytecode Outline plugin for Eclipse
 http://andrei.gmxhome.de/bytecode/
57
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 58
Wir bedanken uns für Ihre Aufmerksamkeit!
msgGillardon AG
Robert-Bürkle-Str. 1
85737 Ismaning
> www.msg-gillardon.de
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 60
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
Range Kata
 http://codingdojo.org/cgi-bin/wiki.pl?KataRange
61
integer range contains
[2,6) contains {2,4}
[2,6) doesn't contain {-1,1,6,10}
getAllPoints?
[2,6) allPoints = {2,3,4,5}
ContainsRange?
[2,5) doesn't contain [7,10)
[2,5) doesn't contain [3,10)
[3,5) doesn't contain [2,10)
[2,10) contains [3,5]
[3,5] contains [3,5)
endPoints
[2,6) allPoints = {2,3,4,5}
[2,6] allPoints = {2,3,4,5,6}
(2,6) allPoints = {3,4,5}
(2,6] allPoints = {3,4,5,6}
overlapsRange
[2,5) doesn't overlap with [7,10)
[2,10) overlaps with [3,5)
[3,5) overlaps with [3,5)
[2,5) overlaps with [3,10)
[3,5) overlaps with [2,10)
Equals
[3,5) equals [3,5)
[2,10) neq [3,5)
[2,5) neq [3,10)
[3,5) neq [2,10)
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014
List of freely available programming books
 http://stackoverflow.com/questions/194812/list-of-freely-available-
programming-books/392926#392926
62
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 63
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 64
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 65
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 66
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 67
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 68
JSR 223:
https://code.google.com/p/clojure-jsr223/
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 69
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 70
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 71
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 72
© 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 73

More Related Content

Similar to Scripting In Java

Building domain-specific languages with Groovy
Building domain-specific languages with GroovyBuilding domain-specific languages with Groovy
Building domain-specific languages with GroovyYaroslav Yermilov
 
Java Course in Gurgaon: Your Gateway to Mastering Java Programming
Java Course in Gurgaon: Your Gateway to Mastering Java ProgrammingJava Course in Gurgaon: Your Gateway to Mastering Java Programming
Java Course in Gurgaon: Your Gateway to Mastering Java ProgrammingUncodemy
 
Why Should You Learn Java in 2023?
Why Should You Learn Java in 2023?Why Should You Learn Java in 2023?
Why Should You Learn Java in 2023?Uncodemy
 
NodeJS vs Golang - A detailed comparison
NodeJS vs Golang - A detailed comparisonNodeJS vs Golang - A detailed comparison
NodeJS vs Golang - A detailed comparisonDevathon
 
Gr8Conf US 2017 - From Java to Groovy: Adventure Time!
Gr8Conf US 2017 - From Java to Groovy: Adventure Time!Gr8Conf US 2017 - From Java to Groovy: Adventure Time!
Gr8Conf US 2017 - From Java to Groovy: Adventure Time!Iván López Martín
 
JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!Iván López Martín
 
JRuby in a Java World
JRuby in a Java WorldJRuby in a Java World
JRuby in a Java WorldMark Menard
 
JavaScript nicht nur für Programmierer: Einblicke in die weltweit am meisten ...
JavaScript nicht nur für Programmierer: Einblicke in die weltweit am meisten ...JavaScript nicht nur für Programmierer: Einblicke in die weltweit am meisten ...
JavaScript nicht nur für Programmierer: Einblicke in die weltweit am meisten ...Peter Hecker
 
MomentumSI Programming Language Recommendations
MomentumSI Programming Language RecommendationsMomentumSI Programming Language Recommendations
MomentumSI Programming Language RecommendationsJeff Schneider
 
Step by Step Guide on Essay Format in APA For Beginners
Step by Step Guide on Essay Format in APA For BeginnersStep by Step Guide on Essay Format in APA For Beginners
Step by Step Guide on Essay Format in APA For Beginnerscalltutors
 
What is Java Coding?
What is Java Coding?What is Java Coding?
What is Java Coding?JAMESJOHN130
 
JavaScript Interview Questions and Answers | Full Stack Web Development Train...
JavaScript Interview Questions and Answers | Full Stack Web Development Train...JavaScript Interview Questions and Answers | Full Stack Web Development Train...
JavaScript Interview Questions and Answers | Full Stack Web Development Train...Edureka!
 
What all things to consider for a good career in java
What all things to consider for a good career in javaWhat all things to consider for a good career in java
What all things to consider for a good career in javaJanBask Training
 
Understanding the Pros and Cons of Java Software Development
Understanding the Pros and Cons of Java Software DevelopmentUnderstanding the Pros and Cons of Java Software Development
Understanding the Pros and Cons of Java Software DevelopmentBoTree Technologies
 
Java Course in Delhi
Java Course in DelhiJava Course in Delhi
Java Course in Delhidigital anil
 
Comparative Study of programming Languages
Comparative Study of programming LanguagesComparative Study of programming Languages
Comparative Study of programming LanguagesIshan Monga
 

Similar to Scripting In Java (20)

Building domain-specific languages with Groovy
Building domain-specific languages with GroovyBuilding domain-specific languages with Groovy
Building domain-specific languages with Groovy
 
Java Course in Gurgaon: Your Gateway to Mastering Java Programming
Java Course in Gurgaon: Your Gateway to Mastering Java ProgrammingJava Course in Gurgaon: Your Gateway to Mastering Java Programming
Java Course in Gurgaon: Your Gateway to Mastering Java Programming
 
Why Should You Learn Java in 2023?
Why Should You Learn Java in 2023?Why Should You Learn Java in 2023?
Why Should You Learn Java in 2023?
 
NodeJS vs Golang - A detailed comparison
NodeJS vs Golang - A detailed comparisonNodeJS vs Golang - A detailed comparison
NodeJS vs Golang - A detailed comparison
 
Gr8Conf US 2017 - From Java to Groovy: Adventure Time!
Gr8Conf US 2017 - From Java to Groovy: Adventure Time!Gr8Conf US 2017 - From Java to Groovy: Adventure Time!
Gr8Conf US 2017 - From Java to Groovy: Adventure Time!
 
String class
String classString class
String class
 
JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!JavaCro 2016 - From Java to Groovy: Adventure Time!
JavaCro 2016 - From Java to Groovy: Adventure Time!
 
Java.pdf
Java.pdfJava.pdf
Java.pdf
 
JRuby in a Java World
JRuby in a Java WorldJRuby in a Java World
JRuby in a Java World
 
JavaScript nicht nur für Programmierer: Einblicke in die weltweit am meisten ...
JavaScript nicht nur für Programmierer: Einblicke in die weltweit am meisten ...JavaScript nicht nur für Programmierer: Einblicke in die weltweit am meisten ...
JavaScript nicht nur für Programmierer: Einblicke in die weltweit am meisten ...
 
MomentumSI Programming Language Recommendations
MomentumSI Programming Language RecommendationsMomentumSI Programming Language Recommendations
MomentumSI Programming Language Recommendations
 
Step by Step Guide on Essay Format in APA For Beginners
Step by Step Guide on Essay Format in APA For BeginnersStep by Step Guide on Essay Format in APA For Beginners
Step by Step Guide on Essay Format in APA For Beginners
 
What is Java Coding?
What is Java Coding?What is Java Coding?
What is Java Coding?
 
JavaScript Interview Questions and Answers | Full Stack Web Development Train...
JavaScript Interview Questions and Answers | Full Stack Web Development Train...JavaScript Interview Questions and Answers | Full Stack Web Development Train...
JavaScript Interview Questions and Answers | Full Stack Web Development Train...
 
What all things to consider for a good career in java
What all things to consider for a good career in javaWhat all things to consider for a good career in java
What all things to consider for a good career in java
 
Understanding the Pros and Cons of Java Software Development
Understanding the Pros and Cons of Java Software DevelopmentUnderstanding the Pros and Cons of Java Software Development
Understanding the Pros and Cons of Java Software Development
 
Training report
Training reportTraining report
Training report
 
Java for C++ programers
Java for C++ programersJava for C++ programers
Java for C++ programers
 
Java Course in Delhi
Java Course in DelhiJava Course in Delhi
Java Course in Delhi
 
Comparative Study of programming Languages
Comparative Study of programming LanguagesComparative Study of programming Languages
Comparative Study of programming Languages
 

More from Lars Gregori

BYOM - Bring Your Own Model
BYOM - Bring Your Own ModelBYOM - Bring Your Own Model
BYOM - Bring Your Own ModelLars Gregori
 
uTensor - embedded devices and machine learning models
uTensor - embedded devices and machine learning modelsuTensor - embedded devices and machine learning models
uTensor - embedded devices and machine learning modelsLars Gregori
 
SAP Leonardo Machine Learning
SAP Leonardo Machine LearningSAP Leonardo Machine Learning
SAP Leonardo Machine LearningLars Gregori
 
Minecraft and reinforcement learning
Minecraft and reinforcement learningMinecraft and reinforcement learning
Minecraft and reinforcement learningLars Gregori
 
Machine Learning Models on Mobile Devices
Machine Learning Models on Mobile DevicesMachine Learning Models on Mobile Devices
Machine Learning Models on Mobile DevicesLars Gregori
 
Minecraft and Reinforcement Learning
Minecraft and Reinforcement LearningMinecraft and Reinforcement Learning
Minecraft and Reinforcement LearningLars Gregori
 
IoT protocolls - smart washing machine
IoT protocolls - smart washing machineIoT protocolls - smart washing machine
IoT protocolls - smart washing machineLars Gregori
 
[DE] AI und Minecraft
[DE] AI und Minecraft[DE] AI und Minecraft
[DE] AI und MinecraftLars Gregori
 
Minecraft and Reinforcement Learning
Minecraft and Reinforcement LearningMinecraft and Reinforcement Learning
Minecraft and Reinforcement LearningLars Gregori
 
[DE] IoT Protokolle
[DE] IoT Protokolle[DE] IoT Protokolle
[DE] IoT ProtokolleLars Gregori
 
Using a trained model on your mobile device
Using a trained model on your mobile deviceUsing a trained model on your mobile device
Using a trained model on your mobile deviceLars Gregori
 
Using a trained model on your mobile device
Using a trained model on your mobile deviceUsing a trained model on your mobile device
Using a trained model on your mobile deviceLars Gregori
 
[German] Boards für das IoT-Prototyping
[German] Boards für das IoT-Prototyping[German] Boards für das IoT-Prototyping
[German] Boards für das IoT-PrototypingLars Gregori
 
IoT, APIs und Microservices - alles unter Node-RED
IoT, APIs und Microservices - alles unter Node-REDIoT, APIs und Microservices - alles unter Node-RED
IoT, APIs und Microservices - alles unter Node-REDLars Gregori
 
Web Bluetooth - Next Generation Bluetooth?
Web Bluetooth - Next Generation Bluetooth?   Web Bluetooth - Next Generation Bluetooth?
Web Bluetooth - Next Generation Bluetooth? Lars Gregori
 
Embedded Rust – Rust on IoT devices
Embedded Rust – Rust on IoT devicesEmbedded Rust – Rust on IoT devices
Embedded Rust – Rust on IoT devicesLars Gregori
 
Embedded Rust on IoT devices
Embedded Rust on IoT devicesEmbedded Rust on IoT devices
Embedded Rust on IoT devicesLars Gregori
 
IoT mit Rust programmieren
IoT mit Rust programmierenIoT mit Rust programmieren
IoT mit Rust programmierenLars Gregori
 
Boards for the IoT-Prototyping
Boards for the IoT-PrototypingBoards for the IoT-Prototyping
Boards for the IoT-PrototypingLars Gregori
 

More from Lars Gregori (20)

BYOM - Bring Your Own Model
BYOM - Bring Your Own ModelBYOM - Bring Your Own Model
BYOM - Bring Your Own Model
 
uTensor - embedded devices and machine learning models
uTensor - embedded devices and machine learning modelsuTensor - embedded devices and machine learning models
uTensor - embedded devices and machine learning models
 
SAP Leonardo Machine Learning
SAP Leonardo Machine LearningSAP Leonardo Machine Learning
SAP Leonardo Machine Learning
 
Minecraft and reinforcement learning
Minecraft and reinforcement learningMinecraft and reinforcement learning
Minecraft and reinforcement learning
 
Machine Learning Models on Mobile Devices
Machine Learning Models on Mobile DevicesMachine Learning Models on Mobile Devices
Machine Learning Models on Mobile Devices
 
Minecraft and Reinforcement Learning
Minecraft and Reinforcement LearningMinecraft and Reinforcement Learning
Minecraft and Reinforcement Learning
 
IoT protocolls - smart washing machine
IoT protocolls - smart washing machineIoT protocolls - smart washing machine
IoT protocolls - smart washing machine
 
[DE] AI und Minecraft
[DE] AI und Minecraft[DE] AI und Minecraft
[DE] AI und Minecraft
 
Minecraft and Reinforcement Learning
Minecraft and Reinforcement LearningMinecraft and Reinforcement Learning
Minecraft and Reinforcement Learning
 
[DE] IoT Protokolle
[DE] IoT Protokolle[DE] IoT Protokolle
[DE] IoT Protokolle
 
Using a trained model on your mobile device
Using a trained model on your mobile deviceUsing a trained model on your mobile device
Using a trained model on your mobile device
 
Using a trained model on your mobile device
Using a trained model on your mobile deviceUsing a trained model on your mobile device
Using a trained model on your mobile device
 
AI and Minecraft
AI and MinecraftAI and Minecraft
AI and Minecraft
 
[German] Boards für das IoT-Prototyping
[German] Boards für das IoT-Prototyping[German] Boards für das IoT-Prototyping
[German] Boards für das IoT-Prototyping
 
IoT, APIs und Microservices - alles unter Node-RED
IoT, APIs und Microservices - alles unter Node-REDIoT, APIs und Microservices - alles unter Node-RED
IoT, APIs und Microservices - alles unter Node-RED
 
Web Bluetooth - Next Generation Bluetooth?
Web Bluetooth - Next Generation Bluetooth?   Web Bluetooth - Next Generation Bluetooth?
Web Bluetooth - Next Generation Bluetooth?
 
Embedded Rust – Rust on IoT devices
Embedded Rust – Rust on IoT devicesEmbedded Rust – Rust on IoT devices
Embedded Rust – Rust on IoT devices
 
Embedded Rust on IoT devices
Embedded Rust on IoT devicesEmbedded Rust on IoT devices
Embedded Rust on IoT devices
 
IoT mit Rust programmieren
IoT mit Rust programmierenIoT mit Rust programmieren
IoT mit Rust programmieren
 
Boards for the IoT-Prototyping
Boards for the IoT-PrototypingBoards for the IoT-Prototyping
Boards for the IoT-Prototyping
 

Recently uploaded

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 

Recently uploaded (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 

Scripting In Java

  • 1. Scripting in Java JavaLand 2014 25.03.2014, Lars Gregori
  • 2. Scripting in Java JavaLand 2014 25.03.2014, Lars Gregori
  • 3. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Lars Gregori  msgGillardon AG  CoC IT-Architekturen  learn a new language every year --- The Pragmatic Programmer 3
  • 4. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 4
  • 5. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 5
  • 6. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Was sind Scriptsprachen? Wikipedia: „Scriptsprachen sind Programmiersprachen, die vor allem für kleine, überschaubare Programme gedacht sind. Sie verzichten oft auf bestimmte Sprachelemente, deren Nutzen erst bei der Bearbeitung größerer Projekte zum Tragen kommen. So wird etwa in Skriptsprachen auf den Deklarationszwang von Variablen meist verzichtet - vorteilhaft zur schnellen Erstellung von kleinen Programmen (siehe auch Prototyping), bei großen hingegen von Nachteil, etwa wegen der fehlenden Überprüfungsmöglichkeit von Tippfehlern in Variablennamen.“ 6 http://de.wikipedia.org/wiki/Skriptsprache
  • 7. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Was sind Scriptsprachen? Wikipedia: „Scriptsprachen sind Programmiersprachen, die vor allem für kleine, überschaubare Programme gedacht sind. Sie verzichten oft auf bestimmte Sprachelemente, deren Nutzen erst bei der Bearbeitung größerer Projekte zum Tragen kommen. So wird etwa in Skriptsprachen auf den Deklarationszwang von Variablen meist verzichtet - vorteilhaft zur schnellen Erstellung von kleinen Programmen (siehe auch Prototyping), bei großen hingegen von Nachteil, etwa wegen der fehlenden Überprüfungsmöglichkeit von Tippfehlern in Variablennamen.“ 7 http://de.wikipedia.org/wiki/Skriptsprache
  • 8. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Static vs. Dynamic Typing  Most scripting languages are dynamically typed  explicit type declarations not required  type information is attached to values, not to variables  Java is static-typed  require variable type (declaration time)  only data of declared type 8 https://confluence.deri.ie:8443/display/romulus/Scripting+Languages+and+java
  • 9. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Weak vs. Strong Typing  Java is a static, strongly typed language  strongest possible constraint on the type of object at declaration time  prevents mixing operations between mismatched types  Many scripting languages are weakly typed  allow operations on incompatible types  implicit type conversion or ad-hoc polymorphism 9 https://confluence.deri.ie:8443/display/romulus/Scripting+Languages+and+java
  • 10. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Weak vs. Strong Typing  Java is a static, strongly typed language  strongest possible constraint on the type of object at declaration time  prevents mixing operations between mismatched types  Many scripting languages are weakly typed  allow operations on incompatible types  implicit type conversion or ad-hoc polymorphism 10 https://confluence.deri.ie:8443/display/romulus/Scripting+Languages+and+java
  • 11. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Quality and Performance  Scripting languages are more compact and readable  less lines of code  weak typing not requiring the overhead of type declaration  Fewer lines of code and less complexity means lower amounts of bugs, thus reducing development and maintenance costs.  The missing type information has some disadvantages.  static, strongly typed languages ensure the robustness  type errors will be detected at compile time 11 https://confluence.deri.ie:8443/display/romulus/Scripting+Languages+and+java
  • 12. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Quality and Performance  runtime performance  extra overhead of the interpreter and runtime checks  not performed at compile time 12 http://attractivechaos.github.io/plb/ https://confluence.deri.ie:8443/display/romulus/Scripting+Languages+and+java
  • 13. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Quality and Performance  runtime performance  extra overhead of the interpreter and runtime checks  not performed at compile time 13 http://attractivechaos.github.io/plb/ https://confluence.deri.ie:8443/display/romulus/Scripting+Languages+and+java
  • 14. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 14 Motivation
  • 15. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Motivation  cool  mal etwas anderes  macht Spass  JATUMBA 15
  • 16. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Motivation  elegant und einfach erweitern  Konfigurationsdatei  Datenbank 16
  • 17. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Motivation  elegant und einfach erweitern  Konfigurationsdatei  Datenbank 17
  • 18. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014  passender  Inner DSL (JRuby)  String Manipulation (Jython, Perl)  map / reduce (Lisp, Clojure)  GroovySQL, GroovyMarkup  Templates Motivation 18
  • 19. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014  passender  Inner DSL (JRuby)  String Manipulation (Jython, Perl)  map / reduce (Lisp, Clojure)  GroovySQL, GroovyMarkup  Templates Motivation 19
  • 20. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Motivation  selbe Technologie Frontend und Backend  Javascript Validierung 20
  • 21. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Motivation  selbe Technologie Frontend und Backend  Javascript Validierung 21
  • 22. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Motivation  langsamer als Java  Entwickler muss andere Sprache lernen 22
  • 23. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Motivation  langsamer als Java  Entwickler muss andere Sprache lernen 23
  • 24. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 24
  • 25. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Buch 25 http://www.scriptinginjava.net/ Scripting in Java: Languages, Frameworks, and Patterns by Dejan Bosanac Publisher: Addison Wesley Professional Pub Date: August 31, 2007 (est.) Print ISBN-10: 0-321-32193-6 Print ISBN-13: 978-0-321-32193-0 eText ISBN-10: 0-321-50933-1 eText ISBN-13: 978-0-321-50933-8 Pages: 432
  • 26. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Scriptsprachen in Java einbinden  kompilieren  eigene Engine  Bean Scripting Framework (BSF)  JSR 223 – Scripting for the Java Platform 26
  • 27. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 kompilieren – groovyc 27 package my.groovy.jartest class Answer { def answer() { 42 } } package my.groovy.jartest; import groovy.lang.GroovyObject; public class Answer implements GroovyObject { ... public Object answer() { CallSite[] arrayOfCallSite = $getCallSiteArray(); return Integer.valueOf(42); return null; } } import my.groovy.jartest; ... Answer answer = new Answer(); int a = (Integer) answer.answer();
  • 28. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Script Engine 28 GroovyShell gs = new GroovyShell(); String script = "return 42"; int answer = (Integer) gs.evaluate(script); Binding binding = new Binding(); binding.setVariable("foo", new Integer(2)); GroovyShell shell = new GroovyShell(binding); Object value = shell.evaluate( "println 'Hello World!'; x = 123; return foo * 10"); assert value.equals(new Integer(20)); assert binding.getVariable("x").equals(new Integer(123)); http://groovy.codehaus.org/Embedding+Groovy
  • 29. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Bean Scripting Framework (BSF)  http://commons.apache.org/proper/commons-bsf/  Bean Scripting Framework (BSF) is a set of Java classes which provides scripting language support within Java applications, and access to Java objects and methods from scripting languages. 29
  • 30. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Bean Scripting Framework (BSF) – Beispiel 30 BSFManager manager = new BSFManager(); manager.declareBean("a", 6, Integer.class); manager.declareBean("b", 7, Integer.class); String script = "var answer = a * b;" + "bsf.registerBean("answer", answer)"; manager.eval("javascript", "blah", 0, 0, script); Double answer = (Double) manager.lookupBean("answer"); assertEquals(42, answer.intValue());
  • 31. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 31
  • 32. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 JSR-223 – Scripting for the Java Platform  The specification describe mechanisms allowing scripting language programs to access information developed in the Java Platform … https://jcp.org/en/jsr/detail?id=223  Java 1.6+  Rhino JavaScript for Java version 1.6R2  javax.script.*  jrunscript  http://docs.oracle.com/javase/6/docs/technotes/tools/share/jrunscript.html 32
  • 33. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 ServiceLoader  Since: 1.6  http://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html  META-INF/services/javax.script.ScriptEngineFactory  This file contains the single line: de.torq.clojure.jsr223.ClojureScriptEngineFactory  Clojure JSR 223 build.xml  https://github.com/pmf/clojure-jsr223/blob/master/build.xml 33 <jar jarfile="${clojure_jsr223_bundle}" basedir="${build_osgi}"> <service type="javax.script.ScriptEngineFactory“ provider="de.torq.clojure.jsr223.ClojureScriptEngineFactory"/>
  • 34. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 JSR-223 – script engines 34
  • 35. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 35
  • 36. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Beispiele  JRuby  Groovy  Clojure 36
  • 37. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 37
  • 38. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 JDK 8 – Was ist neu?  Nashorn  Lambda  … 38
  • 39. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 39
  • 40. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Nashorn  JEP 174  http://openjdk.java.net/jeps/174  ECMAScript-262 Edition 5.1  http://ecma-international.org/ecma-262/5.1/  javax.script (JSR 223) 40
  • 41. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Nashorn 41
  • 42. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 42
  • 43. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Lambda  JSR 335  Lambda Expressions for the Java Programming Language  https://jcp.org/en/jsr/detail?id=335  Final Specification 43
  • 44. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 44
  • 45. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 45
  • 46. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 invokedynamic  JavaScript  4 + 2  4 + “hallo”   add(a, b) 46
  • 47. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014  http://niklasschlimm.blogspot.de/2012/02/java-7-complete- invokedynamic-example.html 47
  • 48. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014  http://niklasschlimm.blogspot.de/2012/02/java-7-complete- invokedynamic-example.html 48
  • 49. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 49
  • 50. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Invokedynamic – Jetzt und Zukunft?  JRuby  Groovy  groovy-indy  Clojure? 50
  • 51. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 51
  • 52. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Bytecode  Bytecode Frameworks  ASM : http://asm.ow2.org/  Javassist : http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/  Jitescript : https://github.com/qmx/jitescript  … 52
  • 53. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 53
  • 54. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 54
  • 55. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Da Vinci Machine  a multi-language renaissance for the Java Virtual Machine architecture  http://openjdk.java.net/projects/mlvm/  dynamic invocation  continuations  tail-calls  interface injection 55
  • 56. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 56
  • 57. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Credits & making of  Fotos  Anja Gregori  Font  Chopin Script by ClaudeP  http://www.dafont.com/chopin-script.font  Eclipse Plugin  Bytecode Outline plugin for Eclipse  http://andrei.gmxhome.de/bytecode/ 57
  • 58. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 58
  • 59. Wir bedanken uns für Ihre Aufmerksamkeit! msgGillardon AG Robert-Bürkle-Str. 1 85737 Ismaning > www.msg-gillardon.de
  • 60. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 60
  • 61. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 Range Kata  http://codingdojo.org/cgi-bin/wiki.pl?KataRange 61 integer range contains [2,6) contains {2,4} [2,6) doesn't contain {-1,1,6,10} getAllPoints? [2,6) allPoints = {2,3,4,5} ContainsRange? [2,5) doesn't contain [7,10) [2,5) doesn't contain [3,10) [3,5) doesn't contain [2,10) [2,10) contains [3,5] [3,5] contains [3,5) endPoints [2,6) allPoints = {2,3,4,5} [2,6] allPoints = {2,3,4,5,6} (2,6) allPoints = {3,4,5} (2,6] allPoints = {3,4,5,6} overlapsRange [2,5) doesn't overlap with [7,10) [2,10) overlaps with [3,5) [3,5) overlaps with [3,5) [2,5) overlaps with [3,10) [3,5) overlaps with [2,10) Equals [3,5) equals [3,5) [2,10) neq [3,5) [2,5) neq [3,10) [3,5) neq [2,10)
  • 62. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 List of freely available programming books  http://stackoverflow.com/questions/194812/list-of-freely-available- programming-books/392926#392926 62
  • 63. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 63
  • 64. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 64
  • 65. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 65
  • 66. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 66
  • 67. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 67
  • 68. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 68 JSR 223: https://code.google.com/p/clojure-jsr223/
  • 69. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 69
  • 70. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 70
  • 71. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 71
  • 72. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 72
  • 73. © 2014 Lars Gregori, msgGillardon AG | Scripting in Java | 25.03.2014 73