Skip to content

Instantly share code, notes, and snippets.

@hadley
Created July 11, 2025 20:33
Show Gist options
  • Save hadley/77d42f02b49d333e8f7b0ce8a8847073 to your computer and use it in GitHub Desktop.
Save hadley/77d42f02b49d333e8f7b0ce8a8847073 to your computer and use it in GitHub Desktop.

LLM for code generation

Currently three main styles:

  1. Autocomplete

    • e.g. github copilot, windsurf
    • Inline "ghost text" as you type
    • Sometimes amazingly good; often pretty useless
    • Need to train yourself to ignore spurious suggestions
  2. Chat

    • e.g. ChatGPT, Claude, positron assistant
    • Claude best for R code
  3. "Agentic"

    • e.g. claude code, cursor.
    • Has ability to run code and change files
    • Comes up with a plan, iterates, and works away on it
    • Can take a long time; cost a lot of tokens.

LLM pros

  • Amazing for quickly generating 95% demos

    • e.g Shiny app from a hand drawing
    • "Create an data frame containing data about X"
  • Great at translations:

    • commad line curl -> httr(2)
    • Latex -> Quarto
    • R code -> STAN
    • JSON -> unit tests
  • Very helpful at finding words/algorithms that you don't know about.

  • Don't forget that it doesn't just generate code; it can explain and critique code too.

LLM cons

  • Less good at making incremental changes to large existing codebases

  • Doesn't know about latest package versions. At some level is a weighted average of all code on the internet, so tends to older/more popular idioms rather than modern approaches.

  • Output always looks plausible, but functions and arguments can be hallucinations. You can not (MUST NOT!) blindly trust its output.

  • Gets stuck in local optima in long conversations; start fresh sessions frequently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment