Monday, December 08, 2014

SpringOne2GX-2014 Day-4

Day-4 Sessions

Reactor and Reactive Streams - John Maldini, Stephan Brisbin
Reactor and Reactive Streams - John Maldini, Stephan Brisbin
My notes
  • NanoService, MicroService, NotTooBigService
  • Reactors are going to help across the boundaries, where microservices cross boundaries to interact with other services in order to get the work done. Microservice can be a method call, a db operation, a file operation etc. which has it’s own (thread) boundary.
  • Reactive Programming- Event driven, scalable, low-latency, fault-tolerant
  • Scaling doesn’t mean throwing more and more resources, often times more throughput can be achieved by scaling down the big operations into smaller so that they can go in and out quickly and better throughput can be achieved with smaller number of threads with less latency.
Groovy vampires, Combining Groovy, REST, NoSQL, and more - Kenneth Kousen

 My notes
  • Making Java Groovy Book: Ratpack next edition
  • REST    Addressible resources, Uniform interface (most public facing restful api are restricted to GET requests, read-only web-service), Content Negotiation (content type in url:e.g. JSON, or accept-header, POST req: both request-header and content-header to indicate what you are sending and what you can receive)
  • GET requests in Groovy are trivial: ‘...url...’.toURL().text()
  • s = [k1:v1, k2:v2].collect{k,v-> “$k=$v”}.join(‘&’)
  • s = [k1:v1, k2:v2].collect{it}.join(‘&’) //more groovier
  • JsonOutput.prettyPrint(url.toUrl().text())
    • commands (interactive javascript based console): mongo, show databases, use movies, show collections,
    • Java driver available com.mongodb.BasicDBObject
    • TODO: GMongo Project (Groovy) - take a look at the code, @delegate Mongo mongo, delegates to Java Mongo class
    • GMongo mongo = new GMongo(); def db = db.getdb(‘myDb’); db.myCollection.find()....//etc
    • db.myCollection << collection //populates mongo db collection, if not there it creates and populates
    • mongo db generates ids
  • Parsing JSON and converting to Java Objects
  • GSON, Google JSON to convert JSON to Java Object
  • Groovy is dynamically typed, but strongly typed language. JSON has no type, it’s weakly typed language.
  • Lazybones - Generates project templates
  • gvm : gvm c //gvm current
  • lazybones list //list all types of apps it can generate templates for, ratpack is one in the list
  • TIP:@Singleton : Groovy
  • TIP: @Shared : JUnit and Spock, if you don’t want vars to be re-initialized for each test…
  • TIP:groovy each vs. every: each returns a collection, every returns a boolean that satifies the statement in the closure
  • Grails: Alternative server, REST capabilities, Mongo plugin

Android and Groovy - a winning pair- Cedric Champeau

Android and Groovy - a winning pair- Cedric Champeau
 My notes
  • Why Android? Uses JVM, SDK is free, Tooling is freely available (Android Studio), don’t own a Mac, Swift (Apple) - inspired by Groovy, Scala and many languages
  • Why Groovy: Great features in the language and in the API, Built on top of Giant Java, Android developers shouldn’t be suffering, Java on Android is very verbose, incredibly verbose, tonnes of ceremony
  • Groovy on Android: the problems- Groovy is dynamic, lot of things happen at run-time, Intensive use of reflection, Potentially slow invocation paths, bytecode on Android is different. Multiple runtimes on Android: Dalvik, ART (new: your device becomes a compiler for the application, it compiles into native bytecode, application installation takes time, purely native code and there is no JVM on the device, so the app runs faster), Behavior not the same as the standard JVM
  • Discobot: 2 guys started Groovy on Android in 2011, forking Groovy 1.7. Groovy was not modularized at the time
  • Dex files: Dalvik VM is new bytecode format
  • Groovy 2.4: Android objectives- Main focus on @CompileStatic, Optional use of dynamic Groovy, Support Android in std distribution, Building a full Android application in Groovy, Bring the goodness of Groovy to Android, Opening new doors: Invent new frameworks.
  • Groovy for Android
    • Requirements: Gradle, Android Studio, Groovy 2.4.0-beta-3
    • Groovy 2.4 Android Support: Must use a specific Android jar, replaces java.beans with openbeans, reduced number of methods for 64k limit of dex files, workarounds for Android specific behavior
    • Gradle plugin: groovy-android plugin
    • Demo: an application on Android in Groovy which starts a countdown timer on Android device and syncs up the timer on Android wearable device (watch)
    • Demo: Create an app- Android studio, create project (mobile and wear), add needed stuff to build.gradle, rename the Java file to Groovy, make the code Groovy
  • TIP: @ClosureParams - with this param, you tell the compiler what type of parameter to infer when parameters are passed into closure without have to define the parameter types.
    • Groovifying Android APIs
    • Performance: GR8Conf Agenda app- Groovy jar 4.5MB, appl size: 2MB, After ProGuard only 1MB, 8.2MB of RAM (but lots of images). There is absolutely no difference from Java with the groovy app @CompilerStatic
    • Other Cool things:
      • SwissKnife - @OnClick(R.id.button) kind of method injections - all such tools are based on APT Annotation Processing Tools. In Groovy it’s all through AST
      • Grooid Tools: Builders for Views, experimental
      • Dragger-like dependency injection FW
      • Data binding APIs
      • Improved reactive APIs
  • Future is now: NYT - Next app will be written in Groovy
http://www.infoq.com/presentations/android-groovy-jvm?utm_campaign=infoq_content&utm_source=infoq&utm_medium=feed&utm_term=global

Takeaways for me:
  • Spring Boot
  • Java 8
  • Groovy 2.4 beta 3 for Android
  • Grails 2.3
  • Spock
This was my 4th Spring One conference, my first one was in 2006 and then I attended the ones in 2012 and 2013. There were about 1000+ attendees and it must have been the largest gathering ever, I guess. The food was good, speakers were great and it was a great great experience. I was totally in my professional world for 4 days and enjoyed every bit of it. Looking forward to more and more in future ;)

Have fun with SPRING Frameworks and Groovy! ;)

No comments:

Post a Comment