Ivan
Ivan

Reputation: 64207

What are key differences between Scala and Scala.JS that one needs to know to write portable code?

I am developing a pure Scala application (no Java libraries used) and would like to be able to port it to Scala.JS. What should I keep in mind while writing the Scala code to make sure it will be as easy to convert to Scala.JS as possible?

Upvotes: 0

Views: 168

Answers (2)

gzm0
gzm0

Reputation: 14842

scala-js.org contains a complete list of semantic differences. If

  • you take these into account,
  • don't use any Scala library that doesn't cross compile itself,
  • don't use any part of the JDK we don't have

Your library should cross compile just fine.

Note that the last bullet unfortunately applies transitively to the Scala standard library itself (or any cross compiled Scala library). So the only really safe choice is to cross compile and test your library.

Upvotes: 1

Nagarjuna Pamu
Nagarjuna Pamu

Reputation: 14825

One important point that I can think of is

No reflection

Don't use any methods or functions which depend on refection directly or indirectly

Because reflection does not translate well to js world

Upvotes: 0

Related Questions