Stupidly Obscure Programming in a Troubled Time (2018)
4 days ago
- #Macros
- #Scala
- #Concurrency
- The author explores concurrent data retrieval in Haskell using Haxl and in Scala with Fetch, noting Haxl's advantage due to Haskell's do construct extensions.
- A tedious Scala macro is constructed to mimic Haxl's functionality in Scala's for comprehensions, with many challenges encountered.
- The post demonstrates the macro's success in batching concurrent data fetches but acknowledges the complexity and limitations.
- The author rants about the complications of implementing Haskell-style programming in Scala, especially around typeclasses and implicits.
- A detailed example shows how Fetch batches data retrieval operations in Scala, comparing manual and macro-assisted approaches.
- The macro's implementation involves complex AST transformations and symbol ownership management to achieve the desired batching effect.
- The author reflects on the difficulties of debugging Scala macros and the IDE's limitations in handling implicit conversions and typeclasses.
- Despite the technical success, the author expresses dissatisfaction with the complexity of categorical programming in Scala compared to Haskell.