News for hackers. Stuff that matters.
Re:I'm puzzled how anyone trusts ChatGPT for code by delichon on Wednesday May 08, 2024 @05:09PM (#40302729)
I'm puzzled why anyone would incorporate code on trust. I certainly don't trust LLMs for code, but I use code from LLMs on most work days ... not because I trust it, but because I understand it and tested it. So, the same as code from anyone, including from myself six months ago. Trust doesn't enter into it. Clear and workable solutions do, and I've gotten an impressive number of those.
Re:I'm puzzled how anyone trusts ChatGPT for code by gordon_freeman on Wednesday May 08, 2024 @05:36PM (#40302925)
yes. LLMs are great at giving a template or code block for specific usecase and then I use it after understanding, modifying (if needed) and testing it. I am not sure about ChatGPT but Gemini Advanced even allows modifying code and running it within the answer itself which is convenient to test out minor changes.

Also, getting template of 100s of LOC saves time in writing it from scratch even if I know exactly what I'd need to write.

Re:I'm puzzled how anyone trusts ChatGPT for code by chrisjj on Thursday May 09, 2024 @08:08AM (#40307350)
> LLMs are great at giving a template or code block for specific use case and then I use it after understanding,

I suspect the typical ChatGPT user is using it for code that's beyond his ability to write. That being the whole point of his using it.

It follows that such code is likely beyond his ability to understand. But worse, beyond his ability to understand he doesn't understand it.

Re:I'm puzzled how anyone trusts ChatGPT for code by Brian_K_White on Thursday May 09, 2024 @12:06PM (#40309614)
I can read and modify all kinds of code I couldn't write in the first place.

I haven't used any llm for code yet but most code I ever touched was mostly written by others, and I wouldn't have been able to write it from scratch, but was able to modify it, take only chunks out of the whole to use for something else, take only the structure and not the verbatim code and use in some other language, refactor to satisfy my own priorities vs the original, get useful results in languages I don't even know, etc etc.

It doesn't seem like using some pattern-matched uber-autocorrect code would be much different, especially once you understand that understandingless nature of what your getting.

Re:I'm puzzled how anyone trusts ChatGPT for code by repelsteeltje on Thursday May 09, 2024 @12:24PM (#40309836)
> Also, getting template of 100s of LOC saves time in writing it from scratch even if I know exactly what I'd need to write.

I rarely know exactly what I need to write and writing it usually isn't the problem. Sans LLM, there have always been tools and techniques you can lean on, like syntax highlighting, auto completion, your compiler feedback, or unit tests.

I find that writing code consumes only a small percentage of my time. And while writing code is obviously where bugs originate, it's not where the big problems come from.

Making software good is the easy part, making the right software is where the trouble lies. It's why I spend most time not coding, but talking to people. Figuring out what needs to be done, how, when and why.

Re:I'm puzzled how anyone trusts ChatGPT for code by GenerocUsername on Wednesday May 08, 2024 @05:18PM (#40302802)
Agree. The snippets from ChatGPT are essentially open-source as in they are fully inspectable and can be freely modified before execution. There is zero trust required.
Re:I'm puzzled how anyone trusts ChatGPT for code by fassssst on Wednesday May 08, 2024 @05:32PM (#40302894)
Right, hopefully no one is sprinkling eval(prompt) into their codebase.
Re:I'm puzzled how anyone trusts ChatGPT for code by 1f60c on Wednesday May 08, 2024 @05:41PM (#40302980)
I had an idea about that the other day!

What if you could write something like:

  @implement_this
  def prime_sieve(n: int) -> list[int]:
    pass
And the decorator reads the function name and optional docstring, runs it through an LLM and replaces the function with one implementing the desired behavior (hopefully correctly). I remember there was something like this for StackOverflow.
Re:I'm puzzled how anyone trusts ChatGPT for code by matsemann on Wednesday May 08, 2024 @05:58PM (#40303125)
I made that as a joke in javascript 8 years ago. Not using LLM, but using javascript proxies so that if a function doesn't exist it tries to implement it runtime based on the name of the function using a sql like grammar. I really hope to not see something like that in real use, heh.

https://github.com/Matsemann/Declaraoids

Maybe I should make a LLM version of this.

Re:I'm puzzled how anyone trusts ChatGPT for code by LegionMammal978 on Wednesday May 08, 2024 @06:15PM (#40303274)
The funny part is, Spring Data JPA has a quite serious take on this, in the form of query methods [0]. You create a repository interface with certain method names, and it dynamically creates an implementation that queries the columns of the underlying table, according to the name of the method.

[0] https://docs.spring.io/spring-data/jpa/reference/jpa/query-m...

Re:I'm puzzled how anyone trusts ChatGPT for code by adhamsalama on Wednesday May 08, 2024 @05:53PM (#40303068)
Re:I'm puzzled how anyone trusts ChatGPT for code by Nodejsmith on Wednesday May 08, 2024 @09:41PM (#40304465)
I've never tried it myself, but Prefect does have something like this with their Marvin AI library for Python.

https://github.com/PrefectHQ/marvin?tab=readme-ov-file#-buil...

Re:I'm puzzled how anyone trusts ChatGPT for code by jackmpcollins on Thursday May 09, 2024 @03:08AM (#40305979)
I'm building magentic https://github.com/jackmpcollins/magentic which has basically this syntax, though it queries the LLM to generate the answer rather than writing + running code.

  from magentic import prompt
  from pydantic import BaseModel
  
  class Superhero(BaseModel):
      name: str
      age: int
      power: str
      enemies: list[str]
  
  @prompt("Create a Superhero named {name}.")
  def create_superhero(name: str) -> Superhero: ...

I do have plans to also solve the case you're talking about of generating code once and executing that each time.
Re:I'm puzzled how anyone trusts ChatGPT for code by bschmidt1 on Wednesday May 08, 2024 @05:49PM (#40303042)
Not gonna lie... llama.cpp... LlamaIndex... Ollama... kinda is eval(prompt) a lot of the time!

Of course AI data pipelines are a totally different conversation than code solutions.

Re:I'm puzzled how anyone trusts ChatGPT for code by yevlasenko on Wednesday May 08, 2024 @05:16PM (#40302793)
I would back this one up as well. The code I generate in chat gpt is rather "dumb" (mostly react components, nestjs modules, etc) and in this case I trust myself to test and use it.
Re:I'm puzzled how anyone trusts ChatGPT for code by argc on Wednesday May 08, 2024 @05:24PM (#40302847)
Yeah, to use it effectively you use it for inspiration and generation of template code. The code may need a lot of changes or may need relatively few. But don't copy it expecting it to work without validating and testing it.
Re:I'm puzzled how anyone trusts ChatGPT for code by 2OEH8eoCRo0 on Wednesday May 08, 2024 @05:43PM (#40302993)
So you've audited all code that you're running on your system?
Re:I'm puzzled how anyone trusts ChatGPT for code by burnte on Wednesday May 08, 2024 @05:42PM (#40302983)
> I'm puzzled why anyone would incorporate code on trust.

Really? You can't understand why people do things based on trust? Do you trust no one?

Re:I'm puzzled how anyone trusts ChatGPT for code by simonw on Wednesday May 08, 2024 @07:40PM (#40303840)
Trust but verify. Code review exists because even the best developers make mistakes.
Re:I'm puzzled how anyone trusts ChatGPT for code by burnte on Thursday May 09, 2024 @12:29PM (#40309891)
I totally agree, but let's say Jane writes the code, Frank reviews the code and checks it in. You're trusting both of them. Trust can't be eliminated.
Re:I'm puzzled how anyone trusts ChatGPT for code by chrisjj on Thursday May 09, 2024 @08:02AM (#40307300)
> I'm puzzled why anyone would incorporate code on trust.

Because almost every programmer these days has learned by a route that relies on incorporating code on trust. E.g. using someone else's compiler.

> I use code from LLMs on most work days ... not because I trust it, but because I understand it and tested it.

The snag there is that one can rarely verify test coverage is sufficient.

> the same as code from anyone, including from myself six months ago.

But it is not the same. ChatGPT delivers completely untested code. Not even syntax-checked in my case. Would you accept such code from any human?

> Trust doesn't enter into it. Clear and workable solutions do

Plenty of clear and workable solutions are discovered unsafe. I suspect that's much more likely when the code comes from a source such as ChatGPT that delivers code in a completely untested state.

Re:I'm puzzled how anyone trusts ChatGPT for code by Brian_K_White on Thursday May 09, 2024 @12:12PM (#40309693)
Syntactically incorrect code is not much different than an outline or pseudocode.

There are way too countless many stories of people successfully accomplishing tasks by getting an llm to give them a starting point or outline or even a complete solution that only needed a few fixups, hardly any different from debugging your own first draft, to say it doesn't or can't work. That's already sailed.

The fact that it doesn't produce finished correct code, or even appropriate outline for every single case, doesn't seem especially remarkable or damning to me. It is what it is, it's not what it's not.

Re:I'm puzzled how anyone trusts ChatGPT for code by dllthomas on Thursday May 09, 2024 @12:16PM (#40309754)
> hardly any different from debugging your own first draft

I find this take surprising. Leaving AI aside entirely, debugging my first draft seems very different than debugging your first draft.

Re:I'm puzzled how anyone trusts ChatGPT for code by Brian_K_White on Thursday May 09, 2024 @12:35PM (#40309968)
I often don't know what's wrong with my broken code. I only know what I want, not exactly in what way I failed to produce it. I have to debug to figure that out.

I grant, maybe that is still quite different.

There is something extra to grasp the theory behind someone else's code sometimes.

Re:I'm puzzled how anyone trusts ChatGPT for code by zouhair on Thursday May 09, 2024 @09:05PM (#40314561)
I am no programmer and I love how chatgpt can explain a bash script to me line by line, makes reading those way easier and more enjoyable.