This may be a good place to start:
In general, TW5 macros aren't "programmatic" so much as they're shortcuts. For example, you could put this at the beginning of a tiddler:
\define mymacro()
This here is my macro.
\end
And then write this anywhere in the tiddler:
To display the text:
By putting a macro in its own tiddler and tagging that tiddler $:/tags/Macro, you can write a macro call to it anywhere in your TiddlyWiki (not just in the tiddler where it's defined).
—
You can also pass variables into macros when you call them, but that's about the most "programmatic" thing they do.
For example:
/define mysecondmacro(adjective feeling)
This is my $adjective$ macro, and it makes me feel $feeling$.
/end
If you refer to this macro like so:
<<mysecondmacro "other" "like a macro-making champion">>
Or like so:
<<mysecondmacro adjective:"other" feeling:"like a macro-making champion">>
... you'll see this text displayed:
This is my other macro, and it makes me feel like a macro-making champion.
—
At least, that's the basic gist of it. ;)