Introduction to AI-Assisted Coding Tools

1

Introduction to AI-Assisted Coding Tools

▶

Artificial intelligence has fundamentally changed how engineers and developers write code. Rather than searching through documentation, copying from Stack Overflow, or writing every line from scratch, programmers can now describe what they want in plain language — or simply start typing — and receive intelligent, context-aware suggestions almost instantly. Two tools that have become central to this shift are GitHub Copilot and ChatGPT. Understanding what each tool does, how it works, where it excels, and where it falls short is essential before relying on either in any serious engineering context.

GitHub Copilot is an AI-powered coding assistant developed by GitHub in collaboration with OpenAI. It is built directly into your code editor and operates inline — meaning it watches what you type in real time and offers suggestions that appear directly in your file, right where your cursor is. This is fundamentally different from looking something up in a browser tab or reading documentation separately. Copilot makes suggestions feel like a natural continuation of your own typing.

The engine behind Copilot was trained on enormous amounts of publicly available source code from repositories across the internet, along with documentation, comments, and other technical text. This training allows it to recognize common programming patterns, standard library usage, and typical ways of solving recurring problems. When you open a file in your editor, Copilot continuously reads the surrounding code — the functions you have already written, the imports at the top of the file, the variable names you have chosen — and uses all of that as context to generate its suggestions. The more context that exists, the more relevant the suggestion tends to be.

One of the most powerful ways to guide Copilot is through comments and docstrings. If you write a comment like # Read a CSV file and return a list of dictionaries, one per row and then press Enter, Copilot will often generate a complete function body implementing exactly that behavior. Similarly, if you write a Python docstring explaining the parameters and return value of a function before writing the function body, Copilot uses that description to infer what the implementation should look like. This means that clearly expressing intent in comments is not just good documentation practice — it is also a direct input to the AI.

Copilot suggestions appear as grayed-out ghost text in the editor. At that point you have several choices: you can press Tab to accept the suggestion in full, press Escape to dismiss it, or use keyboard shortcuts (typically Alt + ] and Alt + [ on Windows/Linux, or Option + ] and Option + [ on macOS) to cycle through alternative suggestions. This cycling is important — Copilot often generates multiple candidate completions for the same prompt, and the first one displayed is not always the best. Reviewing alternatives before accepting trains you to treat Copilot as a collaborator offering options rather than an authority issuing answers.

Consider a simple example. Suppose you are writing a Python script for a mechanical engineering application and you type the following comment:

# Calculate the Reynolds number given fluid velocity (m/s),
# characteristic length (m), and kinematic viscosity (m^2/s)
def reynolds_number(velocity, length, viscosity):

Copilot will very likely suggest something like:

    return (velocity * length) / viscosity

This is the correct formula for Reynolds number. Copilot recognized the domain terminology, inferred the mathematical relationship, and produced a correct one-line implementation. However — and this is critical — you should still verify it. Not because Copilot got it wrong here, but because forming the habit of verification protects you in cases where it does not.

ChatGPT is a large language model developed by OpenAI that you interact with through a conversational interface — either via a web browser at chat.openai.com or programmatically through the OpenAI API. Unlike Copilot, which quietly suggests completions as you type, ChatGPT is explicitly conversational. You type a message — a prompt — and ChatGPT replies with text that might include explanations, code blocks, step-by-step instructions, or a combination of all three.

This conversational format makes ChatGPT especially well-suited for situations where you need to understand something rather than just get a code snippet. For example, if you encounter an error message you have never seen before, you can paste it directly into ChatGPT and ask what it means and how to fix it. ChatGPT will typically explain the underlying cause, show you the corrected code, and walk through why the original code was wrong. This kind of explanatory response is something Copilot, operating silently inside your editor, cannot provide.

ChatGPT can also generate complete implementations from a plain English description. You might prompt it with something like:

Write a Python class that represents a simply supported beam.
It should store the beam length, the applied point load, and
the load position. Include a method that calculates the
maximum bending moment.

ChatGPT will return a fully structured class with an __init__ method and a max_bending_moment method, along with comments and possibly an example of how to instantiate and use the class. This is extremely useful as a starting scaffold when you know what you want to build but want to avoid writing boilerplate from scratch.

Another powerful feature of ChatGPT is iterative refinement. Because the interface is conversational, you can follow up on any response. If the first reply gives you a class but forgets to handle the case where the load is outside the beam span, you can simply reply: "Add input validation to raise a ValueError if the load position is outside the beam length." ChatGPT will revise the code accordingly. You can continue this back-and-forth as many times as needed, progressively narrowing in on exactly the solution you want. This iterative dialogue is one of ChatGPT's most significant advantages over a one-shot code generator.

Despite these impressive capabilities, both Copilot and ChatGPT come with important and non-trivial limitations that engineers must understand before trusting any generated output.

The most dangerous failure mode of AI coding tools is generating code that is syntactically correct but logically or numerically wrong. The code will run without errors. Python will not throw an exception. Your editor will show no red underlines. But the results it computes may be completely incorrect. This happens because the AI learned patterns of code structure rather than deep mathematical or physical reasoning. For example, a Copilot suggestion might implement a stress calculation using the wrong cross-sectional property, use degrees where radians are expected, or apply a formula outside the range of its valid assumptions — and none of these errors will be caught automatically.

AI tools also frequently suggest code that uses deprecated APIs or outdated library versions. Because the training data has a knowledge cutoff date, and because older code is often more prevalent in training data than newer code, suggestions may use functions or class names that no longer exist in current library releases. For instance, a suggestion using an old version of the matplotlib or pandas API may work perfectly on the AI's internal mental model but fail immediately when you run it in your environment with a newer library version. Always check the official documentation when an AI-suggested function call produces an AttributeError or DeprecationWarning.

Perhaps most importantly for engineering applications: AI tools have absolutely no awareness of engineering safety standards, physical tolerances, domain-specific constraints, or regulatory requirements. An AI might generate a perfectly structured function to calculate beam deflection, but it has no knowledge of your factor of safety requirements, the applicable design code (such as AISC or Eurocode), the material properties of your specific alloy, or the environmental conditions that affect fatigue life. The AI is producing code that fits a pattern; you are responsible for ensuring that code reflects engineering reality. Treating any AI-generated engineering calculation as a draft that requires expert review is not just good practice — in many contexts it is an ethical and professional obligation.

Prompt quality matters enormously. Ambiguous or vague prompts produce less reliable and less targeted output. A prompt like "write a function to analyze stress" will produce something generic and probably not useful. A prompt like "write a Python function that computes the von Mises stress from the principal stresses sigma_1, sigma_2, and sigma_3, and returns True if the result exceeds a given yield strength threshold" will produce something specific and actionable. The effort you put into writing a clear, detailed prompt is directly reflected in the quality of what comes back. This is a learnable skill, often called prompt engineering, and it improves with practice.

Setting up these tools in your development environment is straightforward. GitHub Copilot is installed as an extension inside Visual Studio Code. You open the Extensions panel (the puzzle-piece icon in the sidebar), search for GitHub Copilot, and click Install. After installation, VS Code will prompt you to sign in with your GitHub account. Copilot requires either a paid individual or business subscription, or a free student license available through the GitHub Student Developer Pack, which you can apply for with a verified educational email address. Once activated, Copilot begins working immediately with no further configuration required — ghost-text suggestions will appear as you type in any supported language.

ChatGPT requires no installation. You access it through any modern web browser by navigating to chat.openai.com and creating a free OpenAI account. A free tier is available with access to GPT-3.5; a ChatGPT Plus subscription provides access to GPT-4, which produces noticeably more accurate and detailed responses, especially for complex technical tasks. Developers who want to integrate ChatGPT programmatically into their own tools or scripts can do so through the OpenAI API, which requires an API key and may incur usage-based costs.

One important and non-negotiable precaution applies to both tools: never paste sensitive, proprietary, confidential, or commercially restricted code into an external AI chat interface. When you send a prompt to ChatGPT through the web interface, that data is transmitted to OpenAI's servers. Depending on your account settings and terms of service, it may be used to improve future models. If your code contains trade secrets, unpublished algorithms, client data, or any information subject to a non-disclosure agreement, pasting it into ChatGPT is a potential security and legal violation. GitHub Copilot, operating locally in your editor and communicating with GitHub's servers, carries similar considerations — enterprise versions offer additional privacy controls, but individual users should be aware that context sent to generate suggestions may leave their machine. Always consult your organization's data handling policy before using any AI tool with professional or client code.

To summarize the practical relationship between these two tools: GitHub Copilot is best thought of as a smart autocomplete that stays out of your way and helps you write code faster without breaking your flow. ChatGPT is best thought of as a knowledgeable conversation partner you consult when you need explanation, want to explore an approach, or need to generate a larger block of code from a description. The two tools complement each other. You might use ChatGPT to understand how a numerical integration algorithm works and to generate an initial implementation, then paste that implementation into your editor where Copilot helps you extend and adapt it. Used together, with critical human oversight at every step, they significantly accelerate the engineering coding workflow without replacing the engineering judgment that ensures the results are correct and safe.

NotesEmphasize to students that verifying AI-generated code is especially important in engineering contexts where incorrect numerical results can have real-world physical consequences. Encourage students to apply for the GitHub Student Developer Pack early if they do not already have it, as verification can take a few days. Consider a live demo showing Copilot ghost-text suggestions and ChatGPT iterative refinement side by side to make the distinction between the two tools concrete.