Question regarding scala macros and plugins

Need some reference or guide on following:

  • Where can I see list of macros which are bundled with compiler? Are macros experimental or stable?

  • What are the plugins available for various features? e.g. scalafmt, scala-style, is there any center place available?

Broadly speaking, macros are not bundled with the compiler. That’s kind of the point: macros are how applications can add functionality that isn’t included in the language/compiler.

The current version of macros is, and always has been, experimental. (Not really unstable, mind – they’re been fairly consistent for some years now. But they’ve never been officially supported.) Unfortunately, they’ve been around so long that much of the community has adopted them as if they were official.

That version of macros has a long-standing problem: it is based on compiler internals, and therefore could never really be supported as stable. It is being removed in Scala 3 (due in a couple of years), and replaced by a new system that will be official and stable; the fine details of that system are still being discussed.

This shouldn’t have too much effect on the average end user (it is unusual for application code to involve its own macros), but all macro libraries will need to be rewritten to use the new system. (This is probably the biggest change from Scala 2 to 3.) Those macro libraries should be easier to maintain after this rewrite is done. Usage of some of the most powerful macros may have to change – the new system is probably going to be slightly less powerful than the old one, but should cover most use cases.

The place to look for Scala libraries and tools is usually Scaladex. This website is based on a scrape of the publicly-available systems that describe themselves as being Scala-based, and provides relatively easy lookup, and pulls together the tool itself, its documentation, its GitHub link, and so on.

Note that Scaladex’ search functionality can be a little iffy (in particular, the prompts shown as you are typing are often not what you are looking for), but you can usually find the desired tool in the first page or two of results.

1 Like

Thanks @jducoeur, It helps a lot.! :smile: