getkyo / kyo

Toolkit for Scala Development
https://getkyo.io
Apache License 2.0
558 stars 46 forks source link

Cleanup JS stubs #808

Open fwbrasil opened 2 weeks ago

fwbrasil commented 2 weeks ago

I didn't have much discipline when I first introduced JS support and created quick stubs for the necessary types. We should move to a more structured approach with PlatformSpecific super types, avoiding stubs for Java types for example.

fwbrasil commented 2 weeks ago

@hearnadam wdyt about relocating some of the bounty budget to this? It's also an important cleanup step before we add Scala Native support to kyo-core.

hearnadam commented 1 week ago

@fwbrasil Which of these do you think we can remove?

./kyo-scheduler/js/src/main/scala/java/util/concurrent/ThreadFactory.scala
./kyo-scheduler/js/src/main/scala/kyo/scheduler/util/Threads.scala
./kyo-scheduler/js/src/main/scala/kyo/scheduler/InternalClock.scala
./kyo-scheduler/js/src/main/scala/kyo/scheduler/Scheduler.scala
./kyo-scheduler/js/src/main/scala/kyo/scheduler/Coordinator.scala
./kyo-cats/js/src/test/scala/java/util/concurrent/CountDownLatch.scala
./kyo-zio/js/src/test/scala/java/util/concurrent/CountDownLatch.scala
./kyo-core/js/src/main/scala/kyo/AsyncStubs.scala
./kyo-core/js/src/main/scala/kyo/internal/LogPlatformSpecific.scala
./kyo-core/js/src/main/scala/kyo/internal/FiberPlatformSpecific.scala
./kyo-core/js/src/main/scala/kyo/scheduler/IOPromisePlatformSpecific.scala
./kyo-core/js/src/main/scala/kyo/queuesStubs.scala
./kyo-core/js/src/main/scala/kyo/hubsStubs.scala
./kyo-core/js/src/main/scala/kyo/addersStubs.scala
./kyo-core/js/src/main/scala/kyo/timersSubs.scala
./kyo-core/js/src/main/scala/kyo/stats/internal/ServiceLoader.scala
./kyo-stats-registry/js/src/main/scala/java/lang/ref/WeakReference.scala
./kyo-stats-registry/js/src/main/scala/kyo/stats/internal/UnsafeHistogram.scala
./kyo-stats-registry/js/src/main/scala/kyo/stats/internal/StatsRefresh.scala
./kyo-prelude/js/src/main/scala/kyo/kernel/TracePool.scala
./kyo-prelude/js/src/main/scala/kyo/kernel/Platform.scala
./kyo-sttp/js/src/main/scala/kyo/PlatformBackend.scala

Aside from porting some collections to compile for Scala 3, I am not sure how we can avoid some of these stubs. We could however certainly join the jvm + native files that are just duplicated. We can also possibly

fwbrasil commented 1 week ago

I think in many cases it's possible to refactor the code to a PlatformSpecific impl instead of using the java types directly so we don't need to stub them

hearnadam commented 1 week ago

/bounty $75

algora-pbc[bot] commented 1 week ago

💎 $75 bounty • Kyo

Steps to solve:

  1. Start working: Comment /attempt #808 with your implementation plan
  2. Submit work: Create a pull request including /claim #808 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to getkyo/kyo!

Add a bounty • Share on socials