Cloud Native Middleware as a Programming Language
September 2019
Lakmal Warusawithana, Senior Director - Developer Relations, WSO2
@lakwarus
(Almost)
Every programmer is
using and/or creating
APIs
Existing languages treat the
network as simply I/O
Ballerina treats APIs, listeners,
endpoints, network types as first
class entities
Ballerina is a modern, compiled, type safe,
concurrent programming language
Open Source implementations,
Apache Licensed
Open Specification,
Creative Commons Licensed
Hello World
Annotations
caller hello
POST (name)
Hello, name!
caller hello
POST (status)
response
twitter
tweet (status)
response
○ Built in taint analysis
○ Built in API Gateway (JWT and OAuth)
○ Research on embedding SPIFFE into the language
○ First-class integration with Istio / Envoy
More info here:
https://github.com/prabath/ballerina-security
Based on sequence diagrams
○ A type defined by union of two or more other types
float | string v1 = "John";
float | string v2 = 457.68;
float | string
0.51
1.01
457.68
-11.0
“John”
“name”
“”
“bal”
// The return type of 'post' is a union of 'http:Response' and 'error'
http:Response | error response = orderEP -> post("/create", reqPayload)
json is just a union - () | int | float | string | map<json> | json[]
// JSON object
json payload = { "orderdata": { "id": 1, "name": "XYZ", "price": 2500 } };
//Access object values
json orderid = payload.orderdata.id;
//JSON arrays
json orders = {
"orderdata": [
{ "id": 1, "name": "XYZ", "price": 2500 },
{ "id": 2, "name": "ABC", "price": 3000 }
]
};
// Simple XML literal
xml x1 = xml`<name>Lakmal Warusawithana</name>`;
// XML with namespaces
xmlns "http://wso2.com" as ns0;
xml x2 = xml `<name id="123" status="married">
<ns0:fname>Lakmal</ns0:fname>
<ns0:lname>Warusawithana</ns0:lname>
</name>`;
// XML literal with interpolation
string lastName = "Warusawithana";
xml x3 = xml`<lname>${lastName}</lname>`;
// Concat XML values
xml x4 = x1 + x2 + x3;
Cloud native
Concurrency
future<int> f = start add( 2,2);
if (f.isDone()) {
int result = wait f;
io:println(result);
}
else if (f.isCancelled())
{
io:println("cancelled");
}
else
{
io:print("cancelling: ");
io:println(f.cancel());
}
Batteries included
○ Test
○ Documentation
○ Swagger tooling
○ gRPC tooling
○ Secret encryption
○ Docker / Kubernetes integration
○ Istio integration
Serverless
Observability
Continuous Integration
gRPC and ProtoBuf
Ballerina syntax
Automatically creates this .proto
https://ballerina.io/learn/by-example/
https://github.com/ballerina-platform/ballerina-spec
○ Come to https://ballerina.io
○ Join the slack channel and/or ballerina-dev mailing list
○ Create a module and upload into Ballerina Central
○ Create issues
○ On the spec or implementation
○ If you have compiler skills, submit PRs on nBallerina or jBallerina
Homepage https://ballerina.io/
Downloads https://ballerina.io/downloads/
Ballerina By Example https://ballerina.io/learn/by-example/
Github https://github.com/ballerina-platform/ballerina-lang

[WSO2 Integration Summit New York 2019] Ballerina - Cloud Native Middleware as a Programming Language