SlideShare a Scribd company logo
1 of 95
Download to read offline
1
Polyglot Plugin Development
How to write plugins in a language other than Java




Stefan Saasen
Confluence Team Lead, Atlassian

                                                     2
Audience
• Written an Atlassian plugin in Java
• Interested in other programming languages
• Eager to see what is possible with Atlassian plugins




                                                         3
Show of hands
• Who has actually written a Atlassian plugin?
• In any other language than Java?




                                                 4
5
Rhino
        6
7
https://bitbucket.org/ssaasen/atlassian-jruby-example-plugin

https://bitbucket.org/ssaasen/atlassian-scala-example-plugin




                                                               8
Polyglot Plugins
• Why?
• How?
 • Example 1: Scala
 • Example 2: JRuby

• Go and do it!


                      9
Why not?
           10
Why ?
        11
What to tell the boss?
• Leverage existing knowledge in the team
• Libraries/applications already written in language X
• Time to market/devspeed
• Explore technologies in a sandboxed environment
• Grass looks always greener on the other side


                                                         12
What to tell the boss?
• Leverage existing knowledge in the team
• Libraries/applications already written in language X
• Time to market/devspeed
• Explore technologies in a sandboxed environment
• Grass looks always greener on the other side


                                                         13
14
“No time to write in Java”

                  “Less bugs”
“Succinctness”
                                15
16
Polyglot Plugins
• Why?
• How?
 • Example 1: Scala
 • Example 2: JRuby

• Go and do it!


                      17
• Hybrid language: Object oriented & functional
• Concise, statically typed (with type inference)
• Higher order/first class functions, pattern matching
• Powerful type system
• Rich standard library


                                                        18
19
20
21
22
How?


       23
Overview

                                          Scala




                                                  scalac
                Scala Runtime Library

Java Bytecode
   *.class                                Java

                 Java Standard Library




                                                  javac
                                    JVM


                                                           24
25
26
Build process
• Start with Maven to get
  the AMPS goodness
• Use the maven-scala-
  plugin
• Add SBT if necessary



                            27
Build process f.
 • Compile time is a concern!
 • FSC
 • Useful Maven goals:
    mvn scala:cc
    mvn scala:console


                                28
Bundle runtime
                 29
Size might be a
  problem :(
                  30
Deployment options
     Option          Scope       Package        Size

                                mvn package
     Bundle          compile     -Pbundle
                                               8.5 MB    Simple

Bundle & Shrink                 mvn package              Deploy
                     compile                   680 KB
 w/ProGuard                     -Pproduction            externally

                                                         Deploy
Install separately   provided   mvn package    50 KB
                                                        internally
                                                                     31
Simply install using the
   plugin manager!

                           32
Development checklist
• Dependencies: Scala libraries are jar files and often
  available from Maven repositories
• Compile time: mvn scala:cc for continuous compilation
• Workflow: scala:cc & atlas-cli pi or
  mvn package && atlas-install-plugin
• Profit: mvn scala:console to get the Scala REPL

                                                          33
Scala: Working
with Java APIs
                 34
Scala gotchas (the 80%)
• Collections
• Method naming conventions
• Annotations
• Null vs. Option




                              35
Collections
 • Immutable vs Mutable, serial vs. parallel
 • Rich API: Prefer Scala collections
 • Convert between Java and Scala collections when
   calling Java methods
 • Solution: JavaConverters (explicit, preferred) vs.
   JavaConversions (implicit)
 • Watch out for serialization: Bandana/XStream
                                                        36
37
38
39
Method naming conventions
• Libraries rely on bean style naming conventions
  e.g. XWork, Velocity
• Scala: uniform access principle
• Solution: Use @BeanProperty and
  @BooleanBeanProperty



                                                    40
41
42
43
(Meta)-Annotations
• How to use @JavaAnnotation on a getter method
  when defining fields?
• Scala meta annotations @beanGetter, @beanGetter,
  @field, @getter, @setter




                                                     44
45
46
47
Option vs. null
 • In Scala Option represents an optional value.
 • Don’t let the billion-dollar mistake leak into your
   Scala code!
 • Solution: wrap nullable method calls in an Option




                                                         48
49
50
51
52
Show me the
   code!
              53
57
58
59
60
Example Scala plugin
• Servlet & XWork action
• Confluence macro
• REST via Jersey/Jackson
• Build setup
• Use as a starting point
                    https://bitbucket.org/ssaasen/atlassian-scala-example-plugin

                                                                                   61
Let’s recap
 • Replace Java entirely with Scala or mix and match
 • Runtime library: 3 deployment options
 • Fits into the AMPS development workflow
 • Scala Gotchas: watch out for common problems
 • “Scala is a great fit to write Atlassian plugins in”


                                                         62
Agenda
• Why?
• How?
 • Example 1: Scala
 • Example 2: JRuby

• Go and do it!


                      63
(J)Ruby
• Dynamic, object-oriented language
• Everything is an object (no “primitives”)
• Meta-programming and open, executable classes
  allow for easy creation of DSLs
• JRuby: Ruby runtime written in Java



                                                  64
65
How?


       66
Overview
                    Ruby
Ruby files *.rb                                  Your Ruby
                  Standard          RubyGems




                                                              jrubyc
                                                   Code
                   Library

                                  Ruby Runtime

Java Bytecode
   *.class                                             Java

                     Java Standard Library




                                                              javac
                                        JVM




                                                                       67
68
69
70
Plugins can’t be
written in Ruby

                   71
But we can still use
 Ruby in a plugin!

                       72
Recipe for using JRuby
• Embed the Ruby Runtime
• Use Java to execute Ruby scripts and classes
• Make components of the host application available
• Use the script execution result in Java




                                                      73
Embedding Strategies
• javax.scripting - JSR 223
• Apache Bean Scripting Framework (BSF)
• JRuby Embed - lower level JRuby API




                                          74
Embedding Strategies
• javax.scripting - JSR 223
  Only configurable via system properties :(
• Apache Bean scripting framework (BSF)
  No point in adding a separate API
• JRuby Embed - lower level JRuby API



                                              75
76
Building the plugin
• Package Ruby files
• Download and package Ruby gems
• Make Ruby gems available on the Ruby LOAD_PATH
• Bundle everything into a plugin jar file
• A lot of Maven XML :)
• Caveat: JRuby runtime is even larger!
                                                   77
Show me the
   code!
              78
79
80
1 minute


           81
82
83
84
85
86
87
88
89
Example JRuby plugin
• How to use Rubygem based
  libraries in a plugin
• How to access host
  components in Ruby
• How to use the execution result
• Sinatra in Confluence ;-)
                     https://bitbucket.org/ssaasen/atlassian-jruby-example-plugin
                                                                                    90
Let’s recap
• The plugin can’t be written in Ruby!
• Use the Ruby runtime
• Development workflow bonus: dynamic reloading!
• The overhead of adding the runtime and providing
  Java glue code makes this only feasible for high
  value use cases :(

                                                     91
Conclusion
• Scala is a great alternative when
  developing an Atlassian plugin
• JRuby is powerful, makes
  developing in a dynamic language
  possible but requires more work and
  custom Java adapter code
• Java interoperability needs to be well
  understood in both cases
                                           92
TAKE-AWAYS




“   The power of the Atlassian plugin framework allows
    you to build your plugins the way you want and

                                     ”
    Java doesn’t have to be the limit.




     #atlascamp


                                                         93
Thank you!




             94
• “Happy Foods” by swanksalot
  http://www.flickr.com/photos/swanksalot/5021262869/
• “Construction” by Daniel Morris
  http://www.flickr.com/photos/danielmorris/275438405/
• “70 80 90” by roujo
  http://www.flickr.com/photos/tekmagika/437989361



                                                        95

More Related Content

What's hot

Testing Ember Apps
Testing Ember AppsTesting Ember Apps
Testing Ember Appsjo_liss
 
An introduction and future of Ruby coverage library
An introduction and future of Ruby coverage libraryAn introduction and future of Ruby coverage library
An introduction and future of Ruby coverage librarymametter
 
A Taste of Pharo 7.0
A Taste of Pharo 7.0A Taste of Pharo 7.0
A Taste of Pharo 7.0ESUG
 
Camel Desing Patterns Learned Through Blood, Sweat, and Tears
Camel Desing Patterns Learned Through Blood, Sweat, and TearsCamel Desing Patterns Learned Through Blood, Sweat, and Tears
Camel Desing Patterns Learned Through Blood, Sweat, and TearsBilgin Ibryam
 
Capybara and cucumber with DSL using ruby
Capybara and cucumber with DSL using rubyCapybara and cucumber with DSL using ruby
Capybara and cucumber with DSL using rubyDeepak Chandella
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBrian Sam-Bodden
 
GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22Jorge Hidalgo
 
Cloud Native Camel Design Patterns
Cloud Native Camel Design PatternsCloud Native Camel Design Patterns
Cloud Native Camel Design PatternsBilgin Ibryam
 
JVM Memory Management Details
JVM Memory Management DetailsJVM Memory Management Details
JVM Memory Management DetailsAzul Systems Inc.
 
Event Driven Architecture with Apache Camel
Event Driven Architecture with Apache CamelEvent Driven Architecture with Apache Camel
Event Driven Architecture with Apache Camelprajods
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuningJerry Kurian
 
Performance of Microservice Frameworks on different JVMs
Performance of Microservice Frameworks on different JVMsPerformance of Microservice Frameworks on different JVMs
Performance of Microservice Frameworks on different JVMsMaarten Smeets
 
GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18Jorge Hidalgo
 
High performance network programming on the jvm oscon 2012
High performance network programming on the jvm   oscon 2012 High performance network programming on the jvm   oscon 2012
High performance network programming on the jvm oscon 2012 Erik Onnen
 
Maven: from Scratch to Production (.pdf)
Maven: from Scratch to Production (.pdf)Maven: from Scratch to Production (.pdf)
Maven: from Scratch to Production (.pdf)Johan Mynhardt
 
ToulouseJUG-Maven 3.x, will it lives up to its promises
ToulouseJUG-Maven 3.x, will it lives up to its promisesToulouseJUG-Maven 3.x, will it lives up to its promises
ToulouseJUG-Maven 3.x, will it lives up to its promisesArnaud Héritier
 
BordeauxJUG-Maven 3.x, will it lives up to its promises
BordeauxJUG-Maven 3.x, will it lives up to its promisesBordeauxJUG-Maven 3.x, will it lives up to its promises
BordeauxJUG-Maven 3.x, will it lives up to its promisesArnaud Héritier
 
From java-to-ruby-book-summary
From java-to-ruby-book-summaryFrom java-to-ruby-book-summary
From java-to-ruby-book-summary120bi
 

What's hot (20)

Testing Ember Apps
Testing Ember AppsTesting Ember Apps
Testing Ember Apps
 
An introduction and future of Ruby coverage library
An introduction and future of Ruby coverage libraryAn introduction and future of Ruby coverage library
An introduction and future of Ruby coverage library
 
A Taste of Pharo 7.0
A Taste of Pharo 7.0A Taste of Pharo 7.0
A Taste of Pharo 7.0
 
Camel Desing Patterns Learned Through Blood, Sweat, and Tears
Camel Desing Patterns Learned Through Blood, Sweat, and TearsCamel Desing Patterns Learned Through Blood, Sweat, and Tears
Camel Desing Patterns Learned Through Blood, Sweat, and Tears
 
Capybara and cucumber with DSL using ruby
Capybara and cucumber with DSL using rubyCapybara and cucumber with DSL using ruby
Capybara and cucumber with DSL using ruby
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRuby
 
GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22
 
Cloud Native Camel Design Patterns
Cloud Native Camel Design PatternsCloud Native Camel Design Patterns
Cloud Native Camel Design Patterns
 
Euruko 2012 - JRuby
Euruko 2012 - JRubyEuruko 2012 - JRuby
Euruko 2012 - JRuby
 
JVM Memory Management Details
JVM Memory Management DetailsJVM Memory Management Details
JVM Memory Management Details
 
Event Driven Architecture with Apache Camel
Event Driven Architecture with Apache CamelEvent Driven Architecture with Apache Camel
Event Driven Architecture with Apache Camel
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
 
Performance of Microservice Frameworks on different JVMs
Performance of Microservice Frameworks on different JVMsPerformance of Microservice Frameworks on different JVMs
Performance of Microservice Frameworks on different JVMs
 
GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18
 
High performance network programming on the jvm oscon 2012
High performance network programming on the jvm   oscon 2012 High performance network programming on the jvm   oscon 2012
High performance network programming on the jvm oscon 2012
 
Maven: from Scratch to Production (.pdf)
Maven: from Scratch to Production (.pdf)Maven: from Scratch to Production (.pdf)
Maven: from Scratch to Production (.pdf)
 
ToulouseJUG-Maven 3.x, will it lives up to its promises
ToulouseJUG-Maven 3.x, will it lives up to its promisesToulouseJUG-Maven 3.x, will it lives up to its promises
ToulouseJUG-Maven 3.x, will it lives up to its promises
 
BordeauxJUG-Maven 3.x, will it lives up to its promises
BordeauxJUG-Maven 3.x, will it lives up to its promisesBordeauxJUG-Maven 3.x, will it lives up to its promises
BordeauxJUG-Maven 3.x, will it lives up to its promises
 
MAVEN
MAVENMAVEN
MAVEN
 
From java-to-ruby-book-summary
From java-to-ruby-book-summaryFrom java-to-ruby-book-summary
From java-to-ruby-book-summary
 

Viewers also liked

Atlassian unite pix
Atlassian unite pixAtlassian unite pix
Atlassian unite pixAtlassian
 
Unite keynote all - mike's edit (don't edit!)
Unite keynote   all - mike's edit (don't edit!)Unite keynote   all - mike's edit (don't edit!)
Unite keynote all - mike's edit (don't edit!)Atlassian
 
Ravendb@swedenprogressive
Ravendb@swedenprogressiveRavendb@swedenprogressive
Ravendb@swedenprogressiveMikael Östberg
 
How HipChat Powers the HipChat Team - Atlassian Summit 2012
How HipChat Powers the HipChat Team - Atlassian Summit 2012How HipChat Powers the HipChat Team - Atlassian Summit 2012
How HipChat Powers the HipChat Team - Atlassian Summit 2012Atlassian
 
Atlassian Overview
Atlassian OverviewAtlassian Overview
Atlassian OverviewAtlassian
 
Guerilla marketing your service desk
Guerilla marketing your service deskGuerilla marketing your service desk
Guerilla marketing your service deskAtlassian
 

Viewers also liked (6)

Atlassian unite pix
Atlassian unite pixAtlassian unite pix
Atlassian unite pix
 
Unite keynote all - mike's edit (don't edit!)
Unite keynote   all - mike's edit (don't edit!)Unite keynote   all - mike's edit (don't edit!)
Unite keynote all - mike's edit (don't edit!)
 
Ravendb@swedenprogressive
Ravendb@swedenprogressiveRavendb@swedenprogressive
Ravendb@swedenprogressive
 
How HipChat Powers the HipChat Team - Atlassian Summit 2012
How HipChat Powers the HipChat Team - Atlassian Summit 2012How HipChat Powers the HipChat Team - Atlassian Summit 2012
How HipChat Powers the HipChat Team - Atlassian Summit 2012
 
Atlassian Overview
Atlassian OverviewAtlassian Overview
Atlassian Overview
 
Guerilla marketing your service desk
Guerilla marketing your service deskGuerilla marketing your service desk
Guerilla marketing your service desk
 

Similar to Polyglot Plugin Programming

Evolving IGN’s New APIs with Scala
 Evolving IGN’s New APIs with Scala Evolving IGN’s New APIs with Scala
Evolving IGN’s New APIs with ScalaManish Pandit
 
Scala in practice
Scala in practiceScala in practice
Scala in practiceTomer Gabel
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Robert Scholte
 
Introduction to Napa.js
Introduction to Napa.jsIntroduction to Napa.js
Introduction to Napa.jsDaiyi Peng
 
basic core java up to operator
basic core java up to operatorbasic core java up to operator
basic core java up to operatorkamal kotecha
 
MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?Joshua Ballanco
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Nilesh Panchal
 
Writing DSL's in Scala
Writing DSL's in ScalaWriting DSL's in Scala
Writing DSL's in ScalaAbhijit Sharma
 
Rust with-kafka-07-02-2019
Rust with-kafka-07-02-2019Rust with-kafka-07-02-2019
Rust with-kafka-07-02-2019Gerard Klijs
 
Using Scala for building DSLs
Using Scala for building DSLsUsing Scala for building DSLs
Using Scala for building DSLsIndicThreads
 
Better code, littler classes
Better code, littler classesBetter code, littler classes
Better code, littler classesdrewz lin
 
Scala adoption by enterprises
Scala adoption by enterprisesScala adoption by enterprises
Scala adoption by enterprisesMike Slinn
 
Java to scala
Java to scalaJava to scala
Java to scalaGiltTech
 
Scala in Model-Driven development for Apparel Cloud Platform
Scala in Model-Driven development for Apparel Cloud PlatformScala in Model-Driven development for Apparel Cloud Platform
Scala in Model-Driven development for Apparel Cloud PlatformTomoharu ASAMI
 
Enterprise OSGi at eBay
Enterprise OSGi at eBayEnterprise OSGi at eBay
Enterprise OSGi at eBayTony Ng
 
Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)Martijn Verburg
 

Similar to Polyglot Plugin Programming (20)

Polyglot Grails
Polyglot GrailsPolyglot Grails
Polyglot Grails
 
Evolving IGN’s New APIs with Scala
 Evolving IGN’s New APIs with Scala Evolving IGN’s New APIs with Scala
Evolving IGN’s New APIs with Scala
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
 
Ruby on the JVM
Ruby on the JVMRuby on the JVM
Ruby on the JVM
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)
 
Introduction to Napa.js
Introduction to Napa.jsIntroduction to Napa.js
Introduction to Napa.js
 
basic core java up to operator
basic core java up to operatorbasic core java up to operator
basic core java up to operator
 
MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Writing DSL's in Scala
Writing DSL's in ScalaWriting DSL's in Scala
Writing DSL's in Scala
 
Rust with-kafka-07-02-2019
Rust with-kafka-07-02-2019Rust with-kafka-07-02-2019
Rust with-kafka-07-02-2019
 
Using Scala for building DSLs
Using Scala for building DSLsUsing Scala for building DSLs
Using Scala for building DSLs
 
Better code, littler classes
Better code, littler classesBetter code, littler classes
Better code, littler classes
 
Scala adoption by enterprises
Scala adoption by enterprisesScala adoption by enterprises
Scala adoption by enterprises
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
 
Java to scala
Java to scalaJava to scala
Java to scala
 
Scala in Model-Driven development for Apparel Cloud Platform
Scala in Model-Driven development for Apparel Cloud PlatformScala in Model-Driven development for Apparel Cloud Platform
Scala in Model-Driven development for Apparel Cloud Platform
 
Enterprise OSGi at eBay
Enterprise OSGi at eBayEnterprise OSGi at eBay
Enterprise OSGi at eBay
 
Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)
 

More from Atlassian

International Women's Day 2020
International Women's Day 2020International Women's Day 2020
International Women's Day 2020Atlassian
 
10 emerging trends that will unbreak your workplace in 2020
10 emerging trends that will unbreak your workplace in 202010 emerging trends that will unbreak your workplace in 2020
10 emerging trends that will unbreak your workplace in 2020Atlassian
 
Forge App Showcase
Forge App ShowcaseForge App Showcase
Forge App ShowcaseAtlassian
 
Let's Build an Editor Macro with Forge UI
Let's Build an Editor Macro with Forge UILet's Build an Editor Macro with Forge UI
Let's Build an Editor Macro with Forge UIAtlassian
 
Meet the Forge Runtime
Meet the Forge RuntimeMeet the Forge Runtime
Meet the Forge RuntimeAtlassian
 
Forge UI: A New Way to Customize the Atlassian User Experience
Forge UI: A New Way to Customize the Atlassian User ExperienceForge UI: A New Way to Customize the Atlassian User Experience
Forge UI: A New Way to Customize the Atlassian User ExperienceAtlassian
 
Take Action with Forge Triggers
Take Action with Forge TriggersTake Action with Forge Triggers
Take Action with Forge TriggersAtlassian
 
Observability and Troubleshooting in Forge
Observability and Troubleshooting in ForgeObservability and Troubleshooting in Forge
Observability and Troubleshooting in ForgeAtlassian
 
Trusted by Default: The Forge Security & Privacy Model
Trusted by Default: The Forge Security & Privacy ModelTrusted by Default: The Forge Security & Privacy Model
Trusted by Default: The Forge Security & Privacy ModelAtlassian
 
Designing Forge UI: A Story of Designing an App UI System
Designing Forge UI: A Story of Designing an App UI SystemDesigning Forge UI: A Story of Designing an App UI System
Designing Forge UI: A Story of Designing an App UI SystemAtlassian
 
Forge: Under the Hood
Forge: Under the HoodForge: Under the Hood
Forge: Under the HoodAtlassian
 
Access to User Activities - Activity Platform APIs
Access to User Activities - Activity Platform APIsAccess to User Activities - Activity Platform APIs
Access to User Activities - Activity Platform APIsAtlassian
 
Design Your Next App with the Atlassian Vendor Sketch Plugin
Design Your Next App with the Atlassian Vendor Sketch PluginDesign Your Next App with the Atlassian Vendor Sketch Plugin
Design Your Next App with the Atlassian Vendor Sketch PluginAtlassian
 
Tear Up Your Roadmap and Get Out of the Building
Tear Up Your Roadmap and Get Out of the BuildingTear Up Your Roadmap and Get Out of the Building
Tear Up Your Roadmap and Get Out of the BuildingAtlassian
 
Nailing Measurement: a Framework for Measuring Metrics that Matter
Nailing Measurement: a Framework for Measuring Metrics that MatterNailing Measurement: a Framework for Measuring Metrics that Matter
Nailing Measurement: a Framework for Measuring Metrics that MatterAtlassian
 
Building Apps With Color Blind Users in Mind
Building Apps With Color Blind Users in MindBuilding Apps With Color Blind Users in Mind
Building Apps With Color Blind Users in MindAtlassian
 
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...Atlassian
 
Beyond Diversity: A Guide to Building Balanced Teams
Beyond Diversity: A Guide to Building Balanced TeamsBeyond Diversity: A Guide to Building Balanced Teams
Beyond Diversity: A Guide to Building Balanced TeamsAtlassian
 
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed Team
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed TeamThe Road(map) to Las Vegas - The Story of an Emerging Self-Managed Team
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed TeamAtlassian
 
Building Apps With Enterprise in Mind
Building Apps With Enterprise in MindBuilding Apps With Enterprise in Mind
Building Apps With Enterprise in MindAtlassian
 

More from Atlassian (20)

International Women's Day 2020
International Women's Day 2020International Women's Day 2020
International Women's Day 2020
 
10 emerging trends that will unbreak your workplace in 2020
10 emerging trends that will unbreak your workplace in 202010 emerging trends that will unbreak your workplace in 2020
10 emerging trends that will unbreak your workplace in 2020
 
Forge App Showcase
Forge App ShowcaseForge App Showcase
Forge App Showcase
 
Let's Build an Editor Macro with Forge UI
Let's Build an Editor Macro with Forge UILet's Build an Editor Macro with Forge UI
Let's Build an Editor Macro with Forge UI
 
Meet the Forge Runtime
Meet the Forge RuntimeMeet the Forge Runtime
Meet the Forge Runtime
 
Forge UI: A New Way to Customize the Atlassian User Experience
Forge UI: A New Way to Customize the Atlassian User ExperienceForge UI: A New Way to Customize the Atlassian User Experience
Forge UI: A New Way to Customize the Atlassian User Experience
 
Take Action with Forge Triggers
Take Action with Forge TriggersTake Action with Forge Triggers
Take Action with Forge Triggers
 
Observability and Troubleshooting in Forge
Observability and Troubleshooting in ForgeObservability and Troubleshooting in Forge
Observability and Troubleshooting in Forge
 
Trusted by Default: The Forge Security & Privacy Model
Trusted by Default: The Forge Security & Privacy ModelTrusted by Default: The Forge Security & Privacy Model
Trusted by Default: The Forge Security & Privacy Model
 
Designing Forge UI: A Story of Designing an App UI System
Designing Forge UI: A Story of Designing an App UI SystemDesigning Forge UI: A Story of Designing an App UI System
Designing Forge UI: A Story of Designing an App UI System
 
Forge: Under the Hood
Forge: Under the HoodForge: Under the Hood
Forge: Under the Hood
 
Access to User Activities - Activity Platform APIs
Access to User Activities - Activity Platform APIsAccess to User Activities - Activity Platform APIs
Access to User Activities - Activity Platform APIs
 
Design Your Next App with the Atlassian Vendor Sketch Plugin
Design Your Next App with the Atlassian Vendor Sketch PluginDesign Your Next App with the Atlassian Vendor Sketch Plugin
Design Your Next App with the Atlassian Vendor Sketch Plugin
 
Tear Up Your Roadmap and Get Out of the Building
Tear Up Your Roadmap and Get Out of the BuildingTear Up Your Roadmap and Get Out of the Building
Tear Up Your Roadmap and Get Out of the Building
 
Nailing Measurement: a Framework for Measuring Metrics that Matter
Nailing Measurement: a Framework for Measuring Metrics that MatterNailing Measurement: a Framework for Measuring Metrics that Matter
Nailing Measurement: a Framework for Measuring Metrics that Matter
 
Building Apps With Color Blind Users in Mind
Building Apps With Color Blind Users in MindBuilding Apps With Color Blind Users in Mind
Building Apps With Color Blind Users in Mind
 
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...
 
Beyond Diversity: A Guide to Building Balanced Teams
Beyond Diversity: A Guide to Building Balanced TeamsBeyond Diversity: A Guide to Building Balanced Teams
Beyond Diversity: A Guide to Building Balanced Teams
 
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed Team
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed TeamThe Road(map) to Las Vegas - The Story of an Emerging Self-Managed Team
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed Team
 
Building Apps With Enterprise in Mind
Building Apps With Enterprise in MindBuilding Apps With Enterprise in Mind
Building Apps With Enterprise in Mind
 

Recently uploaded

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 

Recently uploaded (20)

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 

Polyglot Plugin Programming

  • 1. 1
  • 2. Polyglot Plugin Development How to write plugins in a language other than Java Stefan Saasen Confluence Team Lead, Atlassian 2
  • 3. Audience • Written an Atlassian plugin in Java • Interested in other programming languages • Eager to see what is possible with Atlassian plugins 3
  • 4. Show of hands • Who has actually written a Atlassian plugin? • In any other language than Java? 4
  • 5. 5
  • 6. Rhino 6
  • 7. 7
  • 9. Polyglot Plugins • Why? • How? • Example 1: Scala • Example 2: JRuby • Go and do it! 9
  • 10. Why not? 10
  • 11. Why ? 11
  • 12. What to tell the boss? • Leverage existing knowledge in the team • Libraries/applications already written in language X • Time to market/devspeed • Explore technologies in a sandboxed environment • Grass looks always greener on the other side 12
  • 13. What to tell the boss? • Leverage existing knowledge in the team • Libraries/applications already written in language X • Time to market/devspeed • Explore technologies in a sandboxed environment • Grass looks always greener on the other side 13
  • 14. 14
  • 15. “No time to write in Java” “Less bugs” “Succinctness” 15
  • 16. 16
  • 17. Polyglot Plugins • Why? • How? • Example 1: Scala • Example 2: JRuby • Go and do it! 17
  • 18. • Hybrid language: Object oriented & functional • Concise, statically typed (with type inference) • Higher order/first class functions, pattern matching • Powerful type system • Rich standard library 18
  • 19. 19
  • 20. 20
  • 21. 21
  • 22. 22
  • 23. How? 23
  • 24. Overview Scala scalac Scala Runtime Library Java Bytecode *.class Java Java Standard Library javac JVM 24
  • 25. 25
  • 26. 26
  • 27. Build process • Start with Maven to get the AMPS goodness • Use the maven-scala- plugin • Add SBT if necessary 27
  • 28. Build process f. • Compile time is a concern! • FSC • Useful Maven goals: mvn scala:cc mvn scala:console 28
  • 30. Size might be a problem :( 30
  • 31. Deployment options Option Scope Package Size mvn package Bundle compile -Pbundle 8.5 MB Simple Bundle & Shrink mvn package Deploy compile 680 KB w/ProGuard -Pproduction externally Deploy Install separately provided mvn package 50 KB internally 31
  • 32. Simply install using the plugin manager! 32
  • 33. Development checklist • Dependencies: Scala libraries are jar files and often available from Maven repositories • Compile time: mvn scala:cc for continuous compilation • Workflow: scala:cc & atlas-cli pi or mvn package && atlas-install-plugin • Profit: mvn scala:console to get the Scala REPL 33
  • 35. Scala gotchas (the 80%) • Collections • Method naming conventions • Annotations • Null vs. Option 35
  • 36. Collections • Immutable vs Mutable, serial vs. parallel • Rich API: Prefer Scala collections • Convert between Java and Scala collections when calling Java methods • Solution: JavaConverters (explicit, preferred) vs. JavaConversions (implicit) • Watch out for serialization: Bandana/XStream 36
  • 37. 37
  • 38. 38
  • 39. 39
  • 40. Method naming conventions • Libraries rely on bean style naming conventions e.g. XWork, Velocity • Scala: uniform access principle • Solution: Use @BeanProperty and @BooleanBeanProperty 40
  • 41. 41
  • 42. 42
  • 43. 43
  • 44. (Meta)-Annotations • How to use @JavaAnnotation on a getter method when defining fields? • Scala meta annotations @beanGetter, @beanGetter, @field, @getter, @setter 44
  • 45. 45
  • 46. 46
  • 47. 47
  • 48. Option vs. null • In Scala Option represents an optional value. • Don’t let the billion-dollar mistake leak into your Scala code! • Solution: wrap nullable method calls in an Option 48
  • 49. 49
  • 50. 50
  • 51. 51
  • 52. 52
  • 53. Show me the code! 53
  • 54.
  • 55.
  • 56.
  • 57. 57
  • 58. 58
  • 59. 59
  • 60. 60
  • 61. Example Scala plugin • Servlet & XWork action • Confluence macro • REST via Jersey/Jackson • Build setup • Use as a starting point https://bitbucket.org/ssaasen/atlassian-scala-example-plugin 61
  • 62. Let’s recap • Replace Java entirely with Scala or mix and match • Runtime library: 3 deployment options • Fits into the AMPS development workflow • Scala Gotchas: watch out for common problems • “Scala is a great fit to write Atlassian plugins in” 62
  • 63. Agenda • Why? • How? • Example 1: Scala • Example 2: JRuby • Go and do it! 63
  • 64. (J)Ruby • Dynamic, object-oriented language • Everything is an object (no “primitives”) • Meta-programming and open, executable classes allow for easy creation of DSLs • JRuby: Ruby runtime written in Java 64
  • 65. 65
  • 66. How? 66
  • 67. Overview Ruby Ruby files *.rb Your Ruby Standard RubyGems jrubyc Code Library Ruby Runtime Java Bytecode *.class Java Java Standard Library javac JVM 67
  • 68. 68
  • 69. 69
  • 70. 70
  • 72. But we can still use Ruby in a plugin! 72
  • 73. Recipe for using JRuby • Embed the Ruby Runtime • Use Java to execute Ruby scripts and classes • Make components of the host application available • Use the script execution result in Java 73
  • 74. Embedding Strategies • javax.scripting - JSR 223 • Apache Bean Scripting Framework (BSF) • JRuby Embed - lower level JRuby API 74
  • 75. Embedding Strategies • javax.scripting - JSR 223 Only configurable via system properties :( • Apache Bean scripting framework (BSF) No point in adding a separate API • JRuby Embed - lower level JRuby API 75
  • 76. 76
  • 77. Building the plugin • Package Ruby files • Download and package Ruby gems • Make Ruby gems available on the Ruby LOAD_PATH • Bundle everything into a plugin jar file • A lot of Maven XML :) • Caveat: JRuby runtime is even larger! 77
  • 78. Show me the code! 78
  • 79. 79
  • 80. 80
  • 81. 1 minute 81
  • 82. 82
  • 83. 83
  • 84. 84
  • 85. 85
  • 86. 86
  • 87. 87
  • 88. 88
  • 89. 89
  • 90. Example JRuby plugin • How to use Rubygem based libraries in a plugin • How to access host components in Ruby • How to use the execution result • Sinatra in Confluence ;-) https://bitbucket.org/ssaasen/atlassian-jruby-example-plugin 90
  • 91. Let’s recap • The plugin can’t be written in Ruby! • Use the Ruby runtime • Development workflow bonus: dynamic reloading! • The overhead of adding the runtime and providing Java glue code makes this only feasible for high value use cases :( 91
  • 92. Conclusion • Scala is a great alternative when developing an Atlassian plugin • JRuby is powerful, makes developing in a dynamic language possible but requires more work and custom Java adapter code • Java interoperability needs to be well understood in both cases 92
  • 93. TAKE-AWAYS “ The power of the Atlassian plugin framework allows you to build your plugins the way you want and ” Java doesn’t have to be the limit. #atlascamp 93
  • 95. • “Happy Foods” by swanksalot http://www.flickr.com/photos/swanksalot/5021262869/ • “Construction” by Daniel Morris http://www.flickr.com/photos/danielmorris/275438405/ • “70 80 90” by roujo http://www.flickr.com/photos/tekmagika/437989361 95