Hacker News new | ask | show | jobs
by ryanmarsh 2662 days ago
The only time I have ever encountered a code base where the visitor pattern was necessary and fulfilling its purpose is Babel (the JS compiler).
1 comments

Agreed. The _only_ times I've ever been justified in implementing this pattern have been when doing compiler work.

Someone else up-thread mentioned what I think is the key requirement making visitors worthwhile is non-trivial tree traversal. ASTs seem to fit this description more than any other data structure I've had to work with day-to-day.

Outside of language trees, I wonder where else visitors are common?

ETL for very complex data structures maybe? Oh the irony. I've never seen the visitor pattern used in an ETL pipeline, which might be why they're always such God forsaken messes.