Programming for a living used to be an active conversation between yourself, the computer, and your colleagues. This Christmas, a new guest is joining the programming party: the LLM. Large Language Models (LLMs) can talk a lot and just like your crazy Uncle occasionally blurt out something bonkers. But do we want to invite LLMs to the programming party, and where should they sit? How can they help things flow?
Finding flow while programming is the art of staying in the Goldilocks zone - working on challenges that are not too hard and not too easy. Raku and Perl are both super-expressive languages with rich operators. Their low and long learning curves enable programmers to pick a place that matches their current skill level and stay in flow.
There is a potential downside, however, for a language like Raku that is optimized for (O)fun. Sometimes new programmers encounter code too far along their learning curve, way outside their Goldilocks zone. For them, fear is a flow stopper. Worse than that, as Master Yoda put it, "Fear leads to anger. Anger leads to hate. Hate leads to suffering." The mindshare of expressive languages has suffered enough.
Fortunately, Santa is smiling more than ever this Christmas! LLMs are a gift that can help lift more programmers up the learning curve and into the Goldilocks zone: less fear, more flow.
Expressive languages, like Raku, can offer LLM-powered utilities as part of their tooling to help new programmers up the learning curve. Here's a simple example.
[12]\d{3}-[01]\d-[0-3]\d ([^ \[]*?)\[([^\]]*?)\]:.*
Now instead of wailing "WAT?!" Just use the Raku "wat" utility to help explain it.
shell> wat "[12]\d{3}-[01]\d-[0-3]\d ([^ \[]*?)\[([^\]]*?)\]:.*"
This code extracts log entries in the format "timestamp [source]: message".
Use it to parse log files and extract specific information.
wat
works with code snippets or can explain entire programs for you.
shell> wat WAT/CLI.rakumod
This code summarizes code using the LLM::DWIM module.
To use:
- Run `wat <filename>` to summarize a program
- Run `wat "$some-code.here();"` to explain code
- Run `wat config` to change settings
- Run `wat help` to show help
The WAT::CLI
module uses the following prompt:
# keeping the prompt short and sweet
my $prompt = q:to"PROMPT";
You are an expert programmer.
Produce friendly, simple, structured output.
Summarize the following code for a new programmer.
Limit the response to less than $response-char-limit characters.
Highlight how to use this code:
PROMPT
One programmer's WAT is another's DWIM (Do What I Mean). Under the hood, the WAT::CLI
module relies on
the LLM::DWIM
module's dwim
method to do all the LLM work.
say dwim $prompt ~ $program-content;
Current LLMs work best with sufficient context - so they can associate problems and solutions. Without context,
LLMs can stumble. Just try giving wat
an empty context (" "
) and it's like that crazy Uncle at Christmas after
one too many!
To have a play with wat
this Christmas, install it with Raku's package manager zef
:
shell> zef install wat
Here are some ideas for helping code to flow.
- Comment Injector: Inject useful comments
- Comment Translator: Translate comments into your spoken language
- Reviewer: Suggest potential improvements
- Module Documentor: Document a module with RakuDoc
- Unit Test Maker: Generate unit tests
- CLI Maker: Generate a command-line interface to a program
- API Scaffolder: Translate between OpenAPI spec β program
- Code Translator: Translate code from another language to Raku (e.g., Python β Raku)
- SEO Docs: Document the problems the program solves and generate HTML for SEO and ingestion by LLMs
- Git Log Summary: Generate a stand-up report for your next Scrum meeting
- Test Error Summary: Summarize the output of many tests with next steps to fix
- Ticket Subtasks: Generate a set of subtasks required to close a ticket
Merry Christmas, and happy coding with your new guest at the programming table!
π π»β¨