{"id":2089,"date":"2021-07-22T07:24:55","date_gmt":"2021-07-22T14:24:55","guid":{"rendered":"https:\/\/coderpad.io\/?p=2089"},"modified":"2023-06-05T14:38:53","modified_gmt":"2023-06-05T21:38:53","slug":"github-copilot-breaks-bad-interviews","status":"publish","type":"post","link":"https:\/\/coderpad.io\/blog\/development\/github-copilot-breaks-bad-interviews\/","title":{"rendered":"GitHub Copilot Breaks Bad Interviews"},"content":{"rendered":"\n<p><a href=\"https:\/\/copilot.github.com\/\" target=\"_blank\" rel=\"noopener\">GitHub Copilot<\/a> was recently announced! In the past few years, we\u2019ve seen artificial intelligence (AI) revolutionize aspects of technology such as image recognition, recommendation algorithms, and more. With Copilot, GitHub is hoping to add \u201ccode generation\u201d to that list of items. In this article, we\u2019ll explain what GitHub Copilot is, why some people are concerned with allowing its usage in technical interviews, and how to build your interviews to be better in general and therefore more resilient to auto-generated code.<\/p>\n\n\n<h2 class=\"wp-block-heading\">What is GitHub Copilot?<\/h2>\n\n<p>GitHub Copilot is a VSCode extension that\u2019s able to autocomplete code snippets. While we&#8217;ve had some form of code completion for some time now, they&#8217;ve been relatively limited in one way or another. Usually, they tend to rely on existing code in your files or can only suggest a tiny amount of code per suggestion. Other times, code completion can be no more than a predefined snippet of code without considering any additional context.<\/p>\n\n<p>Copilot offers the ability to suggest multi-line and contextually aware code suggestions &#8211; powered by AI. GitHub says this tool is available for most programming languages and can implement entire functions off of their names alone.<\/p>\n\n<p>They\u2019re not alone in this endeavor, however. GitHub is working in collaboration with OpenAI, the company behind the extremely powerful GPT-3 AI tool. Between the training dataset consisting of GitHub\u2019s public source code and OpenAI\u2019s expertise in AI generation, it has the potential to provide impressive results.<\/p>\n\n<p>Taking an example from their website, it\u2019s able to generate an implementation of a date utility from nothing more than the function name.<\/p>\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"344\" src=\"https:\/\/coderpad.io\/wp-content\/uploads\/2021\/07\/image-1-1024x344.png\" alt=\"\" class=\"wp-image-2104\" srcset=\"https:\/\/coderpad.io\/wp-content\/uploads\/2021\/07\/image-1-1024x344.png 1024w, https:\/\/coderpad.io\/wp-content\/uploads\/2021\/07\/image-1-300x101.png 300w, https:\/\/coderpad.io\/wp-content\/uploads\/2021\/07\/image-1-768x258.png 768w, https:\/\/coderpad.io\/wp-content\/uploads\/2021\/07\/image-1-1536x516.png 1536w, https:\/\/coderpad.io\/wp-content\/uploads\/2021\/07\/image-1.png 1600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n<p>It\u2019s incredible that given the simple input of:<\/p>\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">calculateDaysBetweenDates<\/span>(<span class=\"hljs-params\">date1, date2<\/span>) <\/span>{<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<p>It\u2019s able to generate the following code which functions how you might expect:<\/p>\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">calculateDaysBetweenDates<\/span>(<span class=\"hljs-params\">date1, date2<\/span>) <\/span>{\n  <span class=\"hljs-keyword\">var<\/span> oneDay = <span class=\"hljs-number\">24<\/span> * <span class=\"hljs-number\">60<\/span> * <span class=\"hljs-number\">60<\/span> * <span class=\"hljs-number\">1000<\/span>;\n  <span class=\"hljs-keyword\">var<\/span> date1InMillis = date1.getTime();\n  <span class=\"hljs-keyword\">var<\/span> date2InMillis = date2.getTime();\n  <span class=\"hljs-keyword\">var<\/span> days = <span class=\"hljs-built_in\">Math<\/span>.round(<span class=\"hljs-built_in\">Math<\/span>.abs(date2InMillis - date1InMillis) \/ oneDay);\n  <span class=\"hljs-keyword\">return<\/span> days;\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<p>While every new tech has its naysayers, and even some on our team are skeptical of its true utility, it\u2019s undoubtedly a powerful tool that will, for some, change the way they write code.&nbsp;<\/p>\n\n\n<p>GitHub\u2019s not alone in this venture of AI-powered code generation, either! Other companies, such as <a href=\"https:\/\/www.kite.com\/\" target=\"_blank\" rel=\"noopener\">Kite<\/a> or <a href=\"https:\/\/www.tabnine.com\/\" target=\"_blank\" rel=\"noopener\">TabNine<\/a> are working hard at this problem space as well! Whether we want it to or not, AI-generated code helpers are here to stay.<\/p>\n\n\n<h2 class=\"wp-block-heading\">How does Copilot Threaten Tech Interviews?<\/h2>\n\n\n<p>In the current tech interview landscape, algorithms reign as the leading method of technical assessment. While we\u2019ve touched on <a href=\"https:\/\/coderpad.io\/blog\/interviewing\/5-tips-for-tech-recruiting\/\">why this shouldn\u2019t be the case<\/a> before, Copilot in particular breaks algorithm questions in significant ways by being able to rapidly generate solutions to algorithmic problems.<\/p>\n\n\n<p>Let\u2019s see how Copilot interacts with some common interview questions.<\/p>\n\n<p>One common question that\u2019s a favorite of interviewers hoping to quickly glean mathematical competency is a function to check if a given number is prime or not.<br><br>Well, it\u2019s been a few years since I\u2019ve refreshed my math skills, so they might be a little shakey. I should be able to figure it out all the same.&nbsp;<\/p>\n\n<p>Let\u2019s open VSCode and start implementing the function.<\/p>\n\n\n<figure class=\"wp-block-video\"><video height=\"404\" style=\"aspect-ratio: 928 \/ 404;\" width=\"928\" controls src=\"https:\/\/coderpad.io\/wp-content\/uploads\/2021\/07\/GHCopilotIsPrime.mp4\"><\/video><\/figure>\n\n\n<p>Wow! I hadn\u2019t even had a chance to add the parameters to the \u201cisPrime\u201d function before Copilot had already made a suggestion!<\/p>\n\n<p>Looking through the suggested code, it seems clean and functions as expected!<\/p>\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">isPrime<\/span>(<span class=\"hljs-params\">n<\/span>) <\/span>{\n\u00a0 \u00a0 <span class=\"hljs-keyword\">if<\/span> (n &lt; <span class=\"hljs-number\">2<\/span>) <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">false<\/span>;\n\u00a0 \u00a0 <span class=\"hljs-keyword\">for<\/span> (<span class=\"hljs-keyword\">var<\/span> i = <span class=\"hljs-number\">2<\/span>; i &lt; n; i++) {\n\u00a0 \u00a0 \u00a0 \u00a0 <span class=\"hljs-keyword\">if<\/span> (n % i == <span class=\"hljs-number\">0<\/span>) <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">false<\/span>;\n\u00a0 \u00a0 }\n\u00a0 \u00a0 <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">true<\/span>;\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<p>Sure, we could change the <code>var<\/code> to a <code>const<\/code>, but this is code that I wouldn\u2019t blink twice at in a code review!<\/p>\n\n<p>While this may seem like an outlier, Copilot seems to excel in these algorithm-based questions.&nbsp;<\/p>\n\n\n<p>But surely <code>isPrime<\/code> would be too trivial for a<em>real<\/em> interview question, right? Perhaps, but watch what happens when a popular coding YouTuber attempts to utilize Copilot to solve Leetcode interview questions<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<lite-youtube\n    videoid=\"FHwnrYm0mNc\"\n            params=\"rel=0\"\n        style=\"background-image: url('https:\/\/i.ytimg.com\/vi\/FHwnrYm0mNc\/maxresdefault.jpg');\">\n  <a href=\"https:\/\/www.youtube.com\/watch?v=FHwnrYm0mNc\" class=\"lty-playbtn\" title=\"Play Video\" target=\"_blank\" rel=\"noopener\">\n            <span class=\"lyt-visually-hidden\">Play Video: GitHub Copilot CRUSHES Leetcode Interview Questions! \ud83d\ude33<\/span>\n      <\/a>\n<\/lite-youtube>\n\n<\/div><\/figure>\n\n\n<p>Without fail, Copilot is able to generate usable code for each difficulty level of algorithms given to it. Further, the solutions are all more performant than the average of submissions. For the permutation question, it\u2019s able to be faster than 88% of other submissions!<\/p>\n\n<p>\u201cGiven how predominant these types of interview questions are, we could be in big trouble if some candidates are less-than-forthcoming with their usage of Copilot in coding exercises.\u201d<br><br>While this may be true for some interviews, if your interviews are susceptible to collapse with Copilot in the picture, you\u2019re already facing this problem whether you\u2019re aware of it or not.<\/p>\n\n<h2 class=\"wp-block-heading\" id=\"algorithms-breaking-interview\">Algorithms Are Breaking Your Interviews<\/h2>\n\n<p>On paper, algorithm based interview questions sound like a great way to assess a candidate&#8217;s skills. They can help give guidance on a candidate&#8217;s understanding of logic complexity, how efficient (or inefficient) a specific solution is, and is usually an insight into a candidate\u2019s ability to think in abstract manners.&nbsp;<\/p>\n\n<p>However, in practice algorithm questions tend to go against the grain of real-world engineering. Ideally, an interview process should act as a way to evaluate a candidate\u2019s ability to do the same kind of engineering they\u2019d be using in their projects at your company. While a developer may, with resources, implement an algorithm once in a while, they\u2019re more than likely doing things like refactoring significantly more often.<\/p>\n\n\n<p>We\u2019ve written more about how <a href=\"https:\/\/coderpad.io\/blog\/interviewing\/5-tips-for-tech-recruiting\/#less-algorithms-more-demos\">algorithms aren\u2019t often effective as interview questions in the past.<\/a><\/p>\n\n\n<p>But more than being unrepresentative of the job, algorithm questions are often easy to cheat &#8211; without the use of GitHub Copilot. Because most algorithm questions are significantly similar to each other, there\u2019s often a small selection of tips and tricks a candidate can memorize in order to drastically improve their output in these styles of interviews.<\/p>\n\n<p><br>There\u2019s even the potential for a candidate to be able to output an algorithm verbatim. There are hundreds of sites that will give a candidate one algorithm question after another in the hopes of improving their understanding of these algorithms.<\/p>\n\n\n<p>But with GitHub Copilot, the propensity for cheating on an algorithm question rises significantly. As we\u2019ve demonstrated previously in the article, it\u2019s capable of generating significant portions of code at a time. In fact, Copilot is so proficient at algorithm questions that a <a href=\"https:\/\/github.com\/CoderPad\/github-copilot-interview-question\" target=\"_blank\" rel=\"noopener\">non-trivial number of algorithm questions we asked it to solve were done<\/a> before we could even finish the function signature. All it takes is a candidate to give Copilot the name of the function and paste the results into their assessment editor.<\/p>\n\n\n\n<p>Further, folks wanting to cheat have had the ability to do something similar for some time now in the form of forum questions. Simply lookup any algorithm on a code forum or site like <a href=\"http:\/\/stackoverflow.com\/\" target=\"_blank\" rel=\"noopener\">StackOverflow<\/a> and you can find hundreds of answers at your disposal.&nbsp;<\/p>\n\n\n\n<p>In fact, many have pointed out that Copilot\u2019s process of looking up code based on its expected constraints is similar to one that a developer might experience by searching StackOverflow for code snippets. Funnily, some thought the idea so similar they decided to build an alternative VSCode plugin to Copilot that simply <a href=\"https:\/\/github.com\/hieunc229\/copilot-clone\" target=\"_blank\" rel=\"noopener\">looks up StackOverflow answers as suggestions<\/a>.<\/p>\n\n\n<p>Regardless of how the question is answered, a candidate\u2019s skill at these types of questions might not reflect their capabilities in other aspects of the codebase. That\u2019s why, in order to access candidates properly, it might be the right move to move away from these questions.<\/p>\n\n<h2 class=\"wp-block-heading\">How to Fix Your Interviews<\/h2>\n\n\n<p>While you <em>could<\/em> simply require candidates to use a non-VSCode IDE for your technical assessments, there are no guarantees that your take-home projects will be spared the same fate. Further, while VSCode is the launch platform for Copilot, it\u2019s more than likely to gain plugins for other IDEs in the future as well.<\/p>\n\n\n\n<p>But what of it? Let\u2019s say your company doesn\u2019t do take-home projects (<a href=\"https:\/\/coderpad.io\/blog\/interviewing\/hire-better-faster-and-in-a-more-human-way-with-take-homes\/\">even though you totally should<\/a>), what of it? Well, even if restricting VSCode would work to avoid Copilot for a while, you ideally want to be able to standardize your IDE platform for all candidates.&nbsp;<\/p>\n\n\n<p>Plus, as we touched on in the previous section, algorithm-based interview questions are still able to be manipulated &#8211; with or without Copilot.<\/p>\n\n<p>The solution to fixing your interviews should be two-fold:<\/p>\n\n\n<ol class=\"wp-block-list\"><li>More representative questions of the job<ul><li>Require more thought process than memorization<\/li><\/ul><\/li><li>Better communication with candidates<\/li><\/ol>\n\n\n\n<p>For the first, make sure your questions are examples of real-world challenges you\u2019ve seen in your project\u2019s codebase. Some great examples of this might be \u201csetting up a backend endpoint <a href=\"https:\/\/coderpad.io\/resources\/docs\/interview\/databases\/\">connected to your database<\/a>\u201d or \u201c<a href=\"https:\/\/coderpad.io\/blog\/development\/master-react-unidirectional-data-flow\/#challenge\">refactor this React component to be unidirectional<\/a>\u201d.<\/p>\n\n\n<blockquote class=\"wp-block-quote\"><p>If you\u2019re using CoderPad, we have a <a href=\"https:\/\/coderpad.io\/resources\/docs\/interview\/question-bank\/example-questions\/\">great selection of questions available in our Question Bank that you can personalize to fix the unique needs of your team<\/a><\/p><\/blockquote>\n\n<p>The second point might sound obvious, but look at it this way: Engineering often utilizes more \u201csoft\u201d skills than we usually credit. In any engineering team you\u2019ll need to do code review, create technical documentation, and communicate with others on your team. Being able to program is well and good, but without soft skills your ability to leverage those skills goes flat.<\/p>\n\n<p>Even if a candidate does end up using Copilot to generate a non-trivial portion of a candidates\u2019 submitted code, you should be able to ask them what their review process of the generated code looked like. Does it follow their code standards? What alternatives did it suggest and why did they choose that one? How maintainable is said code? Are there edge-cases not yet covered?<\/p>\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n<p>GitHub Copilot is a remarkable piece of technology. It will be interesting to watch as it continues to develop and see how developers will utilize it in their day-to-day. As it becomes more and more relevant, we need to make sure our interviews are structured to handle(and prevent) its capabilities.<br><\/p>\n\n\n<p>In fact, we\u2019ve created <a href=\"https:\/\/github.com\/CoderPad\/github-copilot-interview-question\" target=\"_blank\" rel=\"noopener\">a GitHub repo to showcase a wide range of interview questions that Copilot has been able to successfully generate<\/a>, given little input.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/github.com\/CoderPad\/github-copilot-interview-question\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"828\" src=\"https:\/\/coderpad.io\/wp-content\/uploads\/2021\/07\/image-1024x828.png\" alt=\"The GitHub Copilot interview questions GitHub repo\" class=\"wp-image-2099\" srcset=\"https:\/\/coderpad.io\/wp-content\/uploads\/2021\/07\/image-1024x828.png 1024w, https:\/\/coderpad.io\/wp-content\/uploads\/2021\/07\/image-300x242.png 300w, https:\/\/coderpad.io\/wp-content\/uploads\/2021\/07\/image-768x621.png 768w, https:\/\/coderpad.io\/wp-content\/uploads\/2021\/07\/image.png 1355w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n<p>Feel free to open a PR if you find a question that you think should be present. If you\u2019re worried about your interview question being susceptible to Copilot, maybe drop by the repo and see if it\u2019s in the list.<\/p>","protected":false},"excerpt":{"rendered":"<p>How to build your interviews to be more resilient to auto-generated code.<\/p>\n","protected":false},"author":1,"featured_media":2215,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[9],"tags":[],"persona":[29],"blog-programming-language":[],"keyword-cluster":[],"class_list":["post-2089","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development"],"acf":[],"_links":{"self":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/posts\/2089","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/comments?post=2089"}],"version-history":[{"count":16,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/posts\/2089\/revisions"}],"predecessor-version":[{"id":8044,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/posts\/2089\/revisions\/8044"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/media\/2215"}],"wp:attachment":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/media?parent=2089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/categories?post=2089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/tags?post=2089"},{"taxonomy":"persona","embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/persona?post=2089"},{"taxonomy":"blog-programming-language","embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/blog-programming-language?post=2089"},{"taxonomy":"keyword-cluster","embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/keyword-cluster?post=2089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}