Content deleted Content added
→Examples: fix syntaxhighlight errors |
m Grammar |
||
(33 intermediate revisions by 23 users not shown) | |||
Line 1:
{{Short description|Programming language}}
{{Infobox programming language
| name = Ballerina
| logo =
| designer = [[Sanjiva Weerawarana]], [[James Clark (programmer)|James Clark]], Sameera Jayasoma, Hasitha Aravinda, Srinath Perera, [[Frank Leymann]] and [[WSO2]]<ref>{{cite web |url=https://ballerina.io/spec/lang/master/ |publisher=WSO2 |title=Ballerina Language Specification |access-date=2020-04-24 |archive-date=2020-08-11 |archive-url=https://web.archive.org/web/20200811095205/https://ballerina.io/spec/lang/master/ |url-status=dead}}</ref>▼
▲| logo_alt = Ballerina Language
▲| designer = [[Sanjiva Weerawarana]], [[James Clark (programmer)|James Clark]], Sameera Jayasoma, Hasitha Aravinda, Srinath Perera, [[Frank Leymann]] and [[WSO2]]<ref>{{cite web|url=https://ballerina.io/spec/ |publisher=WSO2 |title=Ballerina Language Specification}}</ref>
| developer = [[WSO2]]
| released = {{Start date and age|2019|09|10}}
| typing = [[structural typing|Structural]], [[strong typing|strong]], [[static typing|static]], [[type inference|inferred]]▼
| latest release version = 2201.12.3 (Swan Lake Update 12)
| influenced_by = [[Java (programming language)|Java]], [[Javascript (programming language)|Javascript]], [[Go (programming language)|Go]], [[Rust (programming language)|Rust]], [[C Sharp (programming language)|C#<ref>{{cite journal |title=Ballerina, A modern programming language focused on integration |pages=15 |url=https://opensource.ellak.gr/wp-content/uploads/sites/5/2018/06/2018-06-Ballerina-GFOSS.pdf}}</ref>]]▼
| latest release date = {{Start date and age|2025|04|10}}
| programming language =Java, Ballerina, TypeScript <ref name="sourcecode" />▼
▲| typing = [[
| platform = ▼
▲|
▲| programming language = [[Java (programming language)|Java]], Ballerina, [[TypeScript
| license = [[Apache License]] 2.0<ref name="license">{{cite web▼
▲| platform = [[x86-64]]
| url = https://github.com/ballerina-platform/ballerina-lang/blob/master/LICENSE▼
| operating system = [[Cross-platform software|Cross-platform]]: [[Microsoft Windows|Windows]], [[Linux]], [[macOS]]
| title = WSO2 / LICENSE▼
▲| license = [[Apache License|Apache]] 2.0<ref name="license">{{cite web
| date = 2017-03-08 | access-date = 2018-03-01▼
| website = github.com | publisher = [[WSO2]]▼
}}</ref>
| website = {{URL|
}}
'''Ballerina''' is a general-purpose [[programming language]] designed by [[WSO2]] for cloud-era application [[programmers]].<ref name="sourcecode">{{cite web |url=https://github.com/ballerina-platform/ballerina-lang |title=Ballerina source code |author=((Open Source Contributors)) |date=18 June 2019 |publisher=[[GitHub]]}}</ref> It is [[free and open-source software]] released under [[Apache License]] 2.
It has various constructs geared toward cloud-native development including support for
== History ==
== Design ==
The designers, who provided [[enterprise integration]] products for over 10 years, used their knowledge of the industry when designing the language,<ref>{{Cite news|url=https://blog.jclark.com/2019/09/ballerina-programming-language-part-0.html|title=Ballerina Programming Language Part 0 - Context|last=Clark|first=James|access-date=2020-09-16|language=en-GB}}</ref><ref>{{Cite news|url=https://blog.jclark.com/2019/09/ballerina-programming-language-part-1.html|title=Ballerina Programming Language Part 1 - Concepts|last=Clark|first=James|access-date=2020-09-16|language=en-GB}}</ref> says WSO2 director and Ballerina founder James Clark.
== Examples ==
Line 60 ⟶ 56:
The service version of the Hello World program:
<syntaxhighlight lang="
import ballerina/http;
Line 77 ⟶ 73:
</syntaxhighlight>
<ref name="example1">{{cite web |url=https://ballerina.io/learn/by-example/hello-world-service.html |title=
=== REST API ===
<syntaxhighlight lang="
import ballerina/http;
Line 143 ⟶ 139:
</syntaxhighlight>
=== Sequence
The generated [[sequence diagram]] is a canonical representation of the source code. The two representations can be used interchangeably. The diagram support is provided through the Ballerina VS Code plugin. The following are a couple of such generated sequence diagrams, compared with its associated code.
A sample program for retrieving and processing
[[File:Working-with-data-code+diagram.png]]
Line 154 ⟶ 150:
[[File:Consuming-services-code+diagram.png]]
=== JSON
The language provides support for working with JSON values. The builtin type `json` is defined as the following union: <code>()|boolean|int|float|decimal|string|json[]|map<json></code>
<syntaxhighlight lang="typescript">
Line 173 ⟶ 169:
</syntaxhighlight>
=== Code to
Docker and Kubernetes artifacts required for deploying the code to the cloud can be generated when building the code. Values required for these artifacts are derived from the code. Additionally, one can override these values as well using the <code>Cloud.toml</code> file. To enable generation of the cloud artifacts, the users can use the <code>cloud</code> build option in the <code>Ballerina.toml</code> file. Use <code>docker</code> to generate just the Docker image and the Dockerfile and use <code>k8s</code> to generate Kubernetes artifacts as well. Minimal sample config [[TOML]] files would look something like the following:
<code>Ballerina.toml</code> file:
Line 194 ⟶ 190:
=== Workers ===
<syntaxhighlight lang="
import ballerina/http;
import ballerina/lang.'int;
Line 258 ⟶ 254:
== External links ==
* {{Official website|ballerina.io}}
* {{GitHub|ballerina-platform}}
{{Programming languages}}
Line 272 ⟶ 268:
[[Category:Free software projects]]
[[Category:Cross-platform free software]]
<!-- Hidden categories below -->
[[Category:Articles with example code]]
|