<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hasitha Aravinda</title>
    <description>The latest articles on DEV Community by Hasitha Aravinda (@hasitha).</description>
    <link>https://dev.to/hasitha</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F215365%2Fe2996ec2-bbf6-4e61-8397-8d2e8dceb709.png</url>
      <title>DEV Community: Hasitha Aravinda</title>
      <link>https://dev.to/hasitha</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hasitha"/>
    <language>en</language>
    <item>
      <title>A Quick Introduction to Ballerina: The Network-Aware Programming Language</title>
      <dc:creator>Hasitha Aravinda</dc:creator>
      <pubDate>Sun, 04 Jun 2023 06:23:35 +0000</pubDate>
      <link>https://dev.to/hasitha/a-quick-introduction-to-ballerina-the-network-aware-programming-language-5dc3</link>
      <guid>https://dev.to/hasitha/a-quick-introduction-to-ballerina-the-network-aware-programming-language-5dc3</guid>
      <description>&lt;p&gt;Have you heard of a programming language called Ballerina? As someone who works closely with the Ballerina language design and implementation team, I wanted to shed some light on this relatively young language that has a strong focus on network integration.&lt;/p&gt;

&lt;p&gt;Why Ballerina, you ask? It was developed with the intent of making network behaviour a first-class concept within the language, simplifying tasks such as integrating with other services (i.e., HTTP, gRPC, GraphQL, Kafka, etc.), manipulating data, handling network security, and much more.&lt;/p&gt;

&lt;p&gt;Here's a "Hello World" service example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import ballerina/http;

service / on new http:Listener(9090) {

    resource function get hello(string? name) returns json {
        // name is an optional query parameter
        string target = name == () ? "World" : name;
        string message = string `Hello, ${target}!`;
        return {"message": message};
    }

    resource function get greet/[string name]() returns xml {
        // name is a required path parameter
        xml response = xml `&amp;lt;message&amp;gt;Greetings, ${name}!&amp;lt;/message&amp;gt;`;
        return response;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This service presents two HTTP resources (&lt;code&gt;/hello&lt;/code&gt; and &lt;code&gt;/greet/{name}&lt;/code&gt;), which produce a response in JSON and XML respectively.&lt;/p&gt;

&lt;p&gt;You can check out more detailed examples of Ballerina's &lt;a href="https://ballerina.io/usecases/integration/"&gt;use cases in network integration&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Although the Ballerina community is currently small and largely composed of enterprise users, it's growing and openly welcoming to anyone interested in network applications development and integration. You are warmly invited to join us on &lt;a href="https://discord.com/invite/ballerinalang"&gt;discord&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're interested in diving deeper into Ballerina, I've written a &lt;a href="https://bal.tips/docs/introduction/basics/"&gt;blog post&lt;/a&gt; covering the basics. We also have &lt;a href="https://ballerina.io/learn/by-example/"&gt;more examples&lt;/a&gt; for you to explore.&lt;/p&gt;

&lt;p&gt;Let me know what you think. I'm excited to hear your thoughts and answer any questions you might have!&lt;/p&gt;

</description>
      <category>ballerinalang</category>
      <category>http</category>
      <category>network</category>
      <category>programming</category>
    </item>
    <item>
      <title>Ballerina Identifiers: A Simple Guide for New Developers</title>
      <dc:creator>Hasitha Aravinda</dc:creator>
      <pubDate>Wed, 15 Mar 2023 12:07:23 +0000</pubDate>
      <link>https://dev.to/hasitha/ballerina-identifiers-a-simple-guide-for-new-developers-43ia</link>
      <guid>https://dev.to/hasitha/ballerina-identifiers-a-simple-guide-for-new-developers-43ia</guid>
      <description>&lt;p&gt;Identifiers are names we give to elements in our code, like variables, functions, or types, to easily recognize and refer to them. &lt;/p&gt;

&lt;p&gt;You'll find identifiers all over your code - for types, variables, functions, and more. Check out this picture showing all the identifiers in a typical Ballerina Service.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GuDbT_Pu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bal.tips/docs/syntax/identifiers/Identifiers.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GuDbT_Pu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bal.tips/docs/syntax/identifiers/Identifiers.png" alt="Identifiers are everywhere" width="880" height="509"&gt;&lt;/a&gt;Identifiers are everywhere - &lt;a href="https://bal.tips"&gt;Source&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Picking good identifiers is super important to make your code easy to read and understand. Every programming language has its own rules and guidelines for identifiers, and in this post, we'll dive into how to nail identifiers in Ballerina.&lt;/p&gt;

&lt;p&gt;This is a summarized version of my blog post on &lt;a href="https://bal.tips/docs/syntax/identifiers/"&gt;Ballerina Identifiers - Best Practices and Use Cases&lt;/a&gt;. Head over there for more code examples and in-depth info.&lt;/p&gt;




&lt;h2&gt;
  
  
  ✍️ Syntax
&lt;/h2&gt;

&lt;p&gt;In Ballerina, identifiers have a few different syntax options:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://bal.tips/docs/syntax/identifiers/#identifier-syntax"&gt;Standard Identifier&lt;/a&gt;: Starts with an ASCII letter, underscore, Unicode identifier character, or a Unicode code point escaped with &lt;code&gt;\u{XXXX}&lt;/code&gt;. It can then be followed by any combination of characters, including digits. Can't use reserved words as they'll cause errors.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://bal.tips/docs/syntax/identifiers/#quoted-identifier"&gt;Quoted Identifier&lt;/a&gt;: Begins with a single quote, allowing keywords and identifiers starting with digits. This helps avoid limitations of the standard syntax.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://bal.tips/docs/syntax/identifiers/#character-escaping"&gt;Character Escaping&lt;/a&gt;: Use &lt;code&gt;\u{XXXX}&lt;/code&gt; or &lt;code&gt;\&amp;lt;Non-ASCII-CHAR&amp;gt;&lt;/code&gt; to include valid Unicode code points in identifiers. Some restrictions apply, as mentioned in the Ballerina Language Specifications.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://bal.tips/docs/syntax/identifiers/#qualified-identifier-syntax"&gt;Qualified Identifier&lt;/a&gt;: To refer to elements in another module, use &lt;code&gt;&amp;lt;module-prefix-identifier&amp;gt;:&amp;lt;identifier&amp;gt;&lt;/code&gt;. The module prefix must match the import declaration within the source file, and a colon separates it from the identifier without any whitespace.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's see some valid identifiers.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Standard Identifier&lt;/th&gt;
&lt;th&gt;Quoted Identifier&lt;/th&gt;
&lt;th&gt;Qualified Identifier&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;name&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;'2invalid&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;my\-variable&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ageInYears&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;'12345&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;bad\u{21}name&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sales_tax_rate&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;'if&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;\@hello&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;_isAvailable&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;'order&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;id\ with\ spaces&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;MAX_ATTEMPTS&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;'class&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;id\u{20}with\u{20}spaces&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;As you can see, Ballerina identifiers are quite flexible, supporting a wide range of combinations. This flexibility is particularly useful when working with data containing different languages and symbols, as it makes handling domain-specific terminology, non-ASCII characters, and even non-English languages much simpler.&lt;/p&gt;

&lt;p&gt;In the following sections, we'll discuss some of the practical use-cases for Ballerina's versatile identifiers.&lt;/p&gt;

&lt;h2&gt;
  
  
  💡 Few Use-Cases
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Ballerina's design prioritizes Unicode support in identifiers, making it easy for programmers to use non-ASCII characters, domain-specific terminology, and non-English languages in their code.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dvVsp1i0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://bal.tips/docs/syntax/identifiers/person-record.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dvVsp1i0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://bal.tips/docs/syntax/identifiers/person-record.gif" alt="Writing Person record in different languages" width="809" height="297"&gt;&lt;/a&gt;Writing Person record in different languages - &lt;a href="http://bal.tips/docs/syntax/identifiers/#unicode-support"&gt;View Source Code&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ballerina's flexible identifiers can be extended to support JSON values with special characters in the keys, making it easier to create matching identifiers that simplify data access and manipulation without complex transformations. This approach can be applied to other use-cases as well. Watch this video where I demonstrate working with JSON in Ballerina, showcasing how simple it is to handle such scenarios.&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Yz21_A6Z1Eo"&gt;
&lt;/iframe&gt;Working with JSON Data with Special Characters in Keys - &lt;a href="http://bal.tips/docs/syntax/identifiers/#better-support-for-json-keys"&gt;View Source Code&lt;/a&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In Ballerina, use a single underscore _ to ignore unneeded values in certain contexts, but note that it only works for non-error values, as ignoring a value that could contain an error generates a compiler error.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o1VhAs06--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5u9m00hcafk6dk6f417l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o1VhAs06--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5u9m00hcafk6dk6f417l.png" alt="Ignoring Values" width="854" height="519"&gt;&lt;/a&gt;Ignoring Values - &lt;a href="http://bal.tips/docs/syntax/identifiers/#ignoring-values-using-_"&gt;View Source Code&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  💡 Naming Conventions
&lt;/h2&gt;

&lt;p&gt;Identifiers can be used in different language contexts, and depending on the context, there are generally accepted best practices for naming identifiers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VBnw-7Gu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bal.tips/docs/syntax/identifiers/7e9l6t.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VBnw-7Gu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bal.tips/docs/syntax/identifiers/7e9l6t.jpg" alt="Identifiers Everywhere, But not a single one descriptive." width="735" height="500"&gt;&lt;/a&gt;&lt;a href="https://imgflip.com/i/7e9l6t"&gt;Identifiers Everywhere, But not a single one descriptive&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use descriptive identifiers to improve code readability.

&lt;ul&gt;
&lt;li&gt;Find a balance between length and clarity. This balance takes time to master.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Avoid abbreviations, except for widely-known ones.&lt;/li&gt;
&lt;li&gt;Consider context and relevant conventions:

&lt;ul&gt;
&lt;li&gt;camelCase - for function/method names and parameters, variables (local, module level, configurable, etc.), record fields, and more.&lt;/li&gt;
&lt;li&gt;PascalCase - for Type Definitions, Classes, Enums, etc.&lt;/li&gt;
&lt;li&gt;UPPER_SNAKE_CASE - for Constants.&lt;/li&gt;
&lt;li&gt;kebab-case - for Service and Resource path segments.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Understand the difference between public and non-public identifiers:

&lt;ul&gt;
&lt;li&gt;Choose public identifiers carefully for exposed APIs (service or client).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Be prepared to deviate from guidelines for specific requirements (e.g., OpenAPI/GraphQL/gRPC contracts) or when using non-English words, where camelCase or PascalCase may not apply.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🚀 Identifier Scopes
&lt;/h2&gt;

&lt;p&gt;Ballerina identifiers have their own rules depending on the scope they're in. There are two main scopes: module-scope (usable in the module and, if public, outside too) and block-scope (limited to the block they're in). You can use the same name for both scopes within the same symbol space, but be careful not to overlap block-scoped ones with the same name or you'll get a compile error. For more info, check out my original post!&lt;/p&gt;




&lt;h2&gt;
  
  
  🎉 Summary
&lt;/h2&gt;

&lt;p&gt;Well, that's a wrap on our quick dive into Ballerina identifiers! I hope this discussion helped you learn a new language feature and gave you the confidence to handle special characters with ease. Remember, don't complicate things; use Ballerina for quick development. Maybe you can consider Ballerina for your next DIY integration.&lt;/p&gt;

&lt;p&gt;Don't forget to check out my original &lt;a href="https://bal.tips/docs/syntax/identifiers"&gt;blog post&lt;/a&gt; for more detailed explanations and code examples. Also, visit the &lt;a href="https://ballerina.io"&gt;ballerina.io&lt;/a&gt; website, as it has a lot of great resources to help you learn Ballerina.&lt;/p&gt;

&lt;p&gt;You can meet Ballerina developers &lt;a href="https://discord.gg/ballerinalang"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Keep exploring, and happy coding with Ballerina!&lt;/p&gt;

</description>
      <category>ballerinalang</category>
      <category>identifiers</category>
      <category>programming</category>
      <category>ballerina</category>
    </item>
    <item>
      <title>Simplify Ballerina Workflow on GitHub with setup-ballerina Action</title>
      <dc:creator>Hasitha Aravinda</dc:creator>
      <pubDate>Mon, 20 Feb 2023 17:09:46 +0000</pubDate>
      <link>https://dev.to/hasitha/simplify-ballerina-workflow-on-github-with-setup-ballerina-action-452j</link>
      <guid>https://dev.to/hasitha/simplify-ballerina-workflow-on-github-with-setup-ballerina-action-452j</guid>
      <description>&lt;p&gt;The post covers the use of the &lt;code&gt;setup-ballerina&lt;/code&gt; GitHub Action to automate the installation of the Ballerina (Swan Lake) distribution in the GitHub Action environment. &lt;/p&gt;

&lt;p&gt;The following code block shows how you can configure the GitHub Action to build your Ballerina project. You can find a working example of this in this &lt;a href="https://github.com/hasithaa/example-setup-ballerina/"&gt;repository&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ycsGEabU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a3sw6oneauy7hol8ml53.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ycsGEabU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a3sw6oneauy7hol8ml53.png" alt=" raw `setup-ballerina` endraw  in action" width="880" height="607"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;setup-ballerina&lt;/code&gt; GitHub Action &lt;code&gt;v1&lt;/code&gt; release requires a mandatory input of the Ballerina Swan Lake distribution version in the form of "Swan Lake channel" as listed in the &lt;code&gt;bal dist list&lt;/code&gt; command. i.e. &lt;code&gt;2201.3.0&lt;/code&gt;, &lt;code&gt;2201.3.2&lt;/code&gt;, etc. This will install Ballerina on workflow environment and &lt;code&gt;bal&lt;/code&gt; command is added to the &lt;code&gt;PATH&lt;/code&gt;. &lt;/li&gt;
&lt;li&gt;This action is supported on Ubuntu, MacOS, and Windows, and facilitates easy integration of Ballerina into your GitHub workflow.&lt;/li&gt;
&lt;li&gt;After you install Ballerina command, you can use &lt;code&gt;run&lt;/code&gt; to execute the &lt;code&gt;bal&lt;/code&gt; command. &lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;With the introduction of &lt;code&gt;setup-ballerina&lt;/code&gt;, users now have the option to choose between &lt;a href="https://github.com/marketplace/actions/ballerina-action"&gt;&lt;code&gt;ballerina-action&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://github.com/marketplace/actions/setup-ballerina-language"&gt;&lt;code&gt;setup-ballerina&lt;/code&gt;&lt;/a&gt; for using Ballerina in their GitHub Actions workflows.&lt;/p&gt;

&lt;p&gt;This provides greater flexibility and choice for users, allowing them to choose the option that best suits their specific workflow needs. A comparison of the two options can help users make an informed decision based on factors such as Architecture and full &lt;code&gt;bal&lt;/code&gt; command support.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;GitHub Action&lt;/th&gt;
&lt;th&gt;&lt;code&gt;setup-ballerina&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;&lt;code&gt;ballerina-action&lt;/code&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Architecture&lt;/td&gt;
&lt;td&gt;Composite Actions&lt;/td&gt;
&lt;td&gt;Docker container&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supported Ballerina Versions&lt;/td&gt;
&lt;td&gt;Swan Lake&lt;/td&gt;
&lt;td&gt;1.x and Swan Lake&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Full &lt;code&gt;bal&lt;/code&gt; Command Support&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Limited to &lt;code&gt;bal build&lt;/code&gt; and &lt;code&gt;bal push&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In summary, setup-ballerina provides more flexibility and full bal command support. The choice of which action to use ultimately depends on your specific needs and workflow requirements.&lt;/p&gt;




&lt;p&gt;Originally, &lt;a href="https://github.com/hasithaa/setup-ballerina/"&gt;setup-ballerina&lt;/a&gt; was one of my pet projects that have now been officially part of the &lt;a href="https://github.com/ballerina-platform/setup-ballerina/"&gt;Ballerina platform&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>githubactions</category>
      <category>ballerina</category>
      <category>ballerinalang</category>
    </item>
  </channel>
</rss>
