ballerina-platform / ballerina-lang Goto Github PK
View Code? Open in Web Editor NEWThe Ballerina Programming Language
Home Page: https://ballerina.io/
License: Apache License 2.0
The Ballerina Programming Language
Home Page: https://ballerina.io/
License: Apache License 2.0
json jm = json.bind(m, schema)
int i = jm.get (“$.a.b.c”);
if (i == 1) ...
add a new section to define strings using backquote expressions
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".
$subject
https://github.com/wso2/ballerina/blob/master/src/main/java/org/wso2/ballerina/model/Identifier.java.
Since it can be represented with String
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?
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".
This is schema used to describe the qualifier attached to xml, json etc via < ..> e.g. xml<http://foo/Foo
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)
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.
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.
Similar to write C program and bind to JVM using JNI
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.
In order to implement this generically, we need the support to assign values to multiple variables.
e.g. x, y, z = expression, expression, expression;
e.g. x, y, z = getXYZ():
Left hand side of the assignment statement should be updated to variableRefList.
https://github.com/wso2/ballerina/blob/master/docs/grammar/Ballerina.g4#L201
typeconverter XtoYConverter(xmlElement input1, xmlElement input2, ..) (xmlElement output) {
statements+;
}
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).
What is the recommended way of versioning of a connector?
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(...){
...
}
We need to finalize this.
Is the assumption, that "reply" in the echoService.bal automatically sets an HTTP 200 status code? I.e. is the default status code that is returned always a 200?
Current syntax is follows, which contains duplicate variable names, etc.
`
fork stock_exchanges (messageRef = m) {
worker workerName (message messageName) {
reply res_nyse;
}+
}*
`
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 ?
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).
Actors represents a target system which depicts a lifeline in the sequence diagram. Sometimes, multiple services may need to share these actors. We need to have a mechanism for that.
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:
Use case - Poll file system, transform the file content and publish it to a JMS queue.
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.pptx
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".
We of course don't have a payload type .. but maybe json -> message and xml -> message? Will make some cases easy.
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
As done in https://github.com/wso2/ballerina/blob/master/samples/datamapping/transformService.bal
IMO, type converter is not a function although it looks like one. We can choose to make it act as a function.
This constrain should be in spec
Sample and the Summary document are not consistent
With Actor concept, where can we put configurations like Circuit Breaker (Error codes, suspension, etc), Timeout ?
Need to go through swagger schema and identify the required annotations. We should not go for JAX-RS spec since it is only required for Java.
There can be scenarios where I need to specify the following condition.
I send messages to 5 workers and I need responses from at least 3 workers or any number of responses within 10 mins.
Long type annotations like following make the code ugly?
xmlElement<{http://example.com/xsd/SalesForce}Account>
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
Name of the typeconverter is irrelevant.
XMLDocument<{XSD_namespace_name}type_name>
We need a type to represent the data services output. Sanjiva suggested to use table as a type name. Basically, this table is a wrapper of iterator which wraps a SQL result set.
Following xml functions are suggested.
This is to make the data integration cases work well.
Normally we only invoke top level names as PackageName.SymbolName. In the case of connectors, the actions are INSIDE the named connector (which is the top level thing). Yet, when we invoke an action we are saying PackageName.ActionName - which is inconsistent.
In the twitter connector sample, the following syntax has to be revisited
message loginMessage = new message;
Currently, it only allows
"throw ExceptionVariableName;"
that means you cannot write
throw new exception("IOError") assuming first argument is message
Is this intentional?
--Srinath
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.
boolean true or false
Int Signed 64-bit integers
double Signed 64-bit floating-point numbers
string
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.