0
grooscript
@grooscript
http://grooscript.org
grooscript@gmail.com
Jorge Franco
About me
Developer, I love it
Lazy in english at school
Living in Madrid
Working at Osoco
Grooscript developer
@jfrancolez...
The players
Web developer
Leave your
comfort zone
Move to
the client side
Doesn’t run!
on browsers
Do something!
No excuses
You can do a library,
resolve issues,
create a plugin,
give feedback,
help other projects,
…
!
Yo...
The wire
Groovy to Javascript converter
Groovy 2 to Javascript ECMAScript 5
Open source project, Apache 2 license
Library with Groo...
File.groovy File.js
Conversion!
Options
grooscript.js
Convert Groovy files
Groovy code
Javascript result
Javascript
Groovy
Java
MoreJavascriptfriendly
Types, inheritance, java 8, …
metaClass
ListsClosures
Operators
Dsl’s
Expand...
Limitations
Groovy / Java not fully supported
Working in groovy-core
No good support for inheritance
No methods with same ...
Directly convert code
Conversion options
convertDependencies - boolean - default false
classPath - List<String> or String - default null - Ex: ‘...
Convert dependencies option
Car.groovy
Wheel.groovy
Car.js
convert
== option
wheel
code
included
Main context scope
Customization
• Requires Groovy 2.1, the closure is passed to withConfig(conf)
• More info in http://doc...
Feature: Annotations
@GsNotConvert @GsNative
Feature: Daemon
>phantomjs myTest.js
Inject
grooscript.js
and jquery
Use Groovy
script abilities
I want to
be Groovier
@AST
http://phantom...
Mandatory Screen capture Before start test
More console info
Accept basic parameters
Works fine in GroovyTestCase
Not so we...
Example
Feature: builder
grooscript-builder.js
Demo websockets with Vert.x
https://github.com/chiquitinxx/demoGroovyMeteor
http://www.meteor.com
https://vimeo.com/593950...
https://github.com/chiquitinxx/grooscript-vertx-plugin
http://www.grails.org/plugin/grooscript-vertx
v 0.4
Grooscript Vert.x Plugin
Convert Groovy code to Javascript
Run conversion daemon
Websockets
Eventbus bridge
New port open
...
Differences?Renders
on server
Renders
on the client
Conversions are cached with cache plugin
Grooscript tags auto - import...
Grails
port 8080
Vert.x
port 8085
Browser
gsp
eventBus
http
websockets
Config.groovy
BootStrap.groovy Chat sample
main.gsp
More eventsBuilder
Where
Listen events Render on load
Send event message
= println
Execute on event message
Don’t use ${} ...
Domain classes in the client*
*Experimental, it requires Groovy 2.1 (grails 2.3)
• validate, clientValidations **
• hasErr...
Domain classes connected with the server*
*Experimental, it requires Groovy 2.1 (grails 2.3)
• list
• get
• save
• delete
PhantomJs Tests*
*Not working in Grails 2.3, need improvements
New test phase phantomjs
Tests in test/phantomjs
More featu...
features, features…
next release 0.5
Change resources plugin dependencies to Require.js
Improve domain options
PhantomJs t...
https://github.com/chiquitinxx/grooscript-gradle-plugin
v 0.2
Gradle plugin
Add in your build.gradle
http://grooscript.wordpress.com/2014/02/22/starting-with-grooscript/
Create more conversion tasks: http://grooscript.wordpress.com/2014/01/31/61/
Converted files destination
Require.js setup fi...
Demo springboot
http://projects.spring.io/spring-boot/
REST - Require.js - Grooscript Gradle Plugin - H2
https://github.co...
https://github.com/chiquitinxx/grooscript/tree/master/npm
Last demo :)
Node.js is very fast!
http://grooscript.wordpress.com/2014/01/10/impressive-node-js-v8-speed/
https://github....
Final topics
Coming next months…
grooscript 0.5
gradle plugin 0.3
Improve Groovy support (Java 8 too) and Javascript friendly
Add jQuer...
Why would I use grooscript?
• Create small modules to use in your views
• You can continue developing in Groovy
• Can use ...
Thank you!
All people reading this
680 motivation clicks
Jetbrains for IntelliJ IDEA v13 open source license
Special thank...
Beer time!
Grooscript greach
Upcoming SlideShare
Loading in...5
×

Grooscript greach

1,161

Published on

My talk about at Greach Madrid 2014

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,161
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
6
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Grooscript greach"

  1. 1. grooscript @grooscript http://grooscript.org grooscript@gmail.com Jorge Franco
  2. 2. About me Developer, I love it Lazy in english at school Living in Madrid Working at Osoco Grooscript developer @jfrancoleza jorge.franco.leza@gmail.com
  3. 3. The players
  4. 4. Web developer Leave your comfort zone Move to the client side
  5. 5. Doesn’t run! on browsers
  6. 6. Do something! No excuses You can do a library, resolve issues, create a plugin, give feedback, help other projects, … ! You will learn a lot
  7. 7. The wire
  8. 8. Groovy to Javascript converter Groovy 2 to Javascript ECMAScript 5 Open source project, Apache 2 license Library with Groovy and GPars dependencies No special Javascript objects or functions Converted code requires grooscript.js to run Different conversion options Grails plugin, npm package, gradle plugin What is grooscript?
  9. 9. File.groovy File.js Conversion! Options grooscript.js Convert Groovy files
  10. 10. Groovy code
  11. 11. Javascript result
  12. 12. Javascript Groovy Java MoreJavascriptfriendly Types, inheritance, java 8, … metaClass ListsClosures Operators Dsl’s ExpandoMaps beans methodMissing Mixins Categories
  13. 13. Limitations Groovy / Java not fully supported Working in groovy-core No good support for inheritance No methods with same name Basic support in metaClass No packages, no classes with same name No metainfo, expandoMetaClass, class info Only AST transformations applied in semantic phase No complex Java / Groovy types … see documentation for more info on grooscript.org
  14. 14. Directly convert code
  15. 15. Conversion options convertDependencies - boolean - default false classPath - List<String> or String - default null - Ex: ‘src/groovy’ customization - Closure - default null mainContextScope - List<String> - default null initialText / finalText - String - default null recursive - boolean - default false
  16. 16. Convert dependencies option Car.groovy Wheel.groovy Car.js convert == option wheel code included
  17. 17. Main context scope Customization • Requires Groovy 2.1, the closure is passed to withConfig(conf) • More info in http://docs.codehaus.org/display/GROOVY/Advanced+compiler+configuration • Sometimes you don’t know where to find a variable • When conversion is done, some variables come from other contexts • grooscript.js sometimes tries to find missed variables with eval • Node.js eval not working same way that browsers do • You can define variables or function names with this option • Ex. [‘$’, ‘myAwesomeFunction’, ‘myMissedVariable’]
  18. 18. Feature: Annotations @GsNotConvert @GsNative
  19. 19. Feature: Daemon
  20. 20. >phantomjs myTest.js Inject grooscript.js and jquery Use Groovy script abilities I want to be Groovier @AST http://phantomjs.org/ Please code in Groovy!
  21. 21. Mandatory Screen capture Before start test More console info Accept basic parameters Works fine in GroovyTestCase Not so well in Spock Have to define Phantom.js path Feature: PhantomJsTest
  22. 22. Example
  23. 23. Feature: builder grooscript-builder.js
  24. 24. Demo websockets with Vert.x https://github.com/chiquitinxx/demoGroovyMeteor http://www.meteor.com https://vimeo.com/59395085
  25. 25. https://github.com/chiquitinxx/grooscript-vertx-plugin http://www.grails.org/plugin/grooscript-vertx v 0.4
  26. 26. Grooscript Vert.x Plugin Convert Groovy code to Javascript Run conversion daemon Websockets Eventbus bridge New port open Events in the client Auto reload pages Both are optional http://grooscript.org/pluginManual/ v 1.3.1 Requires Java 1.7
  27. 27. Differences?Renders on server Renders on the client Conversions are cached with cache plugin Grooscript tags auto - import js files needed
  28. 28. Grails port 8080 Vert.x port 8085 Browser gsp eventBus http websockets Config.groovy BootStrap.groovy Chat sample main.gsp
  29. 29. More eventsBuilder Where Listen events Render on load Send event message = println Execute on event message Don’t use ${} in grooscript tags Strong dependency Resources plugin Can put code in a .groovy file
  30. 30. Domain classes in the client* *Experimental, it requires Groovy 2.1 (grails 2.3) • validate, clientValidations ** • hasErrors • count • list * without params • get • save * without params • delete
  31. 31. Domain classes connected with the server* *Experimental, it requires Groovy 2.1 (grails 2.3) • list • get • save • delete
  32. 32. PhantomJs Tests* *Not working in Grails 2.3, need improvements New test phase phantomjs Tests in test/phantomjs More features
  33. 33. features, features… next release 0.5 Change resources plugin dependencies to Require.js Improve domain options PhantomJs tests improvements Move to websockets with Spring 4 in 2.4 and many more… Remote domain class to grails REST support
  34. 34. https://github.com/chiquitinxx/grooscript-gradle-plugin v 0.2
  35. 35. Gradle plugin Add in your build.gradle http://grooscript.wordpress.com/2014/02/22/starting-with-grooscript/
  36. 36. Create more conversion tasks: http://grooscript.wordpress.com/2014/01/31/61/ Converted files destination Require.js setup file Files to be converted Bind id’s to presenter properties
  37. 37. Demo springboot http://projects.spring.io/spring-boot/ REST - Require.js - Grooscript Gradle Plugin - H2 https://github.com/chiquitinxx/springboot-rest-demo
  38. 38. https://github.com/chiquitinxx/grooscript/tree/master/npm
  39. 39. Last demo :) Node.js is very fast! http://grooscript.wordpress.com/2014/01/10/impressive-node-js-v8-speed/ https://github.com/chiquitinxx/colors
  40. 40. Final topics
  41. 41. Coming next months… grooscript 0.5 gradle plugin 0.3 Improve Groovy support (Java 8 too) and Javascript friendly Add jQuery and binder utilities Do tests also with Node.js Wait function in PhantomJs tests Remove binder and integrates with web frameworks website Back to dynamic, online conversions and robots! Improve documentation
  42. 42. Why would I use grooscript? • Create small modules to use in your views • You can continue developing in Groovy • Can use dsl’s, typeCheck, AST’s,… in the browser • You have all the java tools and IDE’s • You can work with new Javascript tools from Groovy • Don’t repeat code in two languages • Single development environment • Create your own architecture in Groovy • Don’t learn another “to Javascript” tool
  43. 43. Thank you! All people reading this 680 motivation clicks Jetbrains for IntelliJ IDEA v13 open source license Special thanks to René, @glaforge and @marioggar Community, I love your feedback Please… Version 0.4.4, time to improve Questions?
  44. 44. Beer time!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×