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

Usage of scalac option -Xcheckinit #106

Closed
cornerman opened this issue Nov 29, 2017 · 3 comments · Fixed by #111
Closed

Usage of scalac option -Xcheckinit #106

cornerman opened this issue Nov 29, 2017 · 3 comments · Fixed by #111

Comments

@cornerman
Copy link
Member

cornerman commented Nov 29, 2017

The option -Xcheckinit introduces runtime checks for uninitialized values in a trait and throws a exception with a meaningful message if the value is used before initialization.

Compiling to javascript, the minified code contains these checks and furthermore introduces a function that is called when accessing this value. Should we remove this because of performance and bundle size or should we keep it?

@raquo
Copy link

raquo commented Dec 3, 2017

I'd say remove the flag. It doesn't feel right to have onerous runtime checks like this, at least not in production. I guess you could only enable it in fastOptJS and/or in tests. Although I personally try to keep the difference between prod and dev to a minimum.

Here more info on the problem this flag solves: https://docs.scala-lang.org/tutorials/FAQ/initialization-order.html

@raquo
Copy link

raquo commented Dec 3, 2017

Hm. As a dependency on someone's project, Outwatch gets compiled into intermediate scala.js representation files, not into JVM bytecode. I wonder if this compiler option even affects those sjsir files, or if it is the consuming project's flag that matters instead.

@cornerman
Copy link
Member Author

I think you are right and quoting from the link you provided: "It is inadvisable to use this flag outside of testing. It adds significantly to the code size by putting a wrapper around all potentially uninitialized field accesses". So we should remove it, but I am also not sure how it works in dependent applications.

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

Successfully merging a pull request may close this issue.

2 participants