[HN Gopher] Maccarone: AI-managed code blocks in Python
       ___________________________________________________________________
        
       Maccarone: AI-managed code blocks in Python
        
       Author : silverthorn
       Score  : 55 points
       Date   : 2023-08-24 21:02 UTC (1 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | Nullabillity wrote:
       | "Hallucination isn't a real problem, people will always
       | scrutinize the generated code!"
       | 
       | Sigh...
        
       | skybrian wrote:
       | Assuming you're using source control properly and read the diff
       | before running it, I guess this is one way to make sure that a
       | comment matches the code? If the bot changes it, maybe your
       | comment wasn't clear enough?
        
       | panarky wrote:
       | It's so awesome to learn a new term like "macaronic language".
       | 
       | https://en.wikipedia.org/wiki/Macaronic_language
       | 
       | I finally have the right term to describe the warning signs from
       | 1960's-era mainframes that coined "blinkenlichten".
       | 
       | https://en.wikipedia.org/wiki/Blinkenlights
       | 
       | There should be a German term for this, but "gefalschter
       | deutscher" doesn't quite capture it.
        
       | verdverm wrote:
       | Would python decorators be better for something like this?
       | 
       | I always get squeamish when I see magic comments
        
         | malux85 wrote:
         | Decorators are a runtime construct, this is a code-writing-time
         | feature, wouldn't it be confusing to have Maccarone find the
         | decorators at write-time that then did nothing at runtime?
        
           | uranusjr wrote:
           | There are examples of decorators having no runtime effects,
           | such as typing.overload. Bit comments are probably more
           | flexible here since it allows arbitrary blocks, not just
           | function/class scopes.
        
             | orf wrote:
             | How would not having the source code be present/pre-
             | generated, and thus needing to generate it at runtime, be
             | an example of a decorator having no runtime effects?
        
               | nkrumm wrote:
               | I had the urge to try this out a while back, here's what
               | I came up with: https://gist.github.com/nkrumm/2b154ea204
               | 1511233079222373c83...
               | 
               | The decorator invokes AI completion only the first time
               | the function is run.
               | 
               | edit: I lost interest before I was able to get arguments
               | to work -\\_(tsu)_/-
        
               | orf wrote:
               | Yea, that's cool and very possible, but it's a runtime
               | effect
        
         | alexeldeib wrote:
         | I guess comments provide a simple paradigm for many languages
        
           | verdverm wrote:
           | comments are in most languages, so I can see that angle, but
           | you still have to be able to parse all supported languages,
           | no small feat
           | 
           | you can alternatively split generated code from human written
           | code with files, keep the mapping in something more
           | structured like a config file
           | 
           | I just normally see a better way to do the same thing a magic
           | comment does, generally speaking. There is typically a better
           | language construct if you limit yourself to that language
           | (most common), and config files offer much more structure
           | with existing tooling (mostly decode in your preferred
           | language)
        
         | skybrian wrote:
         | This is leaving a comment for another programmer, not the
         | compiler or interpreter. It's what comments are for, actually,
         | like writing a TODO.
         | 
         | You should be squeamish about running the code without reading
         | it first, given that you're pair-programming with a bot.
        
         | rbdixon wrote:
         | Here is a framework which uses decorators to delegate runtime
         | behavior to an LLM. Not quite what you meant but the closest
         | I've seen.
         | 
         | https://askmarvin.ai/components/ai_function/
        
       | anotherpaulg wrote:
       | Very cool project. How reliable are you finding your prompts?
       | They look like good choices based on my experience prompting
       | GPT-3.5 and 4 for code editing.
       | 
       | FYI, I think my open source tool aider would work out of the box
       | to serve this use case. You would just run:                 aider
       | file.py --msg "implement the comments"
       | 
       | Of course aider works with any popular language, not just python.
       | And it can do a lot of other coding tasks. It's like pair
       | programming with an AI.
       | 
       | https://github.com/paul-gauthier/aider
        
       ___________________________________________________________________
       (page generated 2023-08-24 23:00 UTC)