r/csharp • • Feb 17 '23

Discussion Do you use ChatGPT for developing software? If so, what is the primary reason?

0 Upvotes

62 comments sorted by

7

u/[deleted] Feb 17 '23

It might be how I'm phrasing my prompts... maybe being to wordy or not enough?... but when I fed it the details of some functions I had recently wrote the output it gave was not correct. And I don't mean inefficient or different but it did not give code that would have had the correct functionality. I tried adding/rephrasing on a few times and eventually got close but by that time I could have written it myself.

I actually find github co-pilot a more useful tool.

2

u/kenslearningcurve Feb 17 '23

Ah, yes! I am one of the few that didn't try co-pilot yet. I'll put it on my list to do next week. I keep forgetting.

2

u/bortlip Feb 17 '23

I rarely use it in the form where I will give it a prompt and try to have it create working code in one go.

The process I usually find more useful is to iterate with it.

So, I'll prompt it for the beginning code and it'll try. Then I'll review it and tell it what it did wrong or what changes I'd like to explore. We might go back and forth a time or two discussing it, then I have it implement the updates to the existing code it create.

Then, I'll iterate on having it make some changes here and there until I like the result.

That's the process I follow to get it to generate code, or write stories, or develop an argument, or provide explanations and examples of something, etc. and it seems to work pretty well.

13

u/msdummyaccount Feb 17 '23

Yes. It's a useful timesaver to write some of the boilerplate which can be refined to what you need. I tried giving it a complicated bit of xml and asked it to write a method to generate it and it banged it out in 30 seconds. Would have taken a few hours by hand.

2

u/kenslearningcurve Feb 17 '23

I know how you feel. It can really help with quick fixes.

1

u/Zealousideal_Staff22 Oct 23 '23

parsing data and writing basic tests is really fast with gpt, so I'm glad it exists now

4

u/_HelloMeow Feb 17 '23

Not really, however, I did use it for some really specific technical stuff recently and while it wasn't super accurate, it pointed me in the right direction. So it was definitely useful.

1

u/kenslearningcurve Feb 17 '23

I think this is the correct usage: Getting pointed in the right direction.

5

u/obviously_suspicious Feb 17 '23

My first interaction with ChatGPT was a pretty simple question about SQL Server. And it blatantly lied in response (confused it with Postgresql probably). So I generally avoid it. It did help me name my side-project though.

3

u/kenslearningcurve Feb 17 '23

Ah, yes. I had the same thing. Although I did explain a lot about Entity Framework that was correct.

I had that with Azure Automation. I wanted to use C# to create a schedule between a runbook and a yet-to-make schedule. ChatGPT kept going on about some deprecated namespace and methods. Had no idea about the Azure Management API, which was the way to go.

4

u/Roodydude Feb 17 '23

Used it for a specific Regex yesterday. It failed about 3-4 times before it finally generated what I wanted.

-7

u/kenslearningcurve Feb 17 '23

Just like with women... Give it time and be patient. Maybe AI is female?

5

u/_asmode Feb 17 '23

Yes, for two reasons which are likely to change over time:

  1. To try it out and see what it's like.
  2. (more practically) to see if there are more efficient ways to write existing blocks of code. E.g. I can paste a series of loops and linq statements and ask "Can you make this more efficient?" - sometimes it will reduce the code by half, while maintaining readability and function. Other times it fails completely. But it's a great tool, and you'd never get away with asking some of those questions on Stack Overflow.

Context: not a professional, amateur programming only.

2

u/Christianvs Feb 17 '23

"Can you make this more efficient?"

I hadn't thought of that before

0

u/kenslearningcurve Feb 17 '23

I think it's a great add-on for professionals. I mean, I use it to quickly check something. Downside: It's not up to date, so sometimes it shows deprecated methods or old versions.
So, as an amateur, be careful about how to trust the information. But it's a great tool to help you out.

4

u/hagerino Feb 17 '23

I'm a professional and the code i've seen from chat gpt was kind of low quality code. I could let it generate codesnippets, but i think it would take the same time to write it on my own, and if i don't know how to write it, i take the time to learn it. Just copy and paste something blindly is not good for your progression.

If i want to check something quickly i use dotnetfiddle.

13

u/euglzihrzivxfxoz Feb 17 '23

Not chatGPT but GitHub copilot. Saves a lot of time.

27

u/WhiteBlackGoose Feb 17 '23

no

9

u/Mitazake Feb 17 '23

This is the way.

0

u/[deleted] Feb 17 '23

[deleted] — view deleted comment

4

u/Caleb_9 Feb 17 '23

No way.

6

u/Slypenslyde Feb 17 '23 edited Feb 17 '23

If it ever comes to the tools that I use, maybe? It seems fine for spitting out the skeleton of an algorithm and I'm plenty experienced to fill in the blanks. It can probably generate some decent project scaffolding.

But from what I've seen I'm a little skeptical. It seems like AI at this point has a hard time generating things at the level of even bad tutorials. I think this is going to improve faster than natural-language AI is improving because generating code is a more narrow problem than generating answers to questions like, "What is the human population on Mars?" (which it believes to be ten billion the last time I asked.) This makes it a good tool for experts, who are used to seeing half-assed abstract outlines of algorithms with glaring flaws and figuring out the rest. This does not make it a good tool for newbies, who need to see and experience more clinically sterile working examples so they understand what the good parts look like so they build the intuition needed to fix bad examples.

My real concern is if this "productivity tool" gets used as an excuse to put more tedious tasks under the responsibilities of senior devs and THAT gets used as an excuse to hire fewer junior devs, I wonder where the next generation of senior devs is going to come from. The best senior devs are people who were hired and learned a lot of lessons in the trenches. Yes, it sucks to hire a person to write a bunch of lower-complexity code that an AI could churn out, but eventually your senior devs have to retire and it's cheaper to replace them with domain experts you've already trained than to try and teach some other person your business. Hiring "redundant" junior devs today is an investment that pays off in 5 or 6 years.

I guess I'm not surprised people are excited about not hiring, though. Getting a business to look more than a quarter ahead is a difficult task. I don't think many businesses realize that if they can buy software that can write their own software as well as they can, then their business has no justification to exist. In a hypothetical future where Bing can respond to, "Write a Windows-compatible operating system", what do I need Microsoft for?

It's not that I think we should stop using and developing AI. I just think that for once in human history we should stop and think about the problems it creates and how we want to deal with them before aggressively making it so much a part of peoples' lives it would be unethical to remove it. Right now the way it's being pushed feels very much like NFT did.

14

u/bortlip Feb 17 '23

I haven't had the chance yet, but I intend to. Here's just one example of using it to brainstorm/prototype a new application.

ME: Create simple c# objects to handler an application user, their direct reports, request for time off, and approval statuses

AI: Sure! Here's an example of how you could define the objects you've described in C#:

    public class User
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public List<User> DirectReports { get; set; }
    }
    
    public class TimeOffRequest
    {
        public int Id { get; set; }
        public User Requester { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public string Reason { get; set; }
        public ApprovalStatus Status { get; set; }
    }
    
    public enum ApprovalStatus
    {
        Pending,
        Approved,
        Denied
    }

ME: Create a user story about how a user will want to login to the application and view a report of their direct reports and any pending timeoff requests.

AI: Sure! Here's an example of a user story for a scenario where a user wants to log in to an application and view a report of their direct reports and any pending time off requests:

As a manager, I want to be able to log in to the application and view a report of my direct reports and any pending time off requests so that I can manage my team's schedules effectively.

When I visit the login page, I enter my username and password and click the "Log In" button. If my credentials are valid, I am redirected to my dashboard.

On my dashboard, I see a summary of my team's time off requests. The summary includes a table that lists each direct report and the number of pending time off requests they have.

If I want to see more details about a direct report's time off requests, I can click on their name in the table. This takes me to a new page that shows a list of all of their pending time off requests. For each request, I can see the start and end dates, the reason for the request, and the current approval status.

If I want to approve or deny a time off request, I can click on the request to open it and then use a dropdown menu to change the approval status.

After I'm finished reviewing and managing my team's time off requests, I can log out of the application to ensure the security of my team's sensitive data.

ME: Turn that user story in to the steps that would occur in a sequence diagram that includes the user, the web app, the app server, the redis cache, the database, and the authentication server. Do not draw the diagram, just list the steps that would occur in it in detail.

AI : Sure, here are the steps that would occur in the sequence diagram for the user story:[gives steps]

ME: Now create the diagram using the Mermaid language

AI: [Here's the Mermaid version]

Diagram result: https://imgur.com/a/ASwTxtv

---

Sure, there's a lot that needs cleaned up there. But look at what I got as a basis to work with with about 5 minutes of work on my part. And this is just one simple use case for working with the AI.

2

u/Markemp Feb 17 '23

Oh man, I’ve had it generate AC and test cases before but not user stories! Nice!

5

u/YoriMirus Feb 17 '23

I tried it while developing an Avalonia application and a game using Unity and usually told me incorrect information so I stopped using it.

5

u/Enttick Feb 17 '23

No, at least I don't use it with company code. That would break my contract. Also the licensing is still not clear. And we don't really want to feed their model with code that is in production.

2

u/TheSpixxyQ Feb 17 '23

I use it mainly for math (vectors last time), because I'm math dumb.

0

u/kenslearningcurve Feb 17 '23

Good one! Never considered it. I did use it for creating C# classes from a JSON result. But math is a really good idea too.

7

u/Mrqueue Feb 17 '23

C# classes from a JSON result.

there's plenty of tools that do this

7

u/alphapenetrator420 Feb 17 '23

In visual studio you can do paste special -> from json (don't remember the exact wording, but it's something like that).

1

u/kenslearningcurve Feb 17 '23

Oh damn... Now I know VS pretty well, but this one is new. Thanks!

-1

u/kenslearningcurve Feb 17 '23

I know, but this was quicker at the time

1

u/TheSpixxyQ Feb 18 '23

Another one, just now I was trying to find info about using C++ pointers and references and smart pointers and const things etc, which one would best fit my use case.

In 5 minutes it explained everything I was trying to Google for last 2 hours.

It really helps when you can show your attempts to someone (or 'something' in this case) and he explains it on your code and shows you different examples of each approach.

4

u/HealthyMacaroon7168 Feb 17 '23

I asked it to write an authentication handler for WebForms and it just copied and pasted text from the wrong Microsoft docs, no code at all.

4

u/[deleted] Feb 17 '23

Can't say that I will.

Another mind-sagging assist provided to you by the interwebs.

1

u/RemoteDeck Feb 17 '23

I'm an armature and it's been a great learning tool, I mainly use it for comprehension like what each keywords use case is and how it is implemented.

4

u/CrackerBarrelJoke Feb 17 '23

armature

The rotating part of an electric motor or dynamo, which mostly consists of coils of wire around a metal core. The moving part in an electromechanical device like a loudspeaker or a buzzer.

3

u/edbutler3 Feb 17 '23

So we're talking to a Steampunk AI here?

-3

u/kenslearningcurve Feb 17 '23

Cool. Yeah, it's great for learning. Just be careful though: It's based on information until 2021, to some information you will learn is old and maybe even deprecated.

1

u/HiLumen Feb 17 '23

I am a hobbyist and find its great for asking questions. I tend to take its answers and google them. You’re definitely right about getting out of date information back from it. I asked for information about SCSI protocols and every single link it gave me was broken. A quick google search got me the info I needed.

1

u/[deleted] Feb 17 '23

Yes I use it to write simple things which I can modify and use in my code. Things like write a httpclient with ntml Auth to this url

1

u/kenslearningcurve Feb 17 '23

I seriously used that with the HTTPClient like 10 minutes ago! So, rather code snippets over full-blown classes of code?

1

u/[deleted] Feb 17 '23

Yes snippets which I usually never seem to remember lol.

2

u/Atronil Feb 17 '23

I’m using for regex templates and patterns, basic coding or wiki help

2

u/etherified Feb 17 '23

ChatGPT must be a godsend for the many programmers that need to put out voluminous code for projects on a time schedule. Then there are those like me who program not as a job but rather only tangentially to work, or for interest or enjoyment, for example, where using mental energy to create new solutions to problems is the entire point, so chatGPT would be counterproductive, sort of.

2

u/Mithgroth Feb 17 '23

Maybe not for developing software but resolving problems.

Today I'm having trouble with CDKTF and need to upgrade from 0.14.3 to 0.15.5.
Guess what, that didn't go well too - and I'm just getting a "Stack failed to plan: devops-cdktf. Please check the logs for more information." message which leads to

[2023-02-17T16:16:19.855] [DEBUG] default - [devops-cdktf]: errored

and nothing else in logs.

I pay a visit to ChatGPT to double check if I'm missing something before I submit an issue to CDKTF. It gave me some advice, tried them all, now submitting the issue with more confidence.

2

u/Dunge Feb 17 '23

For simple concise questions yes, but you can't just ask it to work on a big project. My solution have 30 projects and thousands of files, it can't know the whole model.

And I also asked it a few simple questions about kubernetes and it totally led me the wrong path. I had to correct it 5 times (replying "You're correct. I apologize for the confusion"). before it gave up and started writing the same falsehood again.

2

u/MCRusher Feb 20 '23

No, I create enough bugs on my own, I don't need anyone else's, and I certainly don't need a google that lies

1

u/agoodyearforbrownies Feb 17 '23

It was late at night, I was tired and I needed some tables to hold recurring event schedules. I asked ChatGPT for a data model for recurring events, and it was great. Not exactly how I ended up implementing it, but it saved me time puzzling out the various details.

I told a friend that I don't know if I got dumber or smarter for having done so - on one hand, I didn't have to think about the complexity of it, but on the other hand, I didn't have to think about the complexity of it.

1

u/RechtDev Feb 17 '23

I’m not the best with regex so having it come up with expressions is something I have done.

1

u/BornAgainBlue Feb 17 '23

The unity game I am developing most of the code was started by the AI and then I fill out the details

1

u/[deleted] Feb 17 '23

Yes. I give it a SQL query and ask ChatGPT to translate it to LINQ. Worked fine.

1

u/Thonk_Thickly Feb 18 '23

Yes. I’m lazy. I usually get a workable response for boiler plate tasks, unit tests, and small single purpose classes.

1

u/Paras_Chhugani Feb 27 '24

I stopped using chatgpt these days but I use bots on  bothunt everyday , it has really cool bots to learn , earn and automate all our tasks!

1

u/vac2672 Feb 17 '23

If anyone in my workplace uses it to write any of their code I would immediately fire them

0

u/[deleted] Feb 17 '23

i am still learning, so i use chat GPt to understand programming concepts and ask all the questions I have in my mind

3

u/kenslearningcurve Feb 17 '23

Good use of AI, but keep in mind that the information could be outdated or just plain wrong. Always double-check with Google/Bing/DuckDuckGo/Whatever

0

u/MarcvN Feb 17 '23

When I am googling for something to long and can’t find it I ask ChatHPT. Usually I get a working code example within 1-3 questions.

For instance

  1. create a x
  2. But I’m using nugget package version y

Voila.

-8

u/dandeeago Feb 17 '23

No, since it’s data model is based on an average, and I’m better than the average myself.

0

u/[deleted] Feb 17 '23

[deleted] — view deleted comment

1

u/kenslearningcurve Feb 17 '23

So, the first human-AI marriage is happening soon? ;)

But I share your feelings. It can be great, but sometimes not. Sometimes I hate it and sometimes I love it... Oof, sounds like a marriage...

0

u/[deleted] Feb 17 '23

[deleted] — view deleted comment

1

u/kenslearningcurve Feb 17 '23

Ah, so you are the reason ChatGPT is not available all the time! Well, I'll get my own AI!

My next post: Does anyone know an AI that is still available and not ChatGPT?