Daily Productive Sharing 1200 - How to Use LLMs to Code

One helpful tip per day:)

How to use LLMs to assist with programming? Simon Willison shares his experience:

  1. If someone tells you coding with an LLM is easy, they are (perhaps unintentionally) misleading you.
  2. If you expect this technology to perfectly complete your project without any input from your own skills, you'll quickly become disappointed.
  3. Instead, you should think of the LLM as a tool that enhances your capabilities.
  4. My favorite way of thinking about an LLM is as an overly confident pair-programming partner—it rapidly searches for information, provides instant examples, and tirelessly handles mundane tasks.
  5. When using LLMs, you'll frequently discover limitations. Note these down—they're valuable lessons.
  6. I gain enough value from LLMs that, when selecting software libraries, I intentionally consider their popularity and stability, ensuring ample training data examples exist.
  7. Each new conversation resets the LLM's context. This is important, as the best solution when a conversation becomes ineffective is often to reset it entirely.
  8. You can leverage the LLM’s memory of previous responses to make it more useful.
  9. I frequently begin new conversations by pasting existing code, allowing the LLM to use it as context and helping me refine that code.
  10. One of my favorite code-prompting techniques is to first provide several complete examples, then ask the LLM to create a new project inspired by them.
  11. The best way to start any project is to create a prototype first, verifying if the key requirements are achievable.
  12. In a production setting, I use LLMs strictly—I treat them like an intern, carefully instructing them to write code based on detailed instructions.
  13. Good LLMs are excellent at filling in coding gaps and more detail-oriented than I am—they remember to handle exceptions, write accurate docstrings, and provide appropriate type annotations.
  14. If you haven't actually run it, it's not yet a usable system. Develop the habit of manual testing.
  15. A poor initial result isn't a failure—it's a starting point for refining the LLM's output.
  16. There's a new coding approach I call "vibe-based coding"—completely letting the LLM roam freely without being constrained by strict coding practices.
  17. The best way to learn how to use an LLM is through playful experimentation.
  18. LLMs can't replace human intuition and experience.
  19. This is precisely why I value LLM-driven productivity—not simply because it speeds up work, but because it allows me to pursue projects I wouldn't otherwise have the time for, greatly accelerating skill acquisition.
  20. LLMs enable me to execute ideas faster, meaning I can undertake more projects and learn even more.
  21. You can input your code into a long-context model and start asking questions. Currently, the best available option is gemini-2.0-pro-exp-02-05, a preview of Google Gemini 2.0 Pro, which can be accessed for free via API.

If you enjoy today's sharing, why not subscribe

Need a superb CV, please try our CV Consultation


如何使用 LLM 辅助编程?Simon Willison 分享了他的经验:

  1. 如果有人告诉你,用 LLM 编码很简单,那么他们(可能无意间)误导了你。
  2. 如果你认为这项技术能完美实现你的项目,而你无需发挥任何自己的技能,你会很快感到失望。
  3. 相反,你应该将 LLM 作为增强你能力的工具。
  4. 我目前最喜欢的思维模式是,把 LLM 想象成一个过于自信的结对编程助手——它能飞速查找信息,瞬间给出相关示例,并能无怨无悔地执行枯燥的任务。
  5. 在使用 LLM 时,你会发现它有许多做不到的事情。记下这些问题——它们是很有价值的经验教训。
  6. 我从 LLM 获得了足够多的价值,所以在选择代码包时,我会特意考虑它的普及度和稳定性,以确保它有足够多的示例出现在训练数据中。
  7. 每次开启新的对话,LLM 的上下文都会被清零。这一点很重要,因为当对话变得无效时,最好的解决方案通常是清空对话,重新开始。
  8. 你可以利用 LLM 会记住之前回复的特性,使其发挥更大作用。
  9. 我经常在新对话开始时先输入一段现有代码,让 LLM 以此作为上下文,然后和它一起修改代码。
  10. 我最喜欢的代码提示技巧之一是,先提供几个完整的示例,再要求 LLM 以它们为灵感创建一个新项目。
  11. 开始任何项目的最佳方式是先创建一个原型,以验证关键需求是否可以实现。
  12. 在生产环境中,我对 LLM 的使用更加严格——我把它当作实习生,根据我的详细指令编写代码。
  13. 优秀的 LLM 擅长填补代码中的空缺,而且比我更细心——它们会记得捕获异常、添加准确的文档字符串,并为代码提供合适的类型注解。
  14. 如果你没有实际运行它,那它还不能算是一个可用的系统。你需要培养手动测试的习惯。
  15. 一个糟糕的初始结果并不是失败,而是一个调整 LLM 方向的起点。
  16. 现在有一种新的编码方式,我称之为“氛围编码”——完全放任 LLM,自由发挥,不再拘泥于代码本身。
  17. 学习如何使用 LLM 最好的方法就是尽情尝试。
  18. LLM 无法取代人类的直觉和经验。
  19. 这正是我如此看重 LLM 提升生产力的原因:它不仅仅是让工作更快完成,而是让我能推进那些本来无法投入时间的项目。 这也是一个加速学习新技能的好方法。
  20. LLM 让我更快地实现想法,这意味着我可以执行更多的项目,从而学到更多的东西。
  21. 可以把代码输入到一个长上下文的模型中,然后开始提问。 目前最好用的是 gemini-2.0-pro-exp-02-05,它是 Google Gemini 2.0 Pro 的一个预览版,目前可以通过 API 免费使用。

如果你喜欢的话,不妨直接订阅这份电子报 ⬇️