Giter Club home page Giter Club logo

ballerina-lang's People

Contributors

anupama-pathirage avatar chamil321 avatar daneshk avatar gimantha avatar hasithaa avatar hemikak avatar hevayo avatar hindujab avatar kaviththiranga avatar keizer619 avatar kishanthan avatar lankavitharana avatar lasinicl avatar ldclakmal avatar maheeka avatar maryamzi avatar mohanvive avatar nadeeshaan avatar natashawso2 avatar nipunamarcus avatar nipunaranasinghe avatar pcnfernando avatar pubudu91 avatar rasika avatar rdhananjaya avatar rdulmina avatar sameerajayasoma avatar supuns avatar warunalakshitha avatar wggihan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ballerina-lang's Issues

Content Reading and Type Conversions

  • Content-based routing
  • Transforming content from one type to another type : Data Mapping
  json jm = json.bind(m, schema)
  int i = jm.get (“$.a.b.c”);
  if (i == 1) ...

Syntax in ZipCodeService.bal

In ZipCodeService.bal we write

            message:setPayload(m, successMessage);
            message:setHeader(response, "Status", 200);

and

            message:setPayload(m, failedMessage);
            message:setHeader(response, "Status", 500);

We have to change "response" into "m".

Header fields in response messages

Is there a defaulting scheme for headers in response messages? I.e. are we setting proper values for entity headers (e.g. ETag, Content-Type,...) and response headers (e.g. Location) automatically?

Some Grammar Comments

The grammar still has the concept of "connection". It's my understanding that we want to drop it.


The following looks strange to me - why do we need the ellipsis?

lastFormalParameter
    :   variableModifier* typeType '...' variableDeclaratorId
    ;

Do resource parameters always include exactly one user defined type?

resourceParameters
    :   '(' userDefineType Identifier (',' formalParameterList)? ')'
    ;

The grammar for "ifElseStatement" allows an empty "if" path as well as an empty "else" path:

ifElseStatement
    :   'if' parExpression statement ('else' statement)?
    ;

The same is true for "whileStatement":

whileStatement
    :   'while' parExpression statement
    ;

....but the syntax summary document requires at least one statement in "while".

Since the grammar defines the empty statement ";" as statement the "while" body should also support an empty body too. The same is true for "iterateStatement".


Better name for Actor

At the moment we are using Actor to represent a target system lifeline.
We need to finalize the name as well as the definition of an Actor.
(After that need to remove TODO we have put in the syntax summary doc)

Worker Syntax force us to pass same message to all workers

Our current syntax forces us to pass in the same message to all workers while they return their own messages.

Since workers might be running their own code, this might force us to send a same message in and change it within each worker.

HTTP Form Data representation using a String or Byte[]

Scenario:

HTTP form data may contain binary data such as files. There can be scenarios like where Ballerina developers need to access these form data individually and store in variables for later use.

Will Ballerina require another primitive type called byte to represent these data ? or it is sufficient to use only string for this purpose.

IMO using byte array will be more efficient because there is no character decoding step.

Support of Empty CatchClause?

Java supports empty CatchClause. Ballerina does not support this:

// below tyeName is only 'exception'
catchClause
    :   'catch' '(' typeName Identifier ')' '{' statement+ '}'
    ;

Yes, empty catch clauses sound to be a bad practice. I only want to point out the difference so that we can decide consciously.

Function visibility

Currently all the functions are visible to everyone (anyone can import and use).
We have the requirement to make some of the functions private to the package (mainly for implementing connectors).

Versioning strategy for Connectors.

What is the recommended way of versioning of a connector?

  • Different package name. (e.g: ballerina.file.v1, ballerina.file.v2, ballerina.filev1, ballerina.filev2)
  • Different connector names (e.g: FileConnectorV1, FileConnectorV2 etc.)

We can use an annotation to indicate current version of a connector, But this is only for meta information and will not sufficient to distinct a particular version of a connector when creating a connection.

e.g

package ballerina.file;

@version(1.0.0)
connector fileConnector(...){
...
}

Finalize syntax for Fork/Join

Current syntax is follows, which contains duplicate variable names, etc.

`
fork stock_exchanges (messageRef = m) {
worker workerName (message messageName) {
reply res_nyse;
}+
}*

`

How to represent Service in language

Currently Service name is equal to the Filename, now after discussions (21/11 morning) file name has not direct association to the syntax. So how are we going to represent it ?

Sample Syntax of First Ballerina Program

The first Ballerina program defines the following action:

    action getTemperature(location) (int) { ...}

"location" is defined as

type location{
    int int lon;
}

But we invoke the action by

        float temperature = wc.getTemperature(new location(lat, lon));

Thus, the type definition of "location" must be fixed (or I don't get it).

handling XML

I've been thinking about how to represent XML in Ballerina.

There are two things in XML that people often get wrong: XML Documents and Elements. Document is the whole "file" basically and contains one element, called the Document Element. An Element is of course a single element: <Element attributes*>....

In XSD, there's an element declaration and a type definition. Types are abstract - elements are concrete. There's also a concept of an anonymous type declared for a particular element: an element declared to have structure without declaring a type and then asserting that type for that element is kinda like that.

I'm roughly thinking we need something like this:

  • XMLDocument - represents a full doc. Do we need this though?? Do we ever deal with full docs?
  • XMLElement[<XSDComplexTypeName | XSDSimpleTypeName>] - defines a variable to be an element. We need the namespace and fully qualified name though .. annotations??

Need to correct the figure in the introduction

The "Resource" rectangle should not cover the lifelines.
Input/output messages of a resource should be in "gate style".
Activation phases are often not used because they don't help comprehension.

Thus, I suggest the attached figure...
figure1
Figure1.pptx

Discuss and finalize HTTP Header passing behaviour

  • Do we need to pass all the headers from incoming request to the backend ?
    No.
  • There are two types of headers (connection/protocol related, custom headers). Need to discuss how to handle them, looks like we need to handle them separately.

"break" in "if"

Java allows "break" in "if". We exclude this explicitly in the syntax summary:

A break statement allows one to terminate the immediately enclosing loop. This is only allowed
within the iterate or while constructs.

Why?

The grammar does not exclude a "break" in an "if".

Ballerina language object model and Execution for M1

This implement should support the following language features.

  • Service definition
    ** Resource definition

  • Function definition

  • 'main' function

  • Statements
    ** Assignment
    ** IfElse
    ** While
    ** Return

  • Expressions
    ** Function invocation
    ** Arithmetic
    ** Logical

Proposal to replace Exception Handling with functional Error Handling

AFAIK Balerina was being designed since day one according to functional programming concepts. That is fascinating! IMO using try/catch based exception handling mechanism for such language does not suit well. I think it conflicts with the basis of the language even though some of the functional languages have followed it:

resource passthrough (message m) {
    message response;
    try {
        response = http.get (ep, m);
    } catch (exception e) {
        json error = `{ "error" : "An error occurred" }`;
        message.setPayload(m, error);
    }
    reply response;
  }

Gooogle has carefully studied this and avoided using exceptions in Golang due to many reasons:

Google says that; coupling exceptions to a control structure, as in the try-catch-finally idiom, results in convoluted code. It also tends to encourage programmers to label too many ordinary errors, such as failing to open a file, as exceptional. Go takes a different approach. For plain error handling, Go's multi-value returns make it easy to report an error without overloading the return value [1].

Values can be programmed, and since errors are values, errors can be programmed [2].

Error handling does not obscure the flow of control [2].

You’re free to code your way out of it [3].

The presence of checked exceptions in Java can make functional programming inconvenient, because it can be necessary to catch checked exceptions and then rethrow them [4].

Considering above, I would like to propose functional error handling for Balerina:

resource passthrough (message m) {
    message response, error = invokeCustomerEndpoint (m);
    if error != nil {
        json error = `{ "error" : "An error occurred" }`;
        message.setPayload(m, error);
    }
    reply response;
  }

function invokeCustomerEndpoint(message m) (message, error) {
   message response, error = http.get(m);
   if error != nil {
      return response, error;
   }
   return response, nil;
}

[1] https://golang.org/doc/faq#exceptions
[2] https://blog.golang.org/errors-are-values
[3] https://davidnix.io/post/error-handling-in-go/
[4] https://en.wikipedia.org/wiki/Functional_programming

Supported xml functions in ballerina.lang.xml

Following xml functions are suggested.

  • append (add as last element)
  • insert-first (add as first element)
  • insert-before (add before a given element)
  • insert-after (add after a given element)
  • rename (rename a given node)
  • delete (delete a given node)
  • split (?) (create xml array from a given node)
  • aggregate (?) (create new xmlElement from a xmlArray)

Allow expression with throw

Currently, it only allows

"throw ExceptionVariableName;"

that means you cannot write

throw new exception("IOError") assuming first argument is message

Is this intentional?

--Srinath

Primitive types list - Drop float and long

Ref: ballerina/docs/SyntaxSummary.md

Can we have only the following primitive types? If we make int and double as 64-bit numbers, then we can drop float and long.

List of primitive types

boolean true or false
Int Signed 64-bit integers
double Signed 64-bit floating-point numbers
string

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.