SlideShare a Scribd company logo
Code Generation with
Sven Efftinge - itemis
What is it?
Successor to Xpand
Built with
Why ?
much faster (as fast as Java)
much better IDE support
generalized set of features
simpler
Code Generation Essentials
Template Expression
(aka string concatenation)
same syntax as in Xpand
just an expression
greyspace support!
Codegeneration With Xtend
static typing
simply Java
no pluggable type system
can be emulated with
active annotations
longitude & latitude
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
higher-order functions
map, filter, flatten, etc.
it’s just library!
class TypeProviderExample {
	
	 def getHourlyData() {
	 	 data.weather.hourlys
	 }
	
	 def getTimeWithHighestSwell() {
	 	 hourlyData.sortBy[swellheightM].head.time
	 }
	
	 def getAverageWindSpeed() {
	 	 hourlyData.map[windspeedkmph].reduce[a,b|a+b] / hourlyData.size
	 }
}
dynamic dispatch
dynamic dispatch
dynamic dispatch
easily debuggable & extendable
dynamic dispatch
	 def generate(ETypedElement e) {
	 	 switch e {
	 	 	 EAttribute : '''
	 	 	 	 attribute
	 	 	 '''
	 	 	 EReference case e.isContainment: '''
	 	 	 	 containment reference
	 	 	 '''
	 	 	 EReference : '''
	 	 	 	 reference
	 	 	 '''
	 	 	 EOperation : '''
	 	 	 	 operation
	 	 	 '''
	 	 	 default : throw new IllegalArgumentException("not handled : "+e)
	 	 }
	 }
dispatch over type and state
first come
first serve
modularization
AOP?
Dependency Injection!
class MainGenerator {
	
	 @Inject extension EcoreGen ecoreGenerator
	
	 def doGenerate(EClass it) '''
	 	 class «name» {
	 	 	 «FOR f : EStructuralFeatures»
	 	 	 	 «f.generate»
	 	 	 «ENDFOR»
	 	 }
	 '''
}
class EcoreGen {
	
	 def dispatch generate(EAttribute attribute) '''
	 	 generate attribute
	 '''
	
	 def dispatch generate(EReference reference) '''
	 	 generate reference
	 '''
	
	 def dispatch generate(EOperation operation) '''
	 	 generate operation
	 '''
}
declare the dependency
class MySpecialEcoreGen extends EcoreGen {
	
	 override dispatch generate(EAttribute attribute) '''
	 	 special EAttribute
	 '''
	
	 def dispatch generate(EParameter param) '''
	 	 parameter
	 '''
}
class CustomizedGenerator {
	 def static void main(String[] args) {
	 	 val injector = Guice::createInjector [
	 	 	 bind(typeof(EcoreGen)).to(typeof(MySpecialEcoreGen))
	 	 ]
	 	 val mainGenerator = injector.getInstance(typeof(MainGenerator))
	 	 mainGenerator.doGenerate(EcorePackage::eINSTANCE.EClass)
	 }
}
Extend the class you want to modify
Use Guice to wire up the generator
content assist
syntax coloring
quick assist outline
rename refactoring
formating
call hierarchy
type hierarchy
extract method
debugging
etc...
IDE Support
But why always a DSL?
MyBean
String value
class
MyBean
String value
class {
}
@Observable
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
Codegeneration With Xtend
future work
tooling via library
more macro support
embedded languages
snappiness!
Thank you!
@svenefftinge / @xtext / @xtendlang (c) 2013 by

More Related Content

PDF
Building DSLs With Eclipse
Peter Friese
 
PDF
Recipes to build Code Generators for Non-Xtext Models with Xtend
Karsten Thoms
 
PDF
Auto-GWT : Better GWT Programming with Xtend
Sven Efftinge
 
KEY
Gwt and Xtend
Sven Efftinge
 
PDF
Activator and Reactive at Play NYC meetup
Henrik Engström
 
PDF
React Native One Day
Troy Miles
 
PDF
Node Boot Camp
Troy Miles
 
PDF
GR8Conf 2011: GPars
GR8Conf
 
Building DSLs With Eclipse
Peter Friese
 
Recipes to build Code Generators for Non-Xtext Models with Xtend
Karsten Thoms
 
Auto-GWT : Better GWT Programming with Xtend
Sven Efftinge
 
Gwt and Xtend
Sven Efftinge
 
Activator and Reactive at Play NYC meetup
Henrik Engström
 
React Native One Day
Troy Miles
 
Node Boot Camp
Troy Miles
 
GR8Conf 2011: GPars
GR8Conf
 

What's hot (20)

PDF
Testing Backbone applications with Jasmine
Leon van der Grient
 
PDF
React Native Evening
Troy Miles
 
PPTX
Introduction to underscore.js
Jitendra Zaa
 
PDF
Elegant Solutions for Everyday Python Problems Pycon 2018 - Nina Zakharenko
Nina Zakharenko
 
PDF
Rails on Oracle 2011
Raimonds Simanovskis
 
PDF
Protocol-Oriented MVVM
Natasha Murashev
 
PDF
Why Every Tester Should Learn Ruby
Raimonds Simanovskis
 
PDF
Mobile Open Day: React Native: Crossplatform fast dive
epamspb
 
PDF
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Raimonds Simanovskis
 
PDF
Powerful JavaScript Tips and Best Practices
Dragos Ionita
 
PDF
Selenium cheat sheet
Sri Priya P Kulkarni
 
PDF
Elegant Solutions For Everyday Python Problems - PyCon Canada 2017
Nina Zakharenko
 
PDF
Ten useful JavaScript tips & best practices
Ankit Rastogi
 
PPTX
Softshake 2013: 10 reasons why java developers are jealous of Scala developers
Matthew Farwell
 
ODP
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Knoldus Inc.
 
PPTX
Arrays & functions in php
Ashish Chamoli
 
PDF
How much performance can you get out of Javascript? - Massimiliano Mantione -...
Codemotion
 
PPTX
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Domenic Denicola
 
PPTX
Workshop 1: Good practices in JavaScript
Visual Engineering
 
Testing Backbone applications with Jasmine
Leon van der Grient
 
React Native Evening
Troy Miles
 
Introduction to underscore.js
Jitendra Zaa
 
Elegant Solutions for Everyday Python Problems Pycon 2018 - Nina Zakharenko
Nina Zakharenko
 
Rails on Oracle 2011
Raimonds Simanovskis
 
Protocol-Oriented MVVM
Natasha Murashev
 
Why Every Tester Should Learn Ruby
Raimonds Simanovskis
 
Mobile Open Day: React Native: Crossplatform fast dive
epamspb
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Raimonds Simanovskis
 
Powerful JavaScript Tips and Best Practices
Dragos Ionita
 
Selenium cheat sheet
Sri Priya P Kulkarni
 
Elegant Solutions For Everyday Python Problems - PyCon Canada 2017
Nina Zakharenko
 
Ten useful JavaScript tips & best practices
Ankit Rastogi
 
Softshake 2013: 10 reasons why java developers are jealous of Scala developers
Matthew Farwell
 
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Knoldus Inc.
 
Arrays & functions in php
Ashish Chamoli
 
How much performance can you get out of Javascript? - Massimiliano Mantione -...
Codemotion
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Domenic Denicola
 
Workshop 1: Good practices in JavaScript
Visual Engineering
 
Ad

Similar to Codegeneration With Xtend (20)

PPT
Intro to JavaFX & Widget FX
Stephen Chin
 
KEY
And the Greatest of These Is ... Rack Support
Ben Scofield
 
PDF
Java Annotation Processing: A Beginner Walkthrough
Mahfuz Islam Bhuiyan
 
ODP
To inject or not to inject: CDI is the question
Antonio Goncalves
 
PDF
Workshop 23: ReactJS, React & Redux testing
Visual Engineering
 
PDF
アプリを弄ってみる #1 #antama_ws
Takahiro Yoshimura
 
PDF
QA Lab: тестирование ПО. Яков Крамаренко: "KISS Automation"
GeeksLab Odessa
 
PDF
Clojure - A new Lisp
elliando dias
 
PDF
Front End Development: The Important Parts
Sergey Bolshchikov
 
PDF
All I Need to Know I Learned by Writing My Own Web Framework
Ben Scofield
 
ODP
From Java 6 to Java 7 reference
Giacomo Veneri
 
PDF
From android/ java to swift (2)
allanh0526
 
PDF
Why the Dark Side should use Swift and a SOLID Architecture
Jorge Ortiz
 
PDF
Ember background basics
Philipp Fehre
 
KEY
(map Clojure everyday-tasks)
Jacek Laskowski
 
ODP
JavaFX Mix
giampaolo.melis
 
PPTX
Tools for Making Machine Learning more Reactive
Jeff Smith
 
PDF
Xtext Webinar
Heiko Behrens
 
PDF
Overview of The Scala Based Lift Web Framework
IndicThreads
 
PDF
Scala based Lift Framework
vhazrati
 
Intro to JavaFX & Widget FX
Stephen Chin
 
And the Greatest of These Is ... Rack Support
Ben Scofield
 
Java Annotation Processing: A Beginner Walkthrough
Mahfuz Islam Bhuiyan
 
To inject or not to inject: CDI is the question
Antonio Goncalves
 
Workshop 23: ReactJS, React & Redux testing
Visual Engineering
 
アプリを弄ってみる #1 #antama_ws
Takahiro Yoshimura
 
QA Lab: тестирование ПО. Яков Крамаренко: "KISS Automation"
GeeksLab Odessa
 
Clojure - A new Lisp
elliando dias
 
Front End Development: The Important Parts
Sergey Bolshchikov
 
All I Need to Know I Learned by Writing My Own Web Framework
Ben Scofield
 
From Java 6 to Java 7 reference
Giacomo Veneri
 
From android/ java to swift (2)
allanh0526
 
Why the Dark Side should use Swift and a SOLID Architecture
Jorge Ortiz
 
Ember background basics
Philipp Fehre
 
(map Clojure everyday-tasks)
Jacek Laskowski
 
JavaFX Mix
giampaolo.melis
 
Tools for Making Machine Learning more Reactive
Jeff Smith
 
Xtext Webinar
Heiko Behrens
 
Overview of The Scala Based Lift Web Framework
IndicThreads
 
Scala based Lift Framework
vhazrati
 
Ad

More from Sven Efftinge (20)

PDF
Parsing Expression With Xtext
Sven Efftinge
 
PDF
Language Engineering With Xtext
Sven Efftinge
 
PDF
Future of Xtext
Sven Efftinge
 
PDF
Functional programming with Xtend
Sven Efftinge
 
KEY
Domain Specific Languages (EclipseCon 2012)
Sven Efftinge
 
KEY
Xtend @ EclipseCon 2012
Sven Efftinge
 
KEY
Eclipse Xtend
Sven Efftinge
 
PDF
This Is Not Your Father's Java
Sven Efftinge
 
KEY
Getting the most out of Java [Nordic Coding-2010]
Sven Efftinge
 
PDF
Xtext at MDD Day 2010
Sven Efftinge
 
PDF
Dependency Injection for Eclipse developers
Sven Efftinge
 
PDF
Xtext Webinar
Sven Efftinge
 
KEY
Challenges In Dsl Design
Sven Efftinge
 
KEY
Code Generation in Agile Projects
Sven Efftinge
 
KEY
Xtext Eclipse Con
Sven Efftinge
 
KEY
Generic Editor
Sven Efftinge
 
PDF
Eclipse Banking Day
Sven Efftinge
 
PDF
Bessere Softwareentwicklung (Itemis Wintercon)
Sven Efftinge
 
PDF
Domain-Specific Languages in der Praxis
Sven Efftinge
 
PDF
Xtext @ Profict Summer Camp
Sven Efftinge
 
Parsing Expression With Xtext
Sven Efftinge
 
Language Engineering With Xtext
Sven Efftinge
 
Future of Xtext
Sven Efftinge
 
Functional programming with Xtend
Sven Efftinge
 
Domain Specific Languages (EclipseCon 2012)
Sven Efftinge
 
Xtend @ EclipseCon 2012
Sven Efftinge
 
Eclipse Xtend
Sven Efftinge
 
This Is Not Your Father's Java
Sven Efftinge
 
Getting the most out of Java [Nordic Coding-2010]
Sven Efftinge
 
Xtext at MDD Day 2010
Sven Efftinge
 
Dependency Injection for Eclipse developers
Sven Efftinge
 
Xtext Webinar
Sven Efftinge
 
Challenges In Dsl Design
Sven Efftinge
 
Code Generation in Agile Projects
Sven Efftinge
 
Xtext Eclipse Con
Sven Efftinge
 
Generic Editor
Sven Efftinge
 
Eclipse Banking Day
Sven Efftinge
 
Bessere Softwareentwicklung (Itemis Wintercon)
Sven Efftinge
 
Domain-Specific Languages in der Praxis
Sven Efftinge
 
Xtext @ Profict Summer Camp
Sven Efftinge
 

Recently uploaded (20)

PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 

Codegeneration With Xtend