SlideShare une entreprise Scribd logo
1  sur  51
Ballerina: A modern programming
language focused on integration
Sanjiva Weerawarana, Ph.D.
Lead Ballerina
Founder & Chairman, WSO2
Overview
• Motivation
• Key differences
• Type system
• Errors
• Concurrency
• Networking
• And more
• Beyond the language
• Standard library, developer tools, testing, documentation, observability
Motivation: Why yet another language?
• Digital transformation
• Everything is a network service
• Produce, not just consume network services
• Minimalization of computing
• Hardware: Bare metal  VMs  Containers  Serverless
• Application architecture: SOA  Microservices  Functions
• Integration: ESB  Service meshes
• Middleware is dead; middleware is everywhere
• Servers  sidecars  code
New language
• Most widely used languages fall into one of the two ends of the spectrum
• Too rigid: Statically but nominally typed, often object oriented like Java, C#, Go
• Too flexible: Dynamic languages with little or no static typing like Python,
Javascript (but improved with Typescript), PHP
• Focus is not on the problems that are clear and present today
• Ballerina sits in the middle with
• Structural, mostly static strong typing
• Blend of functional, imperative and object orientation
• Strong focus on data oriented programming, network awareness
• Concurrency made simple for normal programmers
Design inspirations
• Sequence diagrams the core conceptual model for programming
• Many existing languages, including Java, Go, C, C++, Rust, Kotlin, Dart,
Typescript, Javascript, Flow, Swift, RelaxNG, Midori, DLang and more
Design principles
• Code with equivalent both text and graphic syntaxes
• Embrace the network with network friendly data types, resiliency and
syntax
• Make programs secure by default
• Little room for best practices or “findbugs”
• No dogmatic programming paradigm
• Familiarity, where appropriate
• Easy for non-rocket scientist programmers
• Mainstream concepts & abstractions, not research
Status
• Core language design getting closer to being done
• What I am explaining today is a mixture of what is available for download and
what is pending implementation
• Core language is stable but a few more breaking changes are coming 
• Implementation
• Core language
• Stdlib
• Tools
• Team
• 50+ engineers for last 2+ years with higher bursts
Hello, World main
% ballerina run hello.bal KubeCon
Hello, World main
Hello, World service
$ ballerina run helloservice.bal
Initiating service(s) in 'helloservice.bal'
[ballerina/http] started HTTP/WS endpoint 0.0.0.0:9090
Type system
Universe of values
• Simple
• (), boolean, int, float, decimal, string
• Structured: create new values from simple values
• Lists (arrays & tuples), mappings (maps & records), tables, xml and errors
• Behavioral: bits of Ballerina programs as values
• Functions, futures, objects, services and typedesc
• Streams(*), channels(*)
Values and storage
• Some values are stored only conceptually
• E.g. 3.1415 is a float value that doesn’t have a material “storage” location
• Simple values are always immutable
• Certain values are stored somewhere and that location is how you
identify the value
• Reference values
• All structured values and behavioral values
Types and type descriptors
• Types are names for type descriptors
• Type descriptors describe a set of value that belong to that type
• Do not add new values to universe
• Membership
• Given value can be in any number of sets, therefore have any number
of types
Types and shapes
• Values have a storage location (thereby another identity) and are
sometimes mutable
• Types only worry about ”shape” of a value
• Different basic types have different shapes
• Ignores storage location and mutability
• Only difference for reference values, not for simple values (as no storage)
• Type = set of shapes
• Subtype = subset
Types, values & shapes
• Value “looks like a type” at a particular point of execution if its shape
is in the type
• Value “belongs to a type” if it ”looks like a type” and no mutation can
change its shape so it no longer belongs to the type
Other type descriptors
• Singleton
• Union
• Optional
• any
• anydata
• byte
• json
any
• Describes type consisting of all values except error values
• Thus, any|error is a type descriptor for all values
anydata
• Type of all pure values other than errors
• Equal to:
• () | boolean | int | float | decimal | string | (anydata|error)[] |
map<anydata|error> | xml | table
• Used for message passing
byte
• Union of 0 | 1 | .. | 255
json
• Union of
• string | boolean | int | float | decimal | map<json> | json[] | ()
Errors
Error handling
• Different languages have different approaches
• Great blog by Joe Duffy on Midori error handling
• Two kinds of errors
• Abnormal errors (bugs)
• Normal errors
Abnormal vs. normal errors
• Abnormal errors
• Should not normally happen
• Little the programmer can do about them
• Normal errors
• Statically typed
• Explicit control flow
• Normal errors cannot implicitly become abnormal and vice-versa
panic/trap for abnormal errors
• Less convenient form than try-throw-catch
• Abnormal errors are not for people to play with!
• All other errors must be statically declared, even in concurrent
interactions
• Programmer must be aware and must handle
• Not allowed to ignore error returns with union typing
Concurrency
Making concurrency natural
• Most programming languages have made concurrency special
• Everything starts with one thing and then becomes concurrent
• Every executable unit (function, method, resource) is always
concurrent
• Collection of workers
• Sequence diagram with concurrent actors!
• Worker to worker communication allows coordination
Non-blocking runtime
• Ballerina does not rely on callbacks for high performance or scale
• User merrily programs as if they hold execution until delaying action
(I/O etc.) completes
• Runtime scheduler manages scheduling of ready to run strands to
threads
Strands
• Started by a worker or by starting a function call asynchronously
• “strand of workers”
• Gets scheduled to a thread for execution
• Represents a standard call stack
• Every named worker starts a new strand
• Represented by a future which can be used to get return value of
initial worker
Futures
• Futures represent strands
• Type is the return type of the worker running in the strand, including
any errors
• A named worker defines a variable of type future<T> where T is the
return type of the worker.
• Futures are first-class- so can be passed as parameters etc.
Communicating between workers
• Complex interactions allowed only when workers defined lexically
together
• Deadlock avoidance requires this
• Looking into session types to possibly strengthen this
• Values of type anydata|error can be communicated via cloning over
anonymous channels
• Errors (including panics) can propagate across workers
• Blocking & unblocking variants for send
Concurrency safety
• Use immutable data when possible
• Lock construct for explicit locking
• Implements two-phase locking
• Important: physical concurrency in business use cases is limited
• High concurrent users is the common scenario
• More work TBD for this area
• Uniqueness typing (Swift), Ownership types (Rust), STM, ..
• Ideal goal is Ballerina code will not fail with race conditions under load
Networking
Language abstractions
• BSD sockets
• Network communication is not just a byte stream!
• Messages, protocols, interaction patterns
• Endpoints are network termination points
• Inbound or ingress
• Outbound or egress
• Ballerina models these via Listeners, Clients and Services
Graphical representation
• Endpoints are represented as actors in the sequence diagram
• Usually Ingress endpoint on left, egress endpoints on right of workers
• Any network interaction shows up as a line to/from a worker to an
actor representing endpoint
Clients
• Clients are abstraction for egress endpoints
• Defined by an object with “remote” methods
• Methods with a “remote” qualifier
• Syntax:
• Text: var result = client->actionName (args);
• Graphically: line from worker to client
Outbound reliability & resiliency
• Fallacy of distributed computing: network is reliable
• Ballerina comes with library of tools to manage
• Load balancing
• Failover
• ..
• Implemented as libraries that layer on underlying clients
Listeners and services
• Listeners are responsible for establishing network ports (or other
concepts) and managing a set of services that are attached to them
• Listeners are objects that implement system interface
• Module listeners
• Listeners attached to module lifecycle
• Makes services equal citizens as main()
Services
• Collection of handlers for inbound requests
• Resource functions
• Listener responsible for dispatching requests to correct service and
resource
• Services are like singleton objects and are first class values
Service typing
• Listener to service relationship can be complex
• One listener can manage multiple service types, one service type can be
attached to different kinds of listeners
• Current service typing is done by extensions (annotations)
• WIP to improve
And more …
Yeah there’s a few more things ..
• Integrated LINQ-like query for table values
• Streaming query and stream processing
• Security abstractions for secure services and network data
• Distributed transactions, both ACID and compensating
• Long running execution support with checkpointing
• Language extensibility with environment binding and compilation
extensibility
Beyond the language
“Batteries included” standard library
• ballerina/auth
• ballerina/cache
• ballerina/config
• ballerina/crypto
• ballerina/file
• ballerina/grpc
• ballerina/h2
• ballerina/http
• ballerina/internal
• ballerina/io
• ballerina/jdbc
• ballerina/jms
• ballerina/log
• ballerina/math
• ballerina/mb
• ballerina/mime
• ballerina/mysql
• ballerina/reflect
• ballerina/runtime
• ballerina/sql
• ballerina/swagger
• ballerina/system
• ballerina/task
• ballerina/test
• ballerina/time
• ballerina/transactions
• ballerina/websub
Beyond code
• Editing & debugging
• VSCode and IntelliJ plugins
• Testing framework
• Observability: metrics, tracing, logging
• Documentation generation
• Modularity, dependencies, versions, building & sharing
Implementation
• Compilation process
• Mid level intermediate representation (BVM bytecodes) into library (.balo) as portable object
format
• Link & execute via multiple paths
• Link and execute in Java based interpreter (available now)
• Native binary via LLVM (in progress)
• WebASM, Android, embedded devices, MicroVM as future targets
• Bootstrapping compiler into Ballerina in (slow) progress
• Extensible architecture for compiler to allow 3rd party annotation processing to become
part of compilation process, e.g. Docker/K8s
• IDEs supported via Language Server Protocol
• Plugins for VS Code, IntelliJ and standalone browser-based Composer
Compiler architecture
Conclusion
Ongoing work
• Concurrency safety
• Immutable types, STM, uniqueness types, ownership types
• Communication safety
• session types
• Workflow related
• Forward recoverability via checkpoint/restart
• Compensation
• Parametric typing
• Internationalizing the grammar
Timing
• Few more breaking changes expected but not anywhere as dramatic as
0.970, 0.980 or 0.990
• Thank you for your patience!
• Moving some features to ”Experimental” category for 1.0 timeframe
• 1.0 is expected by Summer(-ish) 2019
• Pretty much 3 years since birth
• Full native compilation of 1.0 will take longer
Summary
• Ballerina is building a modern industrial grade programming language
• For future with lots of network endpoints
• Type system is designed to make network data processing easier
• First class network services along with functions/objects
• Framework to encourage more secure code
• Fully open source and developed openly

Contenu connexe

Tendances

Writing DSL's in Scala
Writing DSL's in ScalaWriting DSL's in Scala
Writing DSL's in Scala
Abhijit Sharma
 
Programming Languages #devcon2013
Programming Languages #devcon2013Programming Languages #devcon2013
Programming Languages #devcon2013
Iván Montes
 
.Net overviewrajnish
.Net overviewrajnish.Net overviewrajnish
.Net overviewrajnish
Rajnish Kalla
 
Week 8 intro to python
Week 8   intro to pythonWeek 8   intro to python
Week 8 intro to python
brianjihoonlee
 
Multilingual Content: Presentation from DrupalCamp Montreal 2012
Multilingual Content: Presentation from DrupalCamp Montreal 2012Multilingual Content: Presentation from DrupalCamp Montreal 2012
Multilingual Content: Presentation from DrupalCamp Montreal 2012
Suzanne Dergacheva
 

Tendances (20)

Using Scala for building DSLs
Using Scala for building DSLsUsing Scala for building DSLs
Using Scala for building DSLs
 
Writing DSL's in Scala
Writing DSL's in ScalaWriting DSL's in Scala
Writing DSL's in Scala
 
Programming Languages #devcon2013
Programming Languages #devcon2013Programming Languages #devcon2013
Programming Languages #devcon2013
 
7 expressions and assignment statements
7 expressions and assignment statements7 expressions and assignment statements
7 expressions and assignment statements
 
What's the "right" PHP Framework?
What's the "right" PHP Framework?What's the "right" PHP Framework?
What's the "right" PHP Framework?
 
.Net overviewrajnish
.Net overviewrajnish.Net overviewrajnish
.Net overviewrajnish
 
CH # 1 preliminaries
CH # 1 preliminariesCH # 1 preliminaries
CH # 1 preliminaries
 
6 data types
6 data types6 data types
6 data types
 
Reading Notes : the practice of programming
Reading Notes : the practice of programmingReading Notes : the practice of programming
Reading Notes : the practice of programming
 
Python's dynamic nature (rough slides, November 2004)
Python's dynamic nature (rough slides, November 2004)Python's dynamic nature (rough slides, November 2004)
Python's dynamic nature (rough slides, November 2004)
 
Scala-Ls1
Scala-Ls1Scala-Ls1
Scala-Ls1
 
Multilingual Site Building with Drupal 7 at Drupal Camp NYC 10
Multilingual Site Building with Drupal 7 at Drupal Camp NYC 10Multilingual Site Building with Drupal 7 at Drupal Camp NYC 10
Multilingual Site Building with Drupal 7 at Drupal Camp NYC 10
 
Programming language paradigms
Programming language paradigmsProgramming language paradigms
Programming language paradigms
 
Week 8 intro to python
Week 8   intro to pythonWeek 8   intro to python
Week 8 intro to python
 
Multilingual Content: Presentation from DrupalCamp Montreal 2012
Multilingual Content: Presentation from DrupalCamp Montreal 2012Multilingual Content: Presentation from DrupalCamp Montreal 2012
Multilingual Content: Presentation from DrupalCamp Montreal 2012
 
object oriented programming examples
object oriented programming examplesobject oriented programming examples
object oriented programming examples
 
Persistent Data Structures And Managed References
Persistent Data Structures And Managed ReferencesPersistent Data Structures And Managed References
Persistent Data Structures And Managed References
 
Preparing for Scala 3
Preparing for Scala 3Preparing for Scala 3
Preparing for Scala 3
 
Ch6
Ch6Ch6
Ch6
 
CISSP Prep: Ch 9. Software Development Security
CISSP Prep: Ch 9. Software Development SecurityCISSP Prep: Ch 9. Software Development Security
CISSP Prep: Ch 9. Software Development Security
 

Similaire à 2018 12-kube con-ballerinacon

CSP: Huh? And Components
CSP: Huh? And ComponentsCSP: Huh? And Components
CSP: Huh? And Components
Daniel Fagnan
 
FPL - Part 1 (Sem - I 2013 )
FPL - Part 1  (Sem - I  2013 ) FPL - Part 1  (Sem - I  2013 )
FPL - Part 1 (Sem - I 2013 )
Yogesh Deshpande
 

Similaire à 2018 12-kube con-ballerinacon (20)

David buksbaum a-briefintroductiontocsharp
David buksbaum a-briefintroductiontocsharpDavid buksbaum a-briefintroductiontocsharp
David buksbaum a-briefintroductiontocsharp
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development Security
 
CPP19 - Revision
CPP19 - RevisionCPP19 - Revision
CPP19 - Revision
 
Introduction
IntroductionIntroduction
Introduction
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development Security
 
Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#
 
Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#
 
c++
 c++  c++
c++
 
ICONUK 2018 - Do You Wanna Build a Chatbot
ICONUK 2018 - Do You Wanna Build a ChatbotICONUK 2018 - Do You Wanna Build a Chatbot
ICONUK 2018 - Do You Wanna Build a Chatbot
 
Voldemort Nosql
Voldemort NosqlVoldemort Nosql
Voldemort Nosql
 
CSP: Huh? And Components
CSP: Huh? And ComponentsCSP: Huh? And Components
CSP: Huh? And Components
 
Open Source SQL Databases
Open Source SQL DatabasesOpen Source SQL Databases
Open Source SQL Databases
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!
 
Unit 2 computer software
Unit 2 computer softwareUnit 2 computer software
Unit 2 computer software
 
FPL - Part 1 (Sem - I 2013 )
FPL - Part 1  (Sem - I  2013 ) FPL - Part 1  (Sem - I  2013 )
FPL - Part 1 (Sem - I 2013 )
 
Code Inspection
Code InspectionCode Inspection
Code Inspection
 
Class_X_PYTHON_J.pdf
Class_X_PYTHON_J.pdfClass_X_PYTHON_J.pdf
Class_X_PYTHON_J.pdf
 
Julia Computing - an alternative to Hadoop
Julia Computing - an alternative to HadoopJulia Computing - an alternative to Hadoop
Julia Computing - an alternative to Hadoop
 

Plus de Sanjiva Weerawarana

Plus de Sanjiva Weerawarana (10)

Free & Open Source Software and Intellectual Property
Free & Open Source Software and Intellectual PropertyFree & Open Source Software and Intellectual Property
Free & Open Source Software and Intellectual Property
 
2013-03-JavaColomboMeetup.pptx
2013-03-JavaColomboMeetup.pptx2013-03-JavaColomboMeetup.pptx
2013-03-JavaColomboMeetup.pptx
 
2018 07-ballerina-ballerina con
2018 07-ballerina-ballerina con2018 07-ballerina-ballerina con
2018 07-ballerina-ballerina con
 
2016 07-28-disrupt asia
2016 07-28-disrupt asia2016 07-28-disrupt asia
2016 07-28-disrupt asia
 
2018 05-sri-lanka-first-harvard
2018 05-sri-lanka-first-harvard2018 05-sri-lanka-first-harvard
2018 05-sri-lanka-first-harvard
 
2017 09-07-ray-wijewardene
2017 09-07-ray-wijewardene2017 09-07-ray-wijewardene
2017 09-07-ray-wijewardene
 
Wso2 Cloud Public 2009 11 16
Wso2 Cloud Public 2009 11 16Wso2 Cloud Public 2009 11 16
Wso2 Cloud Public 2009 11 16
 
State Of Services
State Of ServicesState Of Services
State Of Services
 
Service Oriented Architecture for Net Centric Operations based on Open Source...
Service Oriented Architecture for Net Centric Operations based on Open Source...Service Oriented Architecture for Net Centric Operations based on Open Source...
Service Oriented Architecture for Net Centric Operations based on Open Source...
 
Convergence in Enterprise IT ... the renaissance period
Convergence in Enterprise IT ... the renaissance periodConvergence in Enterprise IT ... the renaissance period
Convergence in Enterprise IT ... the renaissance period
 

Dernier

CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
anilsa9823
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
 

Dernier (20)

Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 

2018 12-kube con-ballerinacon

  • 1. Ballerina: A modern programming language focused on integration Sanjiva Weerawarana, Ph.D. Lead Ballerina Founder & Chairman, WSO2
  • 2. Overview • Motivation • Key differences • Type system • Errors • Concurrency • Networking • And more • Beyond the language • Standard library, developer tools, testing, documentation, observability
  • 3. Motivation: Why yet another language? • Digital transformation • Everything is a network service • Produce, not just consume network services • Minimalization of computing • Hardware: Bare metal  VMs  Containers  Serverless • Application architecture: SOA  Microservices  Functions • Integration: ESB  Service meshes • Middleware is dead; middleware is everywhere • Servers  sidecars  code
  • 4. New language • Most widely used languages fall into one of the two ends of the spectrum • Too rigid: Statically but nominally typed, often object oriented like Java, C#, Go • Too flexible: Dynamic languages with little or no static typing like Python, Javascript (but improved with Typescript), PHP • Focus is not on the problems that are clear and present today • Ballerina sits in the middle with • Structural, mostly static strong typing • Blend of functional, imperative and object orientation • Strong focus on data oriented programming, network awareness • Concurrency made simple for normal programmers
  • 5. Design inspirations • Sequence diagrams the core conceptual model for programming • Many existing languages, including Java, Go, C, C++, Rust, Kotlin, Dart, Typescript, Javascript, Flow, Swift, RelaxNG, Midori, DLang and more
  • 6. Design principles • Code with equivalent both text and graphic syntaxes • Embrace the network with network friendly data types, resiliency and syntax • Make programs secure by default • Little room for best practices or “findbugs” • No dogmatic programming paradigm • Familiarity, where appropriate • Easy for non-rocket scientist programmers • Mainstream concepts & abstractions, not research
  • 7. Status • Core language design getting closer to being done • What I am explaining today is a mixture of what is available for download and what is pending implementation • Core language is stable but a few more breaking changes are coming  • Implementation • Core language • Stdlib • Tools • Team • 50+ engineers for last 2+ years with higher bursts
  • 8. Hello, World main % ballerina run hello.bal KubeCon
  • 10. Hello, World service $ ballerina run helloservice.bal Initiating service(s) in 'helloservice.bal' [ballerina/http] started HTTP/WS endpoint 0.0.0.0:9090
  • 12. Universe of values • Simple • (), boolean, int, float, decimal, string • Structured: create new values from simple values • Lists (arrays & tuples), mappings (maps & records), tables, xml and errors • Behavioral: bits of Ballerina programs as values • Functions, futures, objects, services and typedesc • Streams(*), channels(*)
  • 13. Values and storage • Some values are stored only conceptually • E.g. 3.1415 is a float value that doesn’t have a material “storage” location • Simple values are always immutable • Certain values are stored somewhere and that location is how you identify the value • Reference values • All structured values and behavioral values
  • 14. Types and type descriptors • Types are names for type descriptors • Type descriptors describe a set of value that belong to that type • Do not add new values to universe • Membership • Given value can be in any number of sets, therefore have any number of types
  • 15. Types and shapes • Values have a storage location (thereby another identity) and are sometimes mutable • Types only worry about ”shape” of a value • Different basic types have different shapes • Ignores storage location and mutability • Only difference for reference values, not for simple values (as no storage) • Type = set of shapes • Subtype = subset
  • 16. Types, values & shapes • Value “looks like a type” at a particular point of execution if its shape is in the type • Value “belongs to a type” if it ”looks like a type” and no mutation can change its shape so it no longer belongs to the type
  • 17. Other type descriptors • Singleton • Union • Optional • any • anydata • byte • json
  • 18. any • Describes type consisting of all values except error values • Thus, any|error is a type descriptor for all values
  • 19. anydata • Type of all pure values other than errors • Equal to: • () | boolean | int | float | decimal | string | (anydata|error)[] | map<anydata|error> | xml | table • Used for message passing
  • 20. byte • Union of 0 | 1 | .. | 255
  • 21. json • Union of • string | boolean | int | float | decimal | map<json> | json[] | ()
  • 23. Error handling • Different languages have different approaches • Great blog by Joe Duffy on Midori error handling • Two kinds of errors • Abnormal errors (bugs) • Normal errors
  • 24. Abnormal vs. normal errors • Abnormal errors • Should not normally happen • Little the programmer can do about them • Normal errors • Statically typed • Explicit control flow • Normal errors cannot implicitly become abnormal and vice-versa
  • 25. panic/trap for abnormal errors • Less convenient form than try-throw-catch • Abnormal errors are not for people to play with! • All other errors must be statically declared, even in concurrent interactions • Programmer must be aware and must handle • Not allowed to ignore error returns with union typing
  • 27. Making concurrency natural • Most programming languages have made concurrency special • Everything starts with one thing and then becomes concurrent • Every executable unit (function, method, resource) is always concurrent • Collection of workers • Sequence diagram with concurrent actors! • Worker to worker communication allows coordination
  • 28. Non-blocking runtime • Ballerina does not rely on callbacks for high performance or scale • User merrily programs as if they hold execution until delaying action (I/O etc.) completes • Runtime scheduler manages scheduling of ready to run strands to threads
  • 29. Strands • Started by a worker or by starting a function call asynchronously • “strand of workers” • Gets scheduled to a thread for execution • Represents a standard call stack • Every named worker starts a new strand • Represented by a future which can be used to get return value of initial worker
  • 30. Futures • Futures represent strands • Type is the return type of the worker running in the strand, including any errors • A named worker defines a variable of type future<T> where T is the return type of the worker. • Futures are first-class- so can be passed as parameters etc.
  • 31. Communicating between workers • Complex interactions allowed only when workers defined lexically together • Deadlock avoidance requires this • Looking into session types to possibly strengthen this • Values of type anydata|error can be communicated via cloning over anonymous channels • Errors (including panics) can propagate across workers • Blocking & unblocking variants for send
  • 32. Concurrency safety • Use immutable data when possible • Lock construct for explicit locking • Implements two-phase locking • Important: physical concurrency in business use cases is limited • High concurrent users is the common scenario • More work TBD for this area • Uniqueness typing (Swift), Ownership types (Rust), STM, .. • Ideal goal is Ballerina code will not fail with race conditions under load
  • 34. Language abstractions • BSD sockets • Network communication is not just a byte stream! • Messages, protocols, interaction patterns • Endpoints are network termination points • Inbound or ingress • Outbound or egress • Ballerina models these via Listeners, Clients and Services
  • 35. Graphical representation • Endpoints are represented as actors in the sequence diagram • Usually Ingress endpoint on left, egress endpoints on right of workers • Any network interaction shows up as a line to/from a worker to an actor representing endpoint
  • 36. Clients • Clients are abstraction for egress endpoints • Defined by an object with “remote” methods • Methods with a “remote” qualifier • Syntax: • Text: var result = client->actionName (args); • Graphically: line from worker to client
  • 37. Outbound reliability & resiliency • Fallacy of distributed computing: network is reliable • Ballerina comes with library of tools to manage • Load balancing • Failover • .. • Implemented as libraries that layer on underlying clients
  • 38. Listeners and services • Listeners are responsible for establishing network ports (or other concepts) and managing a set of services that are attached to them • Listeners are objects that implement system interface • Module listeners • Listeners attached to module lifecycle • Makes services equal citizens as main()
  • 39. Services • Collection of handlers for inbound requests • Resource functions • Listener responsible for dispatching requests to correct service and resource • Services are like singleton objects and are first class values
  • 40. Service typing • Listener to service relationship can be complex • One listener can manage multiple service types, one service type can be attached to different kinds of listeners • Current service typing is done by extensions (annotations) • WIP to improve
  • 42. Yeah there’s a few more things .. • Integrated LINQ-like query for table values • Streaming query and stream processing • Security abstractions for secure services and network data • Distributed transactions, both ACID and compensating • Long running execution support with checkpointing • Language extensibility with environment binding and compilation extensibility
  • 44. “Batteries included” standard library • ballerina/auth • ballerina/cache • ballerina/config • ballerina/crypto • ballerina/file • ballerina/grpc • ballerina/h2 • ballerina/http • ballerina/internal • ballerina/io • ballerina/jdbc • ballerina/jms • ballerina/log • ballerina/math • ballerina/mb • ballerina/mime • ballerina/mysql • ballerina/reflect • ballerina/runtime • ballerina/sql • ballerina/swagger • ballerina/system • ballerina/task • ballerina/test • ballerina/time • ballerina/transactions • ballerina/websub
  • 45. Beyond code • Editing & debugging • VSCode and IntelliJ plugins • Testing framework • Observability: metrics, tracing, logging • Documentation generation • Modularity, dependencies, versions, building & sharing
  • 46. Implementation • Compilation process • Mid level intermediate representation (BVM bytecodes) into library (.balo) as portable object format • Link & execute via multiple paths • Link and execute in Java based interpreter (available now) • Native binary via LLVM (in progress) • WebASM, Android, embedded devices, MicroVM as future targets • Bootstrapping compiler into Ballerina in (slow) progress • Extensible architecture for compiler to allow 3rd party annotation processing to become part of compilation process, e.g. Docker/K8s • IDEs supported via Language Server Protocol • Plugins for VS Code, IntelliJ and standalone browser-based Composer
  • 49. Ongoing work • Concurrency safety • Immutable types, STM, uniqueness types, ownership types • Communication safety • session types • Workflow related • Forward recoverability via checkpoint/restart • Compensation • Parametric typing • Internationalizing the grammar
  • 50. Timing • Few more breaking changes expected but not anywhere as dramatic as 0.970, 0.980 or 0.990 • Thank you for your patience! • Moving some features to ”Experimental” category for 1.0 timeframe • 1.0 is expected by Summer(-ish) 2019 • Pretty much 3 years since birth • Full native compilation of 1.0 will take longer
  • 51. Summary • Ballerina is building a modern industrial grade programming language • For future with lots of network endpoints • Type system is designed to make network data processing easier • First class network services along with functions/objects • Framework to encourage more secure code • Fully open source and developed openly