This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Community Hub.
You've spent years training as a software developer and learned a variety of different skills like:
- breaking down problems
- debugging
- architecting
- specific frameworks, languages and IDEs
and yes communication.
Now you live in 2023 and suddenly your world looks very different, ChatGPT happened and suddenly, over night, everyone is an author and coder and whatever else profession.
As a coder, you've always been an early adopter of tools to make you faster, but with AI, how fast is fast and in what way?
Let's explore some common problems you're likely to do, and let's see what GitHub Copilot is able to do for us:
References
Task - work with console
It's quite common to build apps that only work on the console and print to it and reads user input from it. So let's craft a prompt that does just that:
C# and .NET
If you know C#, you know that nowadays you can type a lot less like so:
So I guess human - AI, 1-0, in this example, even if the win is that my focus moves from cleaning up after AI rather than typing every single key.
Java
What about a similar prompt for Java?
Great, I don't need to look up the APIs, I can now focus on seeing if it works and fix it if needed.
Python
If this was a language comparison you would probably think Python has the least amount of code. However, the point here is more that Copilot is able to produce code even here and it can.
In conclusion
What we've seen so far is that Copilot can deliver on three different languages without breaking a sweat. Lets look at different type of task next.
Task - Making a web request, fetch and store a file
For this one, we wanted to do something a bit more challenging, making a qeb request, fetch google.com's logo and store it. It's not a very hard task but being a developer, you might still need to check the docs for what the APIs are called and how to call them.
So lets see what Copilot can do..
C#
I see Copilot knows what the current URL is, great, I don't need to look that up.
It also helped me by identifying I need to use a class called `WebRequest` (I could have almost guessed the name there).
Also, I see that it helps show me how to construct paths in an OS independent way.
Finally it opens up a file stream, reads a bunch of bytes and my file ends up getting stored. Yea, that's definitely code I would need to look up.
Java
Let's do the same exercise for Java
Seems the above is a similar approach to C#. This is code I don't have to write, or look up.
Python
Ok, for Python then..
Again, Python code is a lot less, but not the point of this article but it would be weird not to point it out. The point is still Copilot and that I save time not having to look up names of libraries, names of classes and functions etc.
Last task - zip a directory
For this final task, we'll look into how to compress a directory.C#
and just like before, it seems to be trained on the "old" way of doing things. Leveraging modern C#, we can write it like so instead (yes human, you are providing value):
Ok, seems like the above could work.
Java
Ok, a few more lines of code but it's probably quite fast when it runs.
Python
Again it looks like a lot less to type with Python
> But I'm just saying this for everyone in the back, the number of code lines don't matter, performance do. In most languages you create abstractions that hides away complexity.
But yes, from an AI standpoint, it was able to deliver even here.
In conclusion
I've shown you three different examples so far, I didn't need to know either Python, Java or C#, or their APIs, to create what I needed. However, to fix it, if something needs fixing, I need to know how and that's where you as a developer comes in.
Summary
As a developer, you might feel a few different things seeing this. For me here's how I react:
- This is the biggest thing since auto complete, I don't want to code without it.
- I'm now a declarative programmer or "prompt engineer", or as a colleague of mine put it, Copilot is a toddler, it's very fast, and I need to control what it does :)
I also have questions like:
- What about refactoring code, can it do that? Great question, I will research that and present the finding in a future article
- Can I finally get rid of Stack Overflow? Maybe, you can definitely have it generate code AND ask it questions, for instance I learned yesterday how to use CMake, it wrote config files, showed me commands etc, all in the IDE.
- How correct is it and is my job now clean up after an AI "clean up in aisle 5"? It looks that way, a little bit at least.
- And maybe the biggest question of all, do I dare use it, or will the legal department stop it? So there's a few things to know here that hopefully answers that questions namely:
- Copilot (or rather Codex) was trained only on publicly accessible code
- If you're using Copilot for Individuals, AND you have the setting that allows us to use your usage to improve the model, we may use information about the request (which will include some code), the suggestions given, and whether you accepted them, and possibly a few other things. We **don't** use that data to retrain the core codex model (which is owned by OpenAI), just improve the way we're making suggestions.
- if you're using Copilot for Business, OR you've turned that setting off, we only use that request to generate a response for you, then we immediately throw it away. In fact it never hits the disk - it's only kept in memory and is garbage collected soon after.
- Copilot builds a context to send to the server and get a response. That context is made up of a bunch of things - like relevant code in open files, maybe some folder structure, metadata about what you'd just written, etc
Read more on the official FAQ page, https://github.com/features/copilot#faq