-
Notifications
You must be signed in to change notification settings - Fork 152
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
Port all Scala code to Java #4030
Comments
Another option might be to extend @Baltoli's pattern matching library then port This would be more work in the short term, but would also make the LLVM backend more cohesive and get rid of the reverse dependency on K. |
Love the idea of removing the reverse dependency! LLVM backend being self-contained seems worth the effort. That matching code is just used for LLVM codegen right? |
Yep, that's the only place it's used. I think we'd want to first build a C++ implementation that generates the same YAML as the scala code does, test equivalence of the outputs, then eliminate the intermediate YAML. It would be a reasonably big rewrite but Dwight's documentation is really good, and we have a strong way of testing any new implementation! |
Part of #4030. Port the `POSet` class from Scala to Java. This is mostly a straightforward conversion from Scala functional idioms (`map`, `filter`, `reduce`, etc.) to the corresponding Java Stream methods. To port `lazy val`s, we also implement a `Lazy<T>` wrapper which caches the result of a `Supplier<T>`. The only remaining reference to Scala here is a single constructor which takes a `scala.collection.Set<Tuple2<T, T>>` and internally converts it to a `java.util.Set<Pair<T, T>>`. This can be removed once we more pervasively switch away from Scala collection types everywhere in the codebase. --------- Co-authored-by: Bruce Collie <[email protected]>
Part of #4030 Ports the `TopologicalSort` class to Java. Once again, this is a direct translation, replacing functional idioms with either direct iteration or equivalent `Stream` functions. The only semantic change is returning an `Optional` rather than reporting an error when there's a cycle.
While Scala is a nice language, the consensus of the frontend team is that maintaining a mixture of Scala and Java causes more friction than it is worth:
collections.scala
) and write boilerplate code to offer two versions of the same methods (e.g.getOption
andgetOptional
inAtt.scala
).As a result, we have decided that
The largest blocker will be the
matching
library in the LLVM backend, which makes heavy usage of pattern matching and likely can't be ported until we update to Java 21 (#3499).However, searching the frontend, there are only 47 Scala files, and many of them can be straightforwardly ported even without pattern matching support in Java.
A high level roadmap:
Rich.scala
,LabelInfoFromModule.scala
,Location.scala
, etc.matching
POSet.scala
,Att.scala
, etc.trait
to aninterface
pcollections
as a dependency, which provides immutable functional data structuresThe text was updated successfully, but these errors were encountered: