VOOZH about

URL: https://thenewstack.io/why-should-you-program-with-ballerina/

⇱ Why Should You Program with Ballerina? - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2022-04-21 08:05:38
Why Should You Program with Ballerina?
contributed,sponsor-wso2,sponsored,sponsored-post-contributed,
Programming Languages / Software Development

Why Should You Program with Ballerina?

Cloud native open source language Ballerina provides the right level of abstraction for new APIs, new integrations and new logic for network interactions.
Apr 21st, 2022 8:05am by Vishva Ahangama
👁 Featued image for: Why Should You Program with Ballerina?
Image by Angelica Vaihel from Pixabay 
WSO2 sponsored this post.
The modern-day application, whether it’s a web or mobile app, typically has a frontend and a backend. There are many frontend application technologies out there, and the backend often consists of one or hundreds of APIs, depending on the complexity of the application.
Vishva Ahangama
Vishva is a senior lead marketing officer at WSO2, leading the planning and creation of content-driven experiences for its products. He holds a B.A. in English from Carleton University in Ottawa, Canada.
While it’s possible to write APIs in any programming language, developers face many challenges when creating new APIs and when working with those that exist already. Moreover, enterprise integration is still challenging. Integration programming practices have become siloed, and developers programming with their preferred integration tool must develop the rest of their applications with another tool or programming language. To add to this, the shift to the cloud means teams must now deploy integration systems in containers and create applications using microservices that are distributed across a wide number of nodes. Existing programming languages are not particularly adept at understanding these problems and what teams are trying to do. They simply were not built for the cloud. Ballerina, an open source language for cloud native programming and integration, gives the right set of tools and level of abstraction to developers focusing on creating new APIs, new integrations and new logic for network interactions. With its syntax for developing services and APIs, JSON support and built-in concurrency, the new general availability release Swan Lake can further simplify the way developers build and deploy cloud native apps. Here are the major reasons why developers should choose Ballerina to program their APIs, integrations and backend logic for their cloud native applications.

Ballerina Is Data and Network Oriented 

With more services in the cloud, almost every enterprise application involves a network call. For developers, this adds the responsibility of working with networked resources in their code. Ballerina comes with a network-friendly type system with powerful features to handle data on the wire. Ballerina makes it easy to model data and send it back and forth over the network. The language has powerful tools to write, declare, process, query, structure, restructure and navigate data.
importballerina/http;
importballerina/io;

typeCountryrecord {
 stringcountry;
 intpopulation;
 stringcontinent;
 intcases;
 intdeaths;

};

// Prints the top 10 countries having the highest case-fatality ratio.

publicfunctionmain() returnserror? {
 http:ClientdiseaseEp = checknew ("https://disease.sh/v3");
 Country[] countries = checkdiseaseEp->get("/covid-19/countries");

 jsonsummary =
 fromvar {country, continent, population, cases, deaths} incountries
 wherepopulation >= 100000 && deaths >= 100
 letdecimalcaseFatalityRatio = <decimal>deaths / <decimal>cases *
100

 orderbycaseFatalityRatiodescending
 limit10
 select {country, continent, population, caseFatalityRatio};
 io:println(summary);

}

With the Power of a Flexible Type System

A programming language’s type system is the foundation for representing data and implementing logic. While the developer must work with networked resources in their code, the programming language itself must aid in this operation. That’s why Ballerina’s network-friendly type system is specialized for this domain. For example, in typical programming languages, there are standards and protocols to define how to work with data that comes over the wire and bind it to the language (data binding). When data is received, a developer must bind it to a data structure in the language in order to manipulate it. Ballerina’s type system is capable of describing not just data in memory, but also data on the wire. In particular, a lot of work has been done to align closely with JSON, XML and other formats. When data comes over the wire, a developer can bring it into the language without any artificial, complicated data binding concern, effectively eliminating the data-binding concept from well-known data formats and network data structures. Ballerina’s type system is primarily structural with added support for nominal typing. This means that type compatibility is identified by considering the structure of the value rather than just relying on the type name. This is different from languages like Java, C++ and C# that have nominal type systems in which it is bound by the name of the actual type.
Founded in 2005, WSO2 enables the composable enterprise. Our open source, API-first, and decentralized approach helps developers and architects to be more productive and rapidly build digital products to meet demand.
Learn More
The latest from WSO2

Sequence Diagrams Model Network Interactions

In Ballerina, every program can be shown as a sequence diagram that illustrates distributed and concurrent interactions automatically. A function in a Ballerina program has equivalent representations both in textual syntax and as a sequence diagram. You can switch between the two views seamlessly. Ballerina’s unique graphical view isn’t something that was tacked on as a gimmick. It’s been designed deeply into the language to provide real insight into a function’s network interactions and its use of concurrency.
importballerina/http;
importballerinax/googleapis.sheets;

configurablestringgithubPAT = ?;
configurablestringrepository = "ballerina-platform/ballerina-lang";
configurablestringsheetsAccessToken = ?;
configurablestringspreadSheetId = ?;
configurablestringsheetName = "Sheet1";

typePRrecord {
 stringurl;
 stringtitle;
 stringstate;
 stringcreated_at;
 stringupdated_at;
};

publicfunctionmain() returnserror? {
 http:Clientgithub = checknew ("https://api.github.com/repos");
 map<string> headers = {
 "Accept": "application/vnd.github.v3+json",
 "Authorization": "token " + githubPAT
};

PR[] prs = checkgithub->get(string`/${repository}/pulls`, headers);

sheets:Clientgsheets = checknew ({auth: {token: sheetsAccessToken}});
checkgsheets->appendRowToSheet(spreadSheetId, sheetName,
 ["Issue", "Title", "State", "Created At", "Updated At"]);

foreach var {url, title, state, created_at, updated_at} inprs {
 checkgsheets->appendRowToSheet(spreadSheetId, sheetName,
 [url, title, state, created_at, updated_at]);
}
}
👁 Image
While Ballerina has all the general-purpose functionality of a modern programming language, it stands out because it provides language features that make it easier to use, combine and create network services for the cloud. For an in-depth introductory explanation on the language features of Ballerina, we encourage you to watch the video below by Sanjiva Weerawarana, the language’s creator. You can also check out this blog. Ballerina Swan Lake is available now. As an open source implementation released under the Apache License 2.0, it does not carry any licensing fees and can be freely downloaded at https://ballerina.io/downloads.
Founded in 2005, WSO2 enables the composable enterprise. Our open source, API-first, and decentralized approach helps developers and architects to be more productive and rapidly build digital products to meet demand.
Learn More
The latest from WSO2
TRENDING STORIES
Vishva is a senior lead marketing officer at WSO2, leading the planning and creation of content-driven experiences for its products. He holds a B.A. in English from Carleton University in Ottawa, Canada.
Read more from Vishva Ahangama
WSO2 sponsored this post.
SHARE THIS STORY
TRENDING STORIES
TNS owner Insight Partners is an investor in: Pragma.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.