this post was submitted on 18 Feb 2024
515 points (96.7% liked)

Programmer Humor

19511 readers
365 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 

Insert <it's not much but it's honest work> meme. It only supports ints and bools, some logic and simple arithmetics and it compiles to Java but damn was it hard to get that far.

Can you guess what everything does?

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 4 points 8 months ago (1 children)

Very cool, I'd be interested in your publications once you're done. I like metaprogramming, but once you realise you might have needed it, you're already knee deep in fresh legacy code.

[–] [email protected] 3 points 8 months ago (1 children)

You essential have a compiler written through metaprogramming. For your implementation, did you use a find and replace or did you define and parse a grammar like a true compiler.

[–] [email protected] 4 points 8 months ago

MPS uses projectional editing. Which means for the user that everything you do is free from concrete syntax, and you basically edit a graphical representation of that abstract syntax tree directly, while it looks like you're in a textual editor.

So I define abstract nodes that may have certain relationships with each other and then give them a representation in the editor (which is what you see in the screenshot). These nodes may also have generators assigned to them, which use map/reduce operations to generate whatever source code I desire. It usually includes its own bit of code, and triggers code generation of its children as well.

I hope that was somehow clear 😄