Magic playlist github

GitHub Copilot took the web by storm a couple days ago. The "AI pair programmer" had some fancy gifs to accompany the announcement. It will help write code faster and will let you write less.

Copilot draws context from your comments and your code to infer what code you'll want to write next. In this way, the more you feed Copilot with your comments and your naming of functions will increase the relevance of your recommended code.

During testing, Copilot got function code right 43% of the time on first try and 57% of the time when given 10 attempts. Inspiring, but also terrifying for us coders .

It looked like absolute magic and after trying it out for a few days, I'm happy to announce; GitHub Copilot really is magic.

GitHub Copilot Home Page

GitHub Copilot works by using OpenAI, the AI tool and feeding it public GitHub repos. OpenAI reads through all the code on those repos and is able to learn and suggest code [even whole functions].

I wish I could say jump into your VS Code and install the GitHub Copilot extension. Since GitHub Copilot is in closed preview right now, you'll have to apply for access and wait.

For this article, I'll be providing some screenshots of Copilot in action. Here's a quick example of trying to type in a function named pickRandom:

GitHub Copilot Autocompleting pickRandom[]

GitHub Copilot is able to recommend an entire function for picking a random item from an array. GitHub recommends using Copilot with small contained functions like the above and will read your comments, variables, and function names to recommend the best code.

It's like StackOverflow autocomplete right in VS Code.

Let's go through some more Copilot suggestions.

GitHub Copilot Autocompleting calculateDaysBetween[]
GitHub Copilot Autocompleting createColor[]

This one was interesting. It even knew what API call to use from Twitter. Too bad it used XMLHttpRequest and not something like JavaScript's fetch.

GitHub Copilot Giving the Twitter API
GitHub Copilot Reading Comments
GitHub Copilot Completing Multiple Lines
GitHub Copilot Square Root

You can cycle through the code completions using the keyboard shortcut ctrl + enter.

There is also a little command palette to cycle through suggestions that appears on hover.

GitHub Copilot Choosing Suggestion

If you press ctrl + enter Copilot will open up a 2nd pane and give a UI for picking the correct suggestion. This is nicer so you don't have to keep shuffling through the suggestions inline.

Opening GitHub Copilot Panel

It doesn't just write the supported code like JavaScript, TypeScript, Python, and Go. It also writes copy and can complete sentences like Copy.ai or Peppertype.ai.

GitHub Copilot Writing Copy

A lot of the questions that has come up since Copilot was announced is around privacy and copyrights. The Copilot FAQ does a great job at talking about this and saying that the team is open to considerations and in working together to guide how the project moves going forward.

GitHub Copilot is code synthesizer, not a search engine. The majority of code it generates is uniquely generated and only 0.1% of code generated has been seen verbatim before.

You own and have all the rights to the code that Copilot generates for you.

GitHub Copilot is a promising look at what AI can do to help us as coders. I know there's a lot of talk about AI replacing coders. I see AI helping coders get to providing real value to customers faster.

Copilot truly feels like having a pair programmer next to you. It's like you have a friend searching StackOverflow and suggesting code to you. I don't think it'll take our jobs any time soon.

There's still a gap between writing a few functions and piecing together a whole app that provides value to a customer.

We as the coders determine what our goals are and who we want to help. Copilot will do what it does best; help create and code our goals... I hope. I could be wrong and Copilot could take over everything ‍️.

Video liên quan

Chủ Đề