4 ms·
Scala macros are compile-time. The Scala reflection library (that works at runtime) share most API with macros. Macros should always work, reflection is harder
by airless_bar 10y ago
Scala macros are compile-time. The Scala reflection library (that works at runtime) share most API with macros.
Macros should always work, reflection is harder as some information needs to be retained at runtime (either via Java reflection or additional data – which can both be problematic in Scala.js).
- acjohnson55 10y agoAnd as the original author of Scala.js pointed out in a Scala Days talk today, unrestricted reflection means that it's impossible to do dead code elimination, which is a non-starter for real-world use.
- jfoutz 10y agoI've got at least 30 enterprise applications that disagree with your "nonstarter" assertion. Dead code can only exist in real world code.
- acjohnson55 10y agoI'm talking about within the main use case, which is front-end web development. I guess some folks might be cool with 10MB+ JS apps, but I don't think that would be terribly popular, and certainly not popular enough to bother with imitating Java reflection in JavaScript.
- deleted 10y ago[deleted]
- paulddraper 10y agoWell, Proguard does whole program optimization. You have to specify the symbols to preserve explicitly.
- grogs 10y agoI believe that works against jvm bytecode, which you don't get for scalajs. Instead the compiler has a JS specific intermediate representation which the optimizations occur on.