History: Why did Scala *wrap* rather than enrich Java's BigDecimal?

BigInt was introduced long before value classes were added to Scala. And either value classes or extension methods are needed to make enrichments efficient. So wrapping was the best available technology at the time.

For String the tradeoff was different. First, interop with Java was mandatory, not just an option. Second, most String methods would be called as member methods, the enrichment added only some methods that were needed relatively infrequently.

I agree that by now we have technology with extension methods that makes enrichment the better option also for BigDecimal.

7 Likes