from Hacker News

Ask HN: Coding with?overlays?

by quizotic on 3/7/17, 2:58 PM with 2 comments

I'm a C++ dinosaur who uses emacs and git. I'm wondering whether you know of a different language, or an IDE, or an SCM or anything else that might support a notion of coding with "overlays".

What's an overlay? It's code that might be needed in a particular context, but not always. One member of my team adds annoying printf statements and repetitive assertions as debugging aids to code for which he is primarily responsible. I'd love to see his code without all the cruft. I'm frequently guilty of ignoring YAGNI, and leaving in "future" code that's #ifdef'd out. Nobody but me should have to look at that. We've all added code for integrating with various external systems, be it Windows vs Linux, or postgres vs mysql; but maybe I only want to see the Linux code, without all the Windows stuff.

It might even be nice to have overlays for various levels of commenting - so I could add comments for my own understanding of someone's code without inflicting them on everyone.

I imagine a system where I could check boxes: include debugging overlay, for linux, for postgres, with my personal comments ... when I need that. Or just the core code.

Have you ever seen anything like this?

  • by stevekemp on 3/8/17, 4:55 AM

    The only close thing to that which I've used is "feature flags". I could imagine a feature-flag for PSQL, debugging output, etc. But not for "linux" vs "openbsd".
  • by itamarst on 3/7/17, 8:26 PM

    1. Search for "aspect-oriented programming".

    2. http://akkartik.name/post/wart-layers