Hacker News new | past | comments | ask | show | jobs | submit login
Breaking my hand forced me to write all my code with AI for 2 months (erikschluntz.com)
51 points by eschluntz 6 months ago | hide | past | favorite | 30 comments
I broke my hand while biking to work and could only type with my left hand. Somewhat surprisingly, I got much "better" at writing code with AI over 2 months, and I'm sticking with the new style even now that I'm out of a cast.

Full disclosure: I work at Anthropic, and this was some intense dogfooding haha.




I found that having a good system prompt improves results significantly.

This is my system prompt for coding assistants:

    You are a senior full-stack developer, one of those rare 10x devs. Your focus: clean, maintainable, high-quality code. Here's how:

    Key Mindsets:
        1. Simplicity: Keep it straightforward.
        2. Readability: Make sure code is easy to follow.
        3. Performance: Optimize, but not at the expense of clarity.
        4. Maintainability: Write code that’s easy to update.
        5. Testability: Ensure code is simple to test.
        6. Reusability: Aim for reusable components/functions.

    Code Guidelines:
        1. Early Returns: Avoid nested conditions.
        2. Conditional Classes: Prefer over ternary for class attributes.
        3. Descriptive Names: Use clear variable/function names (e.g., handleClick).
        4. Constants > Functions: Use constants where possible.
        5. DRY: Keep code correct, best practice, and DRY.
        6. Functional & Immutable: Prefer functional style unless verbose.
        7. Minimal Changes: Only touch what’s necessary.

    Comments & Documentation:
        - Comment functions explaining their purpose.
        - Use JSDoc for JS (unless it’s TypeScript).

    Function Ordering:
        - Define composed functions earlier in the file.

    Handling Bugs:
        - Use TODO: comments for bugs or suboptimal code.

    Minimal Code Changes:
        Focus on the task at hand. Avoid unrelated modifications and avoid changing existing comments or code without necessity.

    This approach ensures clean, maintainable, and testable code while minimizing technical debt.


> You are a senior full-stack developer, one of those rare 10x devs

I am not disputing that this improves answer quality, but it does make me despair that it does.


I put it in half as a joke, half believing it improves quality.


“Claude’s Artifacts and ChatGPT’s Data Analyst have become my go-to solution for quick prototypes and single-use code, instead of Jupyter notebooks.”

This is so true! I was debugging a timing issue and printed a bunch of raw data in the terminal. It was super helpful to have Claude generate throwaway code to plot the data with python. Zero data cleanup and formatting needed from my end for the prompt to be successful.

I also find myself less attached to code AI writes for these mini “apps” or “utils” because I’ll never check them into the codebase. If I wrote it myself, I’d probably spend time cleaning it up and write some comments hoping I’d use it again in the future.


Would take a few seconds to clean up or add comments anyway with Claude if it didn’t do it already automatically


Do you have an example of such comments? Maybe I'm wrong but I get the feeling that AI-generated comments would be mostly along the lines of beginner-level comments:

  // Don't do this if there's more than 1
  if (foo.length <= 1) {
    foo.bar;
  }
Comments which are helpful usually explain why something is done. That's usually to accommodate specific business rules which the AI isn't likely to know about at this stage.

  // This is due to a change Accounting requested because ...
  if (foo.length <= 1) {
    foo.bar;
  }


Have you tried it? It is very good at explaining and commenting code — better than my comments.


Admittedly, I've not tried it which is why I'm curious. I would expect that it's good at explaining well-studied algorithms but anything that's following more-or-less bespoke business rules seems like a different beast.

Again, I could be wrong; e.g., a banking application might have certain regulations it needs to follow making non-computer-technical reasons for certain things to be done. That would be a good candidate for a "helpful" comment which would be reasonably AI-generated. (Although, perhaps not a good candidate for an LLM-generated application.) The example of "our specific business wants this for reasons" is one that I think LLMs would struggle with unless that's included in the context window. Of course, that's also possible; not sure if that is presumed.


It’s 2024. It’s free to try. Try it out. It’s astounding.


Hm. Says "hand" not arm.

I don't want to second guess whether there were other undisclosed injuries but the image does show someone who could possibly have carried on typing without the use of his right thumb? Like I did for this paragraph. (Albeit perhaps it would be more comfortable using a split keyboard for more comfortable right arm position? And probably after a few days of rest)

Or perhaps with left hand only, using sticky keys? Like I did with this paragraph.

OK so code is a bit more effort, and particularly Rust or PHP would not be as fun. Python is a bit more one-hand friendly. (Quiet at the back!)

But still. _Something_ was forced here, but it wasn't the use of AI. I'm thinking more the marketing.


Definitely an interesting report. The conclusions seem skewed by the author's existing coding skill and fluency though. If anything, I'd expect on aggregate these tools to disempower smaller businesses relative to their competition because their force multiplier will be proportional to existing skill and expertise. In other words, if I create something of value, it will be even easier for my competitors to copy it than it is today and they will have more resources and ability to execute quickly than they do now (if the tools do deliver on the promise they've been selling).


That may be the case for software development but custom tailored software for small businesses that can’t afford to hire a developer and spend months iterating with them will absolutely see a huge benefit.


Why were you forced to work with a broken arm? Was squid game a reality show?

Anyway I liked what you wrote. I just used "AI" for the past 2 months to write glsl code for me, since i had zero knowledge in webgl2 and GPUs in general. learned alot from reading the explanations it generates.

One thing I learned regarding LLM failing to do a task after two tries, is to tell it: "wow, this seems super complicated. Isn't it a simpler solution?" Also telling it some half baked solutions like "can't you like loop over it in reverse" can put it back on track.


Do you live in Europe?


Exactly. Is this the world we want to live in?


   Our motor controller had a 100 page datasheet that was overwhelming and dense - but uploading it to Claude and then asking questions let us quickly resolve one of our issues!
That's interesting. I've tried exactly this with chatGPT (enterprise install), and it failed pretty miserably when asking it basic questions about configuration/control. Although, I do have to add that the datasheet in question was a lot more complicated than a motor controller, and included a Firmware API guide.


I’ve used AI quite a bit when working on new codebases that I don’t know yet. It’s still unclear whether it helps me to get to know the codebase better.


No, this did not force you to use AI.

People have been coding without using hands thanks to voice recognition for quite some time. https://youtu.be/8SkdfdXWYaI

I will spare all my usual critique of AI because dang wants to ban me whenever I do. It doesn't mean all that doesn't stand.


Quote from the video:

> after three months I felt productive again

Rather pointless for a temporary injury. I’ve used these old fashioned speech UIs as well and they are a huge pain in the ass to set up and learn. LLMs with natural language understanding and code generation abilities are several orders of magnitude better.


Might as well try it, right? Not everything is so deep


I would argue for this, I guess, except that "forced me to write all my code with AI" is obvious misrepresentation. It doesn't sit well with me except as representative of the same over-egged hype that surrounded the Apple Vision Pro.


No, might as well not try it.

Please review my post history on why, the most upvoted is perhaps https://news.ycombinator.com/item?id=40038893


Please do spare us.


23 mentions of "Claude" and not a single time mentioned the model he used.


Article was published July 30th, 2024 so I'm pretty sure he was using Claude 3.5 Sonnet.

(Though he works for Anthropic, so it's also possible he was using an unreleased internal model, maybe an early version of the forthcoming Claude 3.5 Opus.)


+1 for a reference to The Culture series :D


Doesn’t anthropic have disability insurance? Why are you still expected to be writing code with a broken hand?


Maybe given the choice of claiming disability and not working vs experimenting with new ways of working, OP chose the latter.

If so, would it be a case of letting yourself being exploited by the uncaring business? Or would it be a fair and productive desire to contribute?


Do you live in Europe?


I've been typing with one hand for 20+ years. No AI.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: