-
-
Couldn't load subscription status.
- Fork 89
feat: Add Scala Native support infrastructure #210
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
base: master
Are you sure you want to change the base?
feat: Add Scala Native support infrastructure #210
Conversation
- Create platform abstraction layer (HttpBackend trait) - Extract JVM implementation into JvmHttpBackend using java.net.http.HttpClient - Add placeholder NativeHttpBackend for Scala Native - Refactor Requester to delegate to platform-specific backends - Configure build.mill for cross-compilation (JVM and Native) - Add platform-specific source directories (src-jvm, src-native) - Enable Scala Native 0.5.6 with scala-native-crypto dependency This provides the foundation for Scala Native support (com-lihaoyi#156). The Native backend implementation requires: - java.net.http.HttpClient for Scala Native - java.net.HttpCookie for Scala Native - Full javax.net.ssl.SSLContext support All JVM functionality remains backward compatible and fully functional.
|
Hi @lihaoyi @LeeTibbert @lqhuang, Quick update on the Scala Native work: I've finished the foundation (~40%) - all the infrastructure is in place: The remaining 60% (actual Native backend) is waiting on @lqhuang's HttpClient work. Rather than sit idle, I'm jumping over to help fix the HttpCookie PR in scala-native (#3927) since it's been stalled since May and we'll need it anyway. Plan:
Following your HttpClient approach. Will keep you posted! Thanks! |
|
Sounds like a good plan. As always, I am on hand to help with the Scala Native parts.
Good hunting. |
|
Hi @LeeTibbert, I’ve decided to implement the HttpCookie support from scratch with a completely new codebase instead of using PR #3927. Thanks, |
|
| I’ve decided to implement the HttpCookie support from scratch Sounds as a wise move. In my "waiting for CI runs to finish" time, I'll refresh my memory of 'HttpCookie' and if Nice to have you working on it. I do not mean to slow you down by my being |
|
Hi @rishi-jat, Thank you for your contributions and for your interest in the project! I appreciate you taking the time to submit a pull request. I'm reviewing the current PR, and I'm trying to understand the purpose of the changes. Given that we're focused on shimming required modules/classes in Java for Scala Native, the expectation was that changes to Additionally, current codes and the description give the impression of being AI-generated. If I'm mistaken, I apologize in advance, and I'd appreciate clarification. While I'm open to code created with the assistance of LLMs, it's important that the submitter takes full ownership of the code and is responsible for ensuring its quality and integration. I want to share a statement here I see elsewhere, "This PR was primarily authored with GPT-5-Codex and hand-reviewed by me. I'm responsible for every change that lands here." Could you explain the rationale behind why we need to split to different backend in this context? Understanding the motivation behind this approach will help me better assess the PR. Still appreciate and welcome for your contribution! Regards |
|
Hi @lihaoyi, Thanks for reviewing the PR and the thoughtful feedback! Why the backend split is necessary: The current Requester.scala directly imports java.net.http.HttpClient - these classes don't exist in Scala Native. Without this abstraction, the code simply won't compile for Native targets. It's not just about runtime behavior, it fails at compile time. Rationale for this approach: I considered conditional compilation, but that would scatter #if JVM blocks throughout the codebase. The backend abstraction keeps platform-specific code isolated while maintaining a clean public API. What this achieves: Zero breaking changes for existing JVM users Alternative approaches: If you prefer a different strategy, I'm open to discussion. The core constraint is that java.net.http.* imports need to be isolated from shared code to enable Native compilation. Looking forward to your thoughts on the best path forward! Best, |
|
As you said
then, it will be a “free lunch” benefit. We can just declare these upstream projects as deps and compile under Scala Native condition. Yeah, that's all. How do you think about it? |
|
Exactly! That's precisely why I structured it this way. The backend abstraction enables that "free lunch" - once your HttpClient work and HttpCookie are available, we just: Update NativeHttpBackend to use the new dependencies Looking forward to your HttpClient progress! The foundation is ready to plug it in. |
|
It's fine to just keep these codes in your forked repo for dev purpose. When everything ready, these codes will be clean up in the future. They may not be suitable for being merged into the main line now. Of course, it's just my personal thought, you could ask Haoyi for more. |
|
I think the ideal here would be to implement the upstream classes in the java standard library. Requests-Scala is just a thin wrapper over Some minimal modifications are fine, in the interests of getting something working, but the goal should be to minimize how much Requests-Scala code needs to be modified |
|
@lqhuang Is the working plan still to implement You could probably delay JDK 26 is only a few months out. I believe that it introduces some changes. It makes some Of course, you have been working on this for awhile and may already have a plan or the I say all of this not to jump into the middle (or end) of people's existing work throw but |
Yeah. Exactly the same with what you describe. That's why I think this PR is probably not necessary.
LOL, yes, I also think so, you could check my project index lqhuang/scala-native-http, my roadmap matches your thoughts. HTTP3 will be a good idea, it's also true that it's not first priority now. Good news is I'm working on Let's try to release something to ensure basic features. I know we're looking forward to that goal. 😋 It's glad to hear your feedback. Thanks! |
Progress: 40% Complete (Foundation)
This PR adds the infrastructure for Scala Native support:
Remaining Work (60%):
Related:
Fixes #156
java.net.http.HttpClientscala-native/scala-native#4104 (HttpClient)