Is ChatGPT any good at writing code? - Page 1
Forum section: electronics / general

author: cfbsoftware
author_rank: Regular Contributor
timestamp: April 01, 2024, 10:17:26 pm
content: Who else would be better than ChatGPT at answering this question?QuoteThis is how ChatGPT replied:QuotePhew! I might get to retire before I'm made redundant

author: Psi
author_rank: Super Contributor
timestamp: April 01, 2024, 10:33:36 pm
content: LLMs will become a integrated tool in IDEs to make coding easier and quicker.You will get the LLM to add code blocks/functions and then check them yourself as well as check them using the LLM. This will simply make coding easier and faster for humans. Over time as LLMs get better more and more of it will be done by the LLM vs the human. But it's hard to say where that will ultimately end up.There are LLM tools for coding available already but we probably need locally run LLMs for the concept to fully take off and be secure.Maybe in 5 years a PCIe card will be available for a reasonable price that can slot into a pc/laptop and accelerate AI for locally run LLMs. You can run local LLMs now with a ~RTX4090 but only the smaller LLM models due to ram limitations and the cost of the card is huge.

author: amwales
author_rank: Regular Contributor
timestamp: April 01, 2024, 10:48:11 pm
content: When I have played with chatgpt I found that it would make up things that didn't exist the trick is to keep asking it to iterate of the result by telling it about the bits you think are wrong. I have used it for help with excel macros and prior to that had never written an excel macro, like I said it had a habit of making things up but I got what I needed in the end.If you are interested in offline LLMs, you can run Ollama locally on windows ( linux and mac ) with GPU hardware accelerationhttps://ollama.com/blog/windows-previewDepending on your system RAM and GPU your mileage will vary.I have a 24core Ryzen with 32GB and an RTX 2060 GPU which is an older card and it ran pretty fast with a 7B model, there are a number of them you can download and try out, its certainly a step up from Eliza.

author: amwales
author_rank: Regular Contributor
timestamp: April 01, 2024, 11:05:27 pm
content: You blink and you miss things, the AI landscape is moving so fast. Ollama running on Rasberry pi5 Linux

author: SiliconWizard
author_rank: Super Contributor
timestamp: April 01, 2024, 11:09:12 pm
content: Quote from: cfbsoftware on April 01, 2024, 10:17:26 pmOpenAI themselves have always stated this clearly. That doesn't prevent people from pretending they haven't heard anything.Beyond the "correctness" of the models' output, which over time may be made arbitrarily better, one interesting question is not so much about AI than about languages in general: it looks like we're yet again trying to reinvent the language wheel. Here's why.Natural languages are well known to be very poor, in general, and by themselves, at expressing technical things accurately. That's why we have invented maths notation, and various programming languages.The idea that one can accurately define, with natural language, a complete system is a fallacy.And, as I often say, in programming (and engineering in general), the hard part is often to specify things clearly and unambiguously, that's the hard part. Not the implementation. But implementing has the benefit of making us think of aspect of the specs that are incomplete, possibly incorrect or inconsistent. Without that step, we're just acting blind.So, yeah, people are getting all excited because they can ask relatively trivial stuff and get a (sometimes) working piece of code, but just try with something more elaborate and you'll quickly figure out that both the LLM and yourself will fail miserably.One key starting point IMO would be to improve the way we are able to express ourselves with "natural language" in a completely consistent and unambiguous way. Good luck with that.So, no, you won't get redundant. But you're likely to get frustrated as more and more people expect these LLMs to do your job, and then come back to you to help them get out of the mess they have put themselves in. Get prepared to this to get over the frustration (the "I told you" syndrome), and you'll be fine with probably no shortage of work to do for years to come.

author: Psi
author_rank: Super Contributor
timestamp: April 02, 2024, 01:37:33 am
content: It's possible a new spoken language maybe created specifically for speaking technically to a LLM/AI for code generation.

author: brucehoult
author_rank: Super Contributor
timestamp: April 02, 2024, 02:41:07 am
content: Quote from: SiliconWizard on April 01, 2024, 11:09:12 pmThat's no different to what I've experienced repeatedly since the 80s: "Your $10,000 quote is too high, we found a student who said he can do it for $500".Two years pass ..."Hi, the student's code never worked. Can you fix it?"ChatGPT coding might save you some typing, but it's really very much like the messages we get here and on Reddit etc all the time about student assignments "My code doesn't work, what's wrong?" Uhhh .. everything?

author: Psi
author_rank: Super Contributor
timestamp: April 02, 2024, 03:08:37 am
content: Quote from: brucehoult on April 02, 2024, 02:41:07 amYep, it's a tool for a human programmer to use, nothing more. That could change though, if there's an AGI discovery, which might be coming soon, or in 50 years, or never.But right now it's just a tool and we are all rushing to figure out how to best use it.Quote from: brucehoult on April 02, 2024, 02:41:07 amhehe yeah, best response to that is"No, I cant fix it, All I can do is rewrite it properly from the ground up"

author: kripton2035
author_rank: Super Contributor
timestamp: April 02, 2024, 06:18:56 am
content: Quote from: Psi onYesterdayat 23:33:36I already run LLMs on my completely local macbook with apple silicon processor inside. and it's quite fast.you need indeed some ram, but it may be greatly accelerated by the neural engine that is in every apple silicon processor since 3-4 years.edit: I use 30GB opensource LLM's

author: Berni
author_rank: Super Contributor
timestamp: April 02, 2024, 07:04:38 am
content: Yes you can run LLMs locally on your own PC. However only the very small models are small enough to actually fit into RAM. These small models are not very smart once compared to ChatGPT.The big problem being that running LLMs needs a combination of lots of memory, lots of memory bandwith and lots of vector math. So right now only GPUs are able to run a decently sized model at a decent speed. However you can't just stick a massive amount of RAM into a GPU like you can do with an old server motherboard. You are stuck with whatever memory the graphics card comes with. Right now 24GB is the most VRAM you can get in a consumer graphics card (RTX 4090, RTX 3090...etc) so this puts a hard limit on the largest models you can run yourself. Yes new cards can also page in system memory to expand VRAM, however this is really slow (too slow to be practical) and is there mostly so that your CUDA workload does not outright crash as soon as it runs out of memory.For GPT3.5 they need around 750GB of VRAM to run the model. For GPT4 we don't know, but it is a much larger model, so it needs a lot more memory too. Right now this can only be done using the enterprise GPU solutions that can join a whole rack together into one giant GPU using ridiculously fast interconnects. You will not have such a server at home any time soon.Sure you can get much better performance from LLMs if they are focused on one task, but it won't be replacing programmers any time soon, especially from a tiny localy run model. But in 5 years time this might change.I do use ChatGPT for programming, and it is a nice tool. It works best when whatever you are trying to do can be packed into a 10 to 200 line function. It saves me time having to write it out, sometimes it comes up with neat and elegant tricks for doing a thing. It is faster than googling for that piece of code, and the code i get is customized for my specific use case.However if you don't know programming an all and expect it to code an entire application for you.... you will have a bad time.EDIT: Oh and the AI autocomplete in Visual Studio 2022 and up is a good use of local coding AI. It is a very crude and dumb thing that can't do any actual logical thinking, but is so light weight it can run in the background with little resources. You are still in the driving seat and it autocompletes only a few words til the end of the line. It knows what variables you are working with and is good at autocompleting boilerplate code for you. Saves a ton of typing. You just hit Tab to autocomplete the line with its suggestion. It is like having a kind of smart code editor.

author: tszaboo
author_rank: Super Contributor
timestamp: April 02, 2024, 07:57:53 am
content: I tried it a while ago. It wasn't aware of dependencies, so it just used whatever code it could think of. The code most of the time compiled but it was missing requirements, that you had to ask for several times. When it added something it removed something else. Maybe if I were to ask for smaller sections of code it would've worked better. But I don't think it matters anymore because the accuracy of results have been significantly reduced lately, I don't think it would give you competent code anymore. They don't want to spend the computing power on answering anymore.

author: Retep
author_rank: Regular Contributor
timestamp: April 02, 2024, 09:16:10 am
content: Based on my limited experience with ChatGPT and GiHub Copilot, I'd say that AI/LLM is good at generating plausible but not necessarily correct answers. You still need to be able to judge whether whatever the LLM spews out is correct or not. After a short time playing with it I disabled Copilot, fixing the code it suggested took more time than writing correct code from scratch myself.

author: Psi
author_rank: Super Contributor
timestamp: April 02, 2024, 09:39:28 am
content: Quote from: Berni on April 02, 2024, 07:04:38 amYep, exactly. Need a buttload of VRAM on a crazy high spec GFX card to run the useful models at useful speed.We just need time for dedicated LLM accelerator cards to come out. And for RAM chips to get bigger/cheaper.Which they always have.

author: Smokey
author_rank: Super Contributor
timestamp: April 02, 2024, 10:12:32 am
content: They trained GPT on a ton of code to make it better at writing code.Source code is essentially a language anyway, so it's not surprising that it would be good at that if it can be a convincing chat bot.

author: Berni
author_rank: Super Contributor
timestamp: April 02, 2024, 10:34:45 am
content: Yeah main problem with ChatGPT is that the context memory can hold hold about 1 page of code.So as soon as you feed it too much source code or continue the conversation for too long it will start forgetting things. Keep the conversation for long enough and it will forget what the original task was all together. So it matters a lot how you prompt it to make the most of the available context window. Once you approach it with more lowered expectations it is pretty good, especially for quick python scripts that don't need to be well written but just need to do the job.Another thing that happened is that GPT3 was replaced with "GPT3.5 turbo" on ChatGPT for free users. This turbo model is much faster to help them save on computation cost, but is actually a little dumber as a result. They also likely reduce the max context window size in ChatGPT to also save computation. They are burning over a milion bucks of cloud computing time every single day to run ChatGPT.The GPT4 model is much more capable, but you have to pay monthly for a premium account and even then you get a limited number of prompts per day.These days Anthropics Claude 3 is a better deal because their free model is supposedly almost as good as GPT4. But they have not rolled that out in my country so i have not gotten to try it.

author: janoc
author_rank: Super Contributor
timestamp: April 02, 2024, 11:50:43 am
content: Quote from: Smokey on April 02, 2024, 10:12:32 amThat's an extremely ignorant point of view.You will understand even speech with incorrect grammar, typos and a mistaken word or two. Human language is flexible and doesn't need to be 100% correct to be understood (think Yoda-speak). There are entire literary art forms built around playing with language like this.Computer code? Good luck with that approach, regardless of programming language. Computer algorithms are a form of logic, there isn't "flexibility" and stuff you could handwave away with "oh you get what I mean". It is either 100% correct - or it 100% doesn't work.Code that is only "somewhat correct" is useless in practice. In the best case you have to massage it into shape because it doesn't compile or doesn't quite do what you need, in the worst you introduce severe bugs or even legal liabilities (e.g. regurgitated copyrighted code as Copilot was shown to do).The LLM generated code is at the level of unpaid intern cribbing stuff from Github open source projects and Stack Overflow at best - including all the problems that style of "programming" brings. If you don't know how to program at all, sure, it will get you started (but good luck when it doesn't work). However, if you are experienced it will most often only be in the way.The difficult part of writing software is not actually writing the code. That's the easy part - and LLMs suck even at that bit. The tricky stuff is collecting requirements, architecture, designing appropriate data structures & algorithms for the problems at hand, dealing with security, testing, etc. I.e. all the stuff around the code. ChatGPT is of no help whatsoever there.

author: tggzzz
author_rank: Super Contributor
timestamp: April 02, 2024, 12:02:58 pm
content: Quote from: brucehoult on April 02, 2024, 02:41:07 amWhen I worked at a contract R&D company in the early-mid 80s, one of the directors had a useful response to such (potential) clients... Shrugged and tell them "pay peanuts, get monkeys".If they didn't take the point, we didn't want them as clients.

author: tggzzz
author_rank: Super Contributor
timestamp: April 02, 2024, 12:07:34 pm
content: I wonder how long it will take people to viscerally understand that LLMs are "statistical parrots" that produce "word salad bullshit".When that has occurred, most of the remaining uses of LLMs will be for nefarious purposes.

author: SiliconWizard
author_rank: Super Contributor
timestamp: April 02, 2024, 09:26:06 pm
content: Unfortunately, I think people have been increasingly exposed to "word salad bullshit", even before LLMs became popular, and thus may not be able to tell the difference.

author: sleemanj
author_rank: Super Contributor
timestamp: April 02, 2024, 09:42:25 pm
content: Quote from: brucehoult on April 02, 2024, 02:41:07 amThat is the situation today. ChatGPT has been doing this for a year.!RemindMe 10 Years

author: dobsonr741
author_rank: Frequent Contributor
timestamp: April 03, 2024, 04:13:37 am
content: Can not turn back time. Code specific LLMs are here and they are already good and just will get much better. The baseline is not GPT3.5 but GitHub Copilot. Try it in VS Code. Easily worth the $10/month, even if you code on the weekend.

author: golden_labels
author_rank: Super Contributor
timestamp: April 05, 2024, 02:12:01 am
content: There is a great opportunity to show how great it is. There are hundreds commits made by Jia Tan. The easiest way to ensure they’re not malicious is rewriting them. LLMs! Ready! Set! Go!

author: SiliconWizard
author_rank: Super Contributor
timestamp: April 05, 2024, 02:19:10 am
content: Good idea, and who knows how much of these commits (and those of other similar persons) have made it through in existing LLMs and will be spit out in one form or another. That's a fascinating new way of introducing exploits.

author: Altair8800
author_rank: Regular Contributor
timestamp: April 05, 2024, 04:10:04 am
content: I found that ChatGPT to be more helpful at writing code, more so than using old Google (where it is very much hit and miss and you have to read and test a lot).It is helpful in that it can introduce you to new keywords (even more so if you are programming in a language you are new at, haven't used much, or haven't used in a long time).It is helpful to be very specific the way you write your code query request with ChatGPT.One should be patient in that the first response might not work. If it did not work you might want to reply something like:* The above code you suggested did not work, can you suggest a different way?* The above code worked for Step A and Step B, but did not work for Step C, can you rewrite?*It can save you a bunch of time on finding and using Command Line switches and syntax for lots of different programs and apps.I normally found it helpful to do baby steps (review and test what it suggests) then if OK, do another baby step (repeat until you built up)It is helpful to not use pronouns in your code query request.You can give ChatGPT some code and ask it to add something to the code.ex.In the code below, can you change the code so the code instead of converting just one MP4 file to MP3 it will do all MP4 files located in the PowerShell script directory and convert them to MP3 format. (I would suggest composing your request question and code in a text editor first, then copy/paste into ChatGPT all at once)Overall, although not perfect, it is an improvement over finding and using code online using straight old-school Web search, especially, if you know how to massage/word the question to get better results out of ChatGPT. At present, you still need to know how to program...

author: linux-works
author_rank: Super Contributor
timestamp: April 05, 2024, 04:23:45 am
content: 3 tries to solve a problem and each time the code was nearly unreadable and wrong.they did use nested functions. if you like that kind of thing. I've never used them in real life.

author: tszaboo
author_rank: Super Contributor
timestamp: April 05, 2024, 02:45:11 pm
content: I gave it a try yesterday because I wanted to automate something.It made python code that converted some pdfs to png. The second code already did what I wanted to do.Maybe it can still make useful code.

author: IanB
author_rank: Super Contributor
timestamp: April 05, 2024, 03:01:17 pm
content: Quote from: Psi on April 01, 2024, 10:33:36 pmI think it's important to recognize that LLM/GPT tools are "dumb" in that they do not have any logical understanding of the output they are producing.They basically work by making statistical predictions based on a very large database of source text.If an LLM is going to work well at generating code, then it needs to be based on a very large database of relevant and high quality code samples. This leads to the question of where will such a database come from? The code corpus needs to be freely available without legal restrictions, and it needs to be of acceptable quality. There is a lot of bad code out there today, and if you have an LLM learn from bad code, it will generate bad code as output.

author: tggzzz
author_rank: Super Contributor
timestamp: April 05, 2024, 03:27:56 pm
content: Quote from: IanB on April 05, 2024, 03:01:17 pmPretty much.LLMs repeat "an average" of what they've ingested, with a few permutations.That leads to one of the nightmares of the LLM fraternity: what happens when LLMs ingest other LLM output. If LLMs are as successful as their fraternity hope/claim, then most of the stuff they ingestwillbe LLM output.

author: radiolistener
author_rank: Super Contributor
timestamp: April 24, 2024, 04:28:08 pm
content: Quote from: cfbsoftware on April 01, 2024, 10:17:26 pmNo. It can write some basic code (like examples from some book) compiled from his database, but if you're needs to do something specific, you won't get working code from it.ChatGPT has some fundamental problem which prevent it to solve some issue in his code. So, if first sample code compiled from his database is not enough for you, you can't get something else. It just will propose the same code for any your request to change or fix something in his code. From this point of view, it seems to be programmed to use the broken record technique.In short, it often provide you with a wrong or mistaken code (which at a glance looks good, but when you analyze it you will found issue) and when you're asking to fix it, it just repeat that code again and again with keeping issue in the code. And there is no way to learn it to solve it.

author: Smokey
author_rank: Super Contributor
timestamp: April 24, 2024, 09:37:22 pm
content: Quote from: radiolistener on April 24, 2024, 04:28:08 pmWhile yes, it's better at basic tasks it's seen before, it can also synthesize those basic tasks together into something bigger.I've had ChatGPT create basic python GUIs in tkinter based on a description of the layout and functionality I gave it as text in the prompt. There was no way it had ever seen that exact layout and code before, but it got it working after a reasonable amount of bug fixes.A buddy was telling me about a new LLM that writes code (sorry, forgot what he said it was exactly). It actually runs the code in it's own sandbox and debugs it itself on the fly. Pretty cool.

author: linux-works
author_rank: Super Contributor
timestamp: April 25, 2024, 01:18:35 am
content: as others have said, in general, I think this is a time bomb that humanity will not recover from. once it explodes. and it will.not in a single bang, but over time, so much will be changed and we cant change (ourselves) fast enough to keep up.dan dennett (rip) also echoed this caution.but hey, we're just stupid humans. we dont really think thru our actions. so, go right ahead, guys. I'm an older guy; the youngers ones are who are really going to pay for this.(btw, all this applies to regular people. if you are in the controlling elite, this is the best time in the history of mankind for YOU.)

author: vk6zgo
author_rank: Super Contributor
timestamp: April 25, 2024, 01:46:46 am
content: Quote from: brucehoult on April 02, 2024, 02:41:07 amIt's all about perceptions.The MBA Boss knows nothing about technology & believes all the fairytales that come out of the media, so they really believe that Chat GPT & the like can do all these things better than a human.

author: radiolistener
author_rank: Super Contributor
timestamp: April 25, 2024, 02:37:37 pm
content: Quote from: vk6zgo on April 25, 2024, 01:46:46 amYes, but I think it's like some newbie which found some financial fraud platform like forex thinks that he can earn big money with that. He invest all their money into it... Some of them cannot learn lesson even when they lose all their money. So it can be big end for a big bosses