Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WISH] Lay explanation how this magic works - maybe a blog post? #30

Open
ngortheone opened this issue Jan 31, 2024 · 2 comments
Open

Comments

@ngortheone
Copy link

ngortheone commented Jan 31, 2024

Hey @Hirrolot,

I was trying to read the implementation of the metalang99 but steam started going out of my ears.
The problem is 100% or receiving end - I lack understanding of C macros and also functional principles you've applied.

I really enjoyed your last blog post "Fueled Evaluation for Decidable Type Checking" for its clarity of thought.
It would be really great to have a similar article that explains metalang99 for smallbrain grug [1].

In particular these questions are interesting:

  • What knowledge of C preporcessor is required even to start understanding Metalang99?
  • How does it really work?
  • What is CPS and why was it a solution? Were there any alternatives to a chosen mechanism?
  • How does CPS solve macro recursion limitation?
  • How to read metalang99 internals? How to teach it to someone else?
  • Can I write some other useful abstraction with it? How to approach such a task?

The knowledge is only good if we can re-transmit and reproduce it. Metalang99 probably goes above the head of the average developer.

Thanks a lot!

[1] https://grugbrain.dev/

@Hirrolot
Copy link
Owner

Thanks for your suggestion! I was thinking about a blog post a while ago, but never really began writing it. I was thinking that an "average developer" should not really know how Metalang99 works under the hood -- for the same reason as they shouldn't know the internals of Clang, GCC, or Boost libraries.

Metalang99 is designed in such a way that it hides its bowels as much as possible (i.e., I tried to avoid abstraction leaking), so I don't think that studying Metalang99's sources is necessary for its successful usage.

On the other hand, you might be interested in actually digging into the implementation. This can be for various reasons, including contributing to Metalang99 or just pure curiosity. In this case, I invite you to begin learning how the recursion engine works -- I left a number of comments covering particular implementation aspects. You'll also find a link to CPS here, which is used as an internal representation of some functional compilers.

Overall, I was relying on already established techniques of preprocessor metaprogramming. They were applied in Boost/Preprocessor, Boost/VMD, and similar libraries a long time ago.

That being said, I think that a blog post is not absolutely necessary, but I'm also not against it. Perhaps one day I will write it, although it's not on my priority list.

@ngortheone
Copy link
Author

I like studying implementations of tools. Especially smaller and less popular ones.
Otherwise I feel like this is an ancient magic artifact made by powerful wizards of the bygone era - it works, but nobody knows how, and nobody knows how to make more of those :D

Repository owner deleted a comment from ngortheone Feb 20, 2024
@github-staff github-staff deleted a comment from apocanow1 Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants