Ballerina is a new programming language that is designed and optimized for integration. Ballerina revolutionized the way you model integration scenarios with its graphical and textual syntax which is built on top of the sequence diagram metaphor. It is fully container native and 100% open source technology.
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Ballerina- A programming language for the networked world
1. Chintana Wilamuna
Solutions Architect
April, 06 2017
A programming language for the networked world
Asanka Abeysinghe
Vice President, Solutions Architecture
Future of Enterprise Integration Meetup: Silicon Valley
2. The world is changing …
• Networked interactions are no longer a niche
– The new shared library
– Ability to reuse and recompose is key to agility
– Everything you write integrates with other things
• Configuration over code not workable at scale
• Containers, microservices, micro integrations
4. From data flows to sequence diagrams
• Every ESB technology based on dataflow
• Not very good at describing complex multi-party
interactions that are now common
• Sequence diagrams to the rescue
– Perfect for describing parallel, coordinated activities of many
parties
6. Why stop at using sequence diagrams to describe
programs?
7.
8. Ballerina
• General purpose programming language, but optimized for
integration
• Strongly typed, concurrent with both text and graphical
syntaxes
• Modern, network-aware, data-aware, security-aware
programming system inspired by Java, Go, Maven, ...
9. The Ballerina Language
• Graphical/textual parity with ability to switch back and forth
• Common integration capabilities are baked into the language:
– Deep HTTP/REST/Swagger alignment
– Connectors for Web APIs and non-HTTP APIs
– Support for JSON, XML, (No)SQL data and mapping
• No magic – no weird syntax exceptions, everything is derived
from a few key language concepts
• Maximize developer productivity and abstraction clarity
• Support high performance implementations: low latency, low
memory and fast startup
12. Ballerina knows services (and main)!
• Two models of programming: service and main
• Services are network invoked collections of entry points
• Main is regular main()
14. Ballerina knows data!
• XML, JSON and datatable are built-in data types
• All streamed, high performant
• Data (type) mapping between Ballerina types, XML, JSON and
datatables
15. Ballerina knows network APIs!
• Client and server connectors for HTTP 1.1/2, WebSockets, JMS,
(S)FTP(S) and more
• Client connectors for BasicAuth, OAuth, AmazonAuth, SOAP
• Client connectors for Web APIs: Twitter, GMail, LinkedIn,
Facebook, Lambda Functions, …
16. Ballerina knows (or rather, is) Swagger!
• Ballerina programs’ interface (in HTTP case) is
expressed in Swagger
– Text syntax, graphical syntax and Swagger syntax
are interchangeable
• Edit interface anywhere
• No more standard limitations of interface first design
17. Ballerina knows Docker!
• Built in build command to create Docker image with executable
Ballerina program package
• Run on any container management platform
18. Ballerina is highly extensible!
• Code organized into packages like Go
• Repository model similar to Maven/NPM/Go giving ability to
create ecosystem of connector contributors
• Recomposable network connectors
19. Ballerina is open source!
• Patent pending technology
• Implementation released under Apache License v2.0
– Fork me on GitHub: https://github.com/ballerinalang/
• Community
– Users: ballerina-user@googlegroups.com
– Slack: #ballerinalang
– Twitter: @ballerinalang
– StackOverflow: #ballerinalang
– Developers: ballerina-dev@googlegroups.com
22. Modularity: Files & Packages
• Package model inspired by Go
– package org.wso2.foo;
• Packages are defined by the set of all files in a directory
• All symbols exposed by any file in the package is referred to with
packagename:symbolname
– In other words, file names have no meaning in the namespace of the language
• To use symbols from a package you must import:
– import org.wso2.foo [as xx];
• Packages that start with ballerina.* and ballerinax.* are reserved
• Packages will be versioned - details later
24. JSON Support
• Variables of type “json” can hold any JSON value
• Optionally, can associate a JSON Schema to the
declaration:
– json[<json_schema_name>] jsdoc;
– Constraints the value to conform to the schema
• Useful for type mapping
• JSON literals can be used to initialize JSON typed variables
– json address_json = `{"name" : "$name", "streetName" : "${street}"}`;
25. XML Support
• Variables of type “xml” can hold any XML element
• Variables of type “xmldocument” can hold any XML
document
• Optionally can associate an XML Schema to constrain the
value space of XML
– xml[<{xsd_namespace_name}type_name}>] e;
• XML literals
– xmlElement address_xml = `<address><name>${name}</name></address>`;
26. Tabular Data Support
• Variables of type “datatable” can hold any tabular data
coming from a data source
• Database connectors to query and produce datatables
27. Type Coercion and Conversion
• Lossless type coercions are automatic
– E.g. int -> float
• Other type conversions can be invoked with the cast
operator
– TypeT1 v1;
– TypeT2 v2;
– v2 = (TypeT2) v1;
• Users can define their own type mappers which fit into the
language type system and get invoked with the cast
operator
34. Ballerina is not just the language
• Composer with debugging, type mapping
• IDE plugins
• Docerina
• Testerina
• (Coming soon) Packerina
35. Composer
• Textual, graphical and Swagger editing of Ballerina
programs
• Runs in the browser
– Currently not packaged with embedded Chromium;
considering it
• Will be hosted in the cloud as well
36. IDE Plugins
• Available (still WIP)
– Atom
– Vim
– Idea
– Sublime Text
– VSCode
– Adobe Brackets
• More to be done!
– Send a pull request ☺
37. Docerina
• Tool to generate API docs for your Ballerina code
• All Ballerina code is documented using Docerina
41. When should I use Ballerina?
• Write integration microservices
– 80-20 rule: if 80% of your service is about integrating with
other services, data and APIs then use Ballerina. If its just
20% then use Java / Node / Go / XYZ
• Re-compose existing services to be API backends
• Write integration scripts
– Replacement for shell scripts that use curl too much
44. Available now: Ballerina v0.85 Technology
Preview
• Language runtime
– Run once, run one service, run many services (bus)
• Developer tools
– Composer: browser based graphic/text/Swagger editor and
debugger
– IDE plugins: Idea, Atom, Vim, Sublime, VSCode, Brackets
– Testerina: Unit testing framework
– Docerina: API doc generation framework
• Connectors
46. Next Steps
• Download, twirl with it, give us feedback
• Engage with the community
– Users: ballerina-user@googlegroups.com
– Slack: #ballerinalang
– Twitter: @ballerinalang
– StackOverflow: #ballerinalang
– Developers: ballerina-dev@googlegroups.com
52. Ballerina Concepts: Client & Server Connectors
• Ballerina services are attached to network protocols with
server connectors
• Ballerina programs interact with network endpoints with
client connectors
– Networked endpoints can mean pretty much anything