Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redundant APIs for Encoding/Decoding #314

Closed
ldclakmal opened this issue Aug 27, 2019 · 2 comments · Fixed by ballerina-platform/ballerina-lang#18309
Closed

Redundant APIs for Encoding/Decoding #314

ldclakmal opened this issue Aug 27, 2019 · 2 comments · Fixed by ballerina-platform/ballerina-lang#18309
Assignees
Labels
platform Relates to the Ballerina platform

Comments

@ldclakmal
Copy link
Member

ldclakmal commented Aug 27, 2019

Description:
Some of the APIs related to the functionalities of encoding/decoding was introduced to langlib/array recently [1]. Those functionalities were already supported and used since Ballerina v0.991.0 with ballerina/encoding module [2]. So, now there are redundant APIs in both langlib/array and ballerina/encoding module.

Newly introduced APIs in langlib/array module

public function toBase64(byte[] arr) returns string = external;
public function fromBase64(string str) returns byte[]|error = external;
public function toBase16(byte[] arr) returns string = external;
public function fromBase16(string str) returns byte[]|error = external;

Matching APIs in the ballerina/encoding module

public function encodeBase64(byte[] input) returns string = external;
public function decodeBase64(string input) returns byte[]|Error = external;
public function encodeHex(byte[] input) returns string = external;
public function decodeHex(string input) returns byte[]|Error = external;

The issue is that what should be done for the rest of the APIs, which were given under the ballerina/encoding module?

Also, where should we add the newly introduced APIs for encoding/decoding in the future?

[1] https://github.com/ballerina-platform/ballerina-lang/blob/master/langlib/lang.array/src/main/ballerina/src/lang.array/array.bal#L204
[2] https://github.com/ballerina-platform/ballerina-lang/blob/master/stdlib/encoding/src/main/ballerina/src/encoding/encoding.bal

Related discussion: https://groups.google.com/d/msg/ballerina-dev/sbASEwIl44k/0YlP3IcXFwAJ

@jclark
Copy link
Collaborator

jclark commented Aug 27, 2019

There is also toBytes and fromBytes in lang.string.

It looks like the remaining things in encoding are:

The 2nd, in my view, is legacy at this point, and pulls in a lot of code, so should be a separate module, with a richer API (e.g. enumerate the available encodings etc). Eventually we will need a bunch of Unicode/i18n libraries, and I would include that there.

Not sure about the first. Maybe put it together with URL-related stuff.

@jclark jclark added the platform Relates to the Ballerina platform label Aug 27, 2019
@sanjiva
Copy link
Contributor

sanjiva commented Aug 28, 2019

We don't have a URL specific place right now, but yeah +1 for removing the methods from the encoding module and maybe leaving just the URL encode/decode function there for now.

I don't know whether we have time to change the code for this release. Worst case we can leave these in encoding and remove later (as the usage is internal to stdlibs).

And +1 to removing non-UTF-8 from basic libs and doing them (later) as another module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform Relates to the Ballerina platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants