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

Remove dependency on Foundation #344

Open
pokryfka opened this issue Aug 19, 2020 · 7 comments
Open

Remove dependency on Foundation #344

pokryfka opened this issue Aug 19, 2020 · 7 comments

Comments

@pokryfka
Copy link

pokryfka commented Aug 19, 2020

Is your feature request related to a problem? Please describe.
Dependency on Foundation affects significantly cold start.

Describe the solution you'd like

  • Remove dependency on any Foundation types like Date and Data.
  • Extend API to be able to provide custom JSON encoder/decoder.

Additional context

@pokryfka
Copy link
Author

CC @fabianfett

@adam-fowler
Copy link
Member

I think you need to break this up into separate tasks. This is a huge task which would require us to replace

URL, Date, DateFormatter, NSRegularExpression, JSONEncoder, CharacterSet, UUID, ContiguousBytes, DataProtocol

You would also need a FoundationCompat library to provide the interfaces that require Foundation. eg AWSPayload conversion to and from Data

One thing that might hold all of this back though is swift-crypto pulls in Foundation, I'm not sure how you want to resolve that one.

There is an argument for doing some of this work still. We could look at replacing the JSONEncoder. I'm sure @fabianfett would be really keen on this.

@fabianfett
Copy link
Contributor

One thing that might hold all of this back though is swift-crypto pulls in Foundation, I'm not sure how you want to resolve that one.

Same is true for AsyncHTTPClient

There is an argument for doing some of this work still. We could look at replacing the JSONEncoder. I'm sure @fabianfett would be really keen on this.

I think it would be enough to make the default JSONEncoder and JSONDecoder replaceable.

Also I have an offering to replace UUID: https://github.com/fabianfett/swift-extras-uuid

@adam-fowler
Copy link
Member

Same is true for AsyncHTTPClient

Good point. Removing Foundation from AHC would be a good starting point but someone needs to do an implementation of Date first and that would be a huge undertaking. And getting SSWG to accept it would be even harder.

I think it would be enough to make the default JSONEncoder and JSONDecoder replaceable.

Should be easy enough.

Also I have an offering to replace UUID: https://github.com/fabianfett/swift-extras-uuid

You can go ahead, although given we can't remove Foundation in the foreseeable future is this necessary? What do we gain, except less exposure.

@pokryfka
Copy link
Author

@adam-fowler @fabianfett

thank you for your feedback and identifying the main problems.

Good point. Removing Foundation from AHC would be a good starting point but someone needs to do an implementation of Date first and that would be a huge undertaking. And getting SSWG to accept it would be even harder.

Had a (very) quick lock at AsyncHTTPClient and it seems:

  • it uses Date only to write expires Cookie value (always in the same format and in UTC),
  • URL to parse schema and host
  • Data in 2 (convenience) functions

So technically its some work but probably not a huge effort - dumping a timestamp is much smaller task than rewriting Date;
I will play with in spare time (low priority), this should give me a better understanding of the "not using Foundation" challenges.
I understand that such PR could be never approved...

@adam-fowler
Copy link
Member

I understand that such PR could be never approved...

I wouldn't be so sure of that. If you can produce a PR which removes Foundation I think there will be people sympathetic to it.

@adam-fowler
Copy link
Member

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

No branches or pull requests

3 participants