I would like to show my new "actionloop" based Scala runtime!
Yes I know,  it is already possible to use Scala with the Java runtime.  But 
you have to compile, create a jar, include libraries
This one is based on the scripting shell "Ammonite" http://ammonite.io and 
works more like js and python.

Here is a  simple demo:

https://openwhisk.eu-de.bluemix.net/api/v1/web/sciabarra_cloud/scala/calc

And this is the source code:

----
import play.api.libs.json._
import scala.util.Try

def main(args: JsObject) : JsObject = {
    val a = if(args \ "a" isDefined) {
        Try(args("a").as[String].toInt).getOrElse(0)
    } else 0
    val b = if(args \ "b" isDefined) {
        Try(args("b").as[String].toInt).getOrElse(0)
    } else 0
    if( args \ "add" isDefined) {
        html(Some(s"${a} + ${b} = ${a+b}"))
    } else if ( args \ "mul" isDefined) {
        html(Some(s"${a} * ${b} = ${a*b}"))
    } else html()
}

def html(msg: Option[String]=None) = {
    val body = s"""<html><body>
${if(msg.isEmpty) "" else "<h1>"+msg.get+"</h1>"}
<form>
  <input name="a" size="4">
  <input name="b" size="4">
  <button name="add">+</button>
  <button name="mul">*</button>
</form></body></html>"""
    Json.obj("body" -> body)
}
----

Deployed with this command:

wsk action update scala/calc calc.sc -m512 --web true --docker 
msciab/actionloop-scala-v2.12

The runtime is also part of a "collection" of runtimes based on the ActionLoop 
(the engine of the GoLang runtime) and I want to show how to build a new 
runtime for any language with just 3 files: a "compiler" script, a launcher and 
a Dockerfile.

I already did the runtimes for Swift and Scala, and I have in mind many others 
(rust, haskell and kotlin  for example).



-- 
  Michele Sciabarra
  [email protected]

----- Original message -----
From: Carlos Santana <[email protected]>
To: "[email protected]" <[email protected]>
Subject: Tech Interchange call this Wed. Oct. 24 - add agenda topics here
Date: Mon, 22 Oct 2018 09:55:48 -0400

Hi Whiskers,

Please add to this thread any agenda items you'd like to present at the
Tech Interchange call this Wednesday (October 24).

Call details:

Web Meeting: Tech Interchange (bi-weekly):
- Day-Time: Wednesdays, 11AM EDT (Eastern US), 5PM CEST (Central Europe),
3PM UTC, 11PM CST (Beijing)
- Zoom: https://zoom.us/my/asfopenwhisk

Thanks,

--carlos

Reply via email to