ekrich
December 29, 2023, 1:08am
1
Happy to announce a new version, 1.6.0.
Scala configuration library supporting HOCON for Scala, Java, Scala.js, and Scala Native - GitHub - ekrich/sconfig: Scala configuration library supporting HOCON for Scala, Java, Scala.js, and Scala...
Scala.js and Scala Native now support java.io.Reader
and significantly more tests (154 to 318, JVM has 532). The last major feature to add is Scala Native support to read files and embedded resources. Around 12 fixes from the original library have not been ported if someone wants to help out. Port all non documentation commits from typesafe/config · Issue #29 · ekrich/sconfig · GitHub
Scala.js released 1.15.0 which includes the new java.io.FilterReader
.
scala-js:main
← ekrich:topic/reader
opened 05:16PM - 01 Nov 23 UTC
This library was originally ported to Scala so we could have a native version of scalafmt
but that has never made it to the finish gate. If any one has the time and inclination to take this PR and make it into a smaller set of PRs that would be super great and you would be my hero.
scalameta:master
← jchyb:feature/add-scala-native
opened 12:26AM - 05 Nov 21 UTC
## Changes
* Project structure was changed in compliance with `sbt-crossproject… `.
* `googlecode`'s `diffutils` had to be removed, as Scala Native does not support java libraries. In its place, part of diffutils was reimplemented in scala as part of scalafmt-cli.
* For similar reasons, the java interfaces were reimplemented in scala for Scala Native.
* Since Scala Native does not yet support glob expressions, a translation function to regex was added, heavily based on a linked stack-overflow answer. Similarly, Scala's `Process` is replaced with java stdlib's `ProcessBuilder`, as `Process` uses concurrency.
* SN's regex implementation is currently based on the re2 instead of the standard java regexes. This means there are a number of differences between them, most notably the lack of backtracking in Scala Native. To accommodate that, some regex function reimplementations were done to match the use of the existing scalafmt regexes in Scala Native.
* Some operations concerning tests were slightly modified to work on Native. For example, renaming a file to an existing directory path could throw errors. Hopefully this is fine, as it does not concern the core of the test, only things like cleanup.
* Assumptions about dynamic tests not working on native were added. Scala Native does not support URLs and only has basic opt-in reflection support comparable to the one of GraalVM, so the used and expected version of scalafmt must match here as well.
* Term Display was made single-threaded for the Scala Native, as SN does not support concurrency yet. Since the new implementation caused display artifacts on JVM, the old multithreaded one was kept there.
* Scala Native setup and testing was added to the CI. Windows support was temporarily disabled as it does not pass all of the tests yet.
* `scala-native` sbt command was also added for easier scala-native cli building. Use `sbt scala-native` to generate Scala Native binaries (with LLVM installed).
## Publishing
I did not include any publishing in this PR. For now there is not much point in releasing the scala-native binaries. Publishing as a library is another story, but I have not looked into that yet.
## Performance
There are some severe performance problems when using the binaries generated from Scala Native. This should not happen. I tried to move the regex reimplementation as well as TermDisplay to use in JVM, yet that did not cause any noticeable performance problems there - unfortunately it seems that there is a bug on scala-native side. I will try to look into that issue.
Comparison running on Scalafmt repo:
JVM:
```
VL-D-0143:scalafmt jchyb$ time java -jar ./scalafmt-cli/jvm/target/scala-2.13/scalafmt.jar
Reformatting...
100,0% [##########] 217 source files formatted
real 0m8.961s
user 0m43.648s
sys 0m1.467s
```
Native (Immix GC, release-fast optimization mode, full LTO, but I tried with many more options to no avail):
```
VL-D-0143:scalafmt jchyb$ time ./scalafmt-cli/native/target/scala-2.13/scalafmt-cli-out
Reformatting...
100.0% [##########] 217 source files formatted
real 0m11.005s
user 0m15.570s
sys 0m5.000s
```
## Additional comments
To smoothen out the review process I split this PR into two commits, one with only renames, and one with more meaningful changes. Hopefully this will help a bit :)
Thanks and have a Happy New Year!
6 Likes