Hacker News new | ask | show | jobs
by Ancapistani 1115 days ago
> AI is being sold as the ultimate tool that will replace artists/programmers/writers/whomever

I see a potential risk here.

This is HN, so let's consider programmers in isolation for a moment. Today, I can issue the following prompt to ChatGPT and get a solution that works:

> Using Python, generate an example unit test that uses monkey patching.

That gives me a runnable, valid example test. I can then ask it to refactor it to use pytest instead of unittest:

> regenerate the above code sample using pytest instead of unittest.

Here's the resultant code:

    # A simple class that we want to test
    class Calculator:
        def add(self, a, b):
            return a + b
    
    
    # Monkey patching the add method to subtract instead
    def mock_add(self, a, b):
        return a - b
    
    
    # Test the monkey patched method
    def test_add_with_monkey_patching():
        # Create an instance of the Calculator class
        calc = Calculator()
    
        # Monkey patch the add method of the Calculator instance
        calc.add = mock_add.__get__(calc, Calculator)
    
        # Test the monkey patched method
        result = calc.add(5, 3)
    
        # Assert that the result is what we expect
        assert result == 2
It _works_, but it completely misses the point. The test case is testing whether or not the monkey patching works as expected - not testing something using monkey patching to isolate a side effect in the method under test, which was my intention.

Here's where I think there is a potential major issue: As someone who is currently a "Senior Staff Software Engineer" and has been doing this sort of work for two decades now, if you had given me the same prompt my first response would have been "use monkey patching to do what?". ChatGPT doesn't do that. Instead, it gives you a response that best fits the question. It includes a half dozen paragraphs explaining the code, what it does, and what monkey patching is, sure... but it doesn't even touch on why you'd want to use monkey patching, when it is or is not the best approach, or any alternatives. In short, ChatGPT lacks the intuition that a human programmer will develop over the course of a career.

It's getting better. A few months ago I could have asked ChatGPT the same question and probably 30% of the time gotten a result that would even run. In the past couple of months I don't think I've run into that at all.

The "intuition" thing is a big deal, though. ChatGPT is a great tool in the hands of a competent engineer who has the experience to examine the output with a critical eye. Today, I could see it replacing a junior engineer in a professional setting. We should not use it in that way.

If we do, in a few years we'll get to the point where the current generation of senior engineers are retiring. If we've replaced the majority of our junior engineers with AI, we'll be left without people who can use the AI-generated results effectively.

There has to be a way to balance the savings represented by these tools (in terms of both time and money) with the fact that the people who are able to most effectively use it today only got to that point because they've spent much of their adult lives developing the exact skillset that we're proposing to replace with them.

2 comments

>If we do, in a few years we'll get to the point where the current generation of senior engineers are retiring. If we've replaced the majority of our junior engineers with AI, we'll be left without people who can use the AI-generated results effectively.

I mean, you might not look at job postings for Jr. Engineers anymore, but they all ask for someone who can lead and mentor teammates less senior than they are so it seems like there won’t be many replacements for senior engineers retiring in the next decade regardless of ai’s existence.

Jr level job requirements in the future "Must have at least 75,000 GPU hours of experience"
I told it that it was a senior engineer and I was a random client and asked the same thing. It explained what monkey patching was for, creates an example where a function pulls from an API and we patch it. Depending on runs or prompts you can see more or less explanation. I like getting it to first reason about its role and task, then it has that in its context when replying.

Have you tried telling it who it is? You're coming at it with context about how it should act without telling it - it can role play a lot of things. I spoke to a teacher dealing with kids doing their homework too well with it, and showed you can just say "write X as a student with middling English" and get realistic mistakes.

I hate that every time someone adds a nuanced view to these discussions, someone comes in to ask if they're "using it right" and asks them if they're typing words right as if that actually stops this thing from hallucinating bullshit all the time.
It's fine to not want to learn to use a tool, but it doesn't really add much to the conversation to get angry about people talking about how to use it.

> as if that actually stops this thing from hallucinating bullshit all the time.

This has nothing to do with hallucinations though. It's about giving something a poorly specified problem and then complaining that it gives a valid answer but doesn't act like a particular persona when that persona was not explained. This is a very general problem with a general approach to fixing it. Want it to challenge you on what you're asking it to do? Tell it that.

He never asked you to explain how to use the tool. You're assuming he doesn't know how to use a tool that requires approximately 10 minutes to learn. It's completely patronizing to ignore his point and continue with "Well have you tried.." in a way that fundamentally does not address the issue he's bringing up at all. Your tips and tricks add nothing to the conversation.
> . You're assuming he doesn't know how to use a tool that requires approximately 10 minutes to learn

That raises the question of why they used it ineffectively in the first place then. They asked it to do something, it did, but they say it misses the point that a senior engineer would spot. My point is that if you want to judge how well it operates in replacing someone you have to actually specify who it's supposed to be imitating. It's not idle speculation, as I said I did this and it worked. Asking it for an example of monkeypatching gave back a proper example, along with a warning about maintainability.

Telling it I was a junior engineer and wanted to use monkeypatching did the same thing. Asking a followup of why I should be so careful with it and what I could do instead it gives explanations about several problems and then a few other approaches. Telling it simply to be a senior and I'm a junior, and that it should come up with followup questions for me it not only explains those problems but gives me the kind of followups a junior should ask but may not know to. Exactly the kind of intuitions about what's going on that are said to be missed here.

So I think the example used is significantly weaker than it appears, and the argument hinges on what GPT4 is lacking.

Now, a very solid response to the problem posed is that if it can approximate a more senior role for discussions it can make junior engineers more effective and teach them those skills.

FYI: I’ve read the whole comment chain under this post before replying

> I told it that it was a senior engineer and I was a random client and asked the same thing.

I’m aware that ChatGPT is capable of performing the task I chose. I agree that it’s a relatively weak example, especially if it was my goal to show that AI can’t do this.

That’s not really what I was trying to show, though. My point is that you knew two things that many/most people probably wouldn’t:

1) That crafting your prompts to get the LLM to adopt a “persona” impacts the results significantly

2) That monkey patching has downsides, and that understanding when it is appropriate is important

I strongly suspect that you knew both of those things because you are a senior engineer yourself. My point is that some level of domain knowledge is necessary to get good results from it; my fear is that one day in the not too distant future, far fewer people will be around with that knowledge, because we’ve slowed the “senior engineer pipeline” down to a trickle through the use of these tools.

I disagree with those points. It brought up that monkey patching has downsides with an explanation, and elaborated when asked what they were.

Here's a relevant paragraph

> That said, it's crucial to understand that monkeypatching can make your tests harder to understand and maintain if used excessively or improperly. When you monkeypatch, you're essentially altering the normal behavior of your code. This can lead to situations where tests pass because of the specific setup in the test and not because the actual code is correct, making it less effective at catching real bugs.

More than that, I could instead tell it at the start to tell me the questions I should ask as followups, here's the list when I told it I think I need to use monkeypatching:

1. When is it appropriate to use monkeypatching and when should I avoid it?

2. What are some common pitfalls or mistakes to avoid when using monkeypatching?

3. Can you give me more examples of how to properly use monkeypatching?

4. Are there any other techniques or tools for mocking or stubbing that I should consider?

I could then just say "answer those". No prompting about assuming downsides or problems.

I agree on point one but it's a very easy lesson to learn - try telling it that it's a pirate. It's also not actually required because someone like me can create the persona prompting and then everyone else can just use it. I'm not subtly crafting a weird prompt, it's just telling it who to be for the most part.

> my fear is that one day in the not too distant future, far fewer people will be around with that knowledge, because we’ve slowed the “senior engineer pipeline” down to a trickle through the use of these tools.

On the other side, what we have here is potentially an infinitely patient, always available mentor. You don't have to crash through mistakes on your own to learn, though some lessons are learned harder because of that.