
AI is becoming ubiquitous within tech companies. Executives are asking developers to utilize generative AI chatbots and other tools in their workflows. Whether that AI actually makes tech work easier is an open question, but tech pros everywhere can’t ignore how this technology is changing the game.
Given how much I’m using AI in my own development work, I wanted to explore all the ways in which you can use AI tools to at least speed up your workflow a bit. I came up with five specific uses:
- Generating code for you.
- Teaching you a new programming language.
- Debugging your code and fixing compile errors.
- Generating data for you.
- Generating practice job interview questions for you.
Obviously, many developers are figuring out whether AI is truly good at generating code. AI tools will provide code in response to a prompt, but is it useful? The answer is “yes”—with some significant caveats. Here are some things to keep in mind.
- Trust but verify: You should not expect AI-generated code to always be correct; there are no guarantees that it compiles, runs and outputs the right answer.
- Not all AI-generated code is the same: I asked Claude.ai to generate a C program to count all numbers from 123456789 to 987654321, with each number containing one each of the digits 1-9 along with timing code, and return the 100,000th number in the sequence. It created a program, then immediately created a second optimized version that took 2.3 ms to find the answer. I then asked it to create a Rust version, which it did… but it had three compile errors. I tried the same prompt with Microsoft CoPilot; it created valid code but it wasn’t optimized and the release version took 1.4 seconds to run. Both projects are zipped up on GitHub.
- You really need to review the code and either fix it or go back to the AI.
From a coding perspective, you can generally utilize AI for the following:
- Generating unit tests: Ensuring the reliability and robustness of your code by automatically creating test cases.
- Creating API endpoints: Quickly setting up the communication layers for your applications.
- Building basic application structures: Providing a foundational framework for new projects, saving you hours of initial setup.
- Translating code between languages: While still an evolving area, AI can assist in porting code from one language to another, albeit with careful review.
Have AI Teach You a New Programming Language
Here’s how I learned Rust via AI: I asked it to create a tutorial in summary form and it produced a 13- section summary, each with three relevant sections. Then I asked it to provide examples and explain each section.
You can do the same thing when it comes to learning new programming languages. As you proceed, ask your AI to generate simple programming questions and then have it review your answers.
I think some of the AIs are getting close to the point where they can compile and run the code. Claude.ai appears to have done that once or twice, unless I’m hallucinating! Along with the code it generated, it also output this:
When you run this program, it will output:
The 100000-th permutation is: 358926471
I can’t see how it could do that unless it ran the program. Claude.ai used to include a warning that it can’t compile code, but maybe the AI has taken on a mind of its own…
While you ponder that conundrum, here are some additional points about using AI to learn a programming language:
- Explain concepts in plain language: Breaking down complex topics into digestible explanations tailored to your existing knowledge.
- Provide code examples: Illustrating theoretical concepts with practical, runnable code snippets.
- Offer exercises and challenges: Testing your understanding and providing immediate feedback on your progress.
- Compare and contrast languages: Highlighting the similarities and differences between languages you already know and the new one you're learning.
- Suggest relevant learning resources: Pointing you towards the most effective documentation, tutorials, and communities for your specific learning style.
Have AI Debug Your Code and Fix Compile Errors
Some coding errors can prove quite confounding, especially if you’re just learning a new programming language! A misplaced comma in a C++ header file could generate over 100 errors, for instance.
AI is very good at finding an error and explaining what’s wrong. Rust in particular has some complicated features such as borrowing and lifetimes; when I hit problems, asking an AI helped solve it. If you’re used to searching online or delving into StackOverflow, give an AI a try. It will save a lot of time.
Here are some other tips for using AI in an error-solving context:
- Analyze error messages: Providing clearer explanations of what the error means and where the potential issue lies.
- Identify potential bugs: Scanning your code for common pitfalls and suggesting improvements even before runtime errors occur.
- Suggest fixes and code corrections: Based on its training data, AI can often propose specific code modifications to resolve errors.
- Explain the root cause of errors: Helping you understand why the error occurred, leading to better learning and preventing future mistakes.
- Compare your code to similar working code: Identifying discrepancies that might be causing the issue.
Have AI Generate Data for You
Ever needed test data for a program? For example, 100 sets of values, each a time and a value between 24.0 and 47.9? You could write a simple program to generate it… or you could use this simple AI prompt:
Please generate 100 pairs of values with a time value that increases from time 0 mins and 0 seconds to 10 minutes in random time intervals and 0 seconds and random values between 24.0 and 47.9.
That generates output from an AI like this:
Time,Value
0:00,36.7
0:06,42.3
0:12,31.5
0:17,45.8
…
You can also pass data like this to an AI, ask it to plot in on a line chart and even have it calculate a polynomial that fits the curve. Here are some other ways that AI can prove useful in the context of data generation:
- Create realistic test data: Populating databases and generating input for testing various application functionalities.
- Generate diverse datasets: Ensuring your application handles a wide range of inputs and edge cases.
- Anonymize and synthesize sensitive data: Creating non-identifiable datasets for development and testing purposes while respecting privacy regulations.
- Generate data in various formats: Producing data compatible with your specific application requirements (e.g., JSON, CSV, XML).
- Simulate real-world data distributions: Creating data that accurately reflects the patterns and characteristics of production data.
Have AI Generate Job Interview Questions for You
If you’re applying for a developer or engineer job, you might have a hard time figuring out potential interview questions, or which areas you should study. AI can prove an interesting study partner; you just need to ask it to keep peppering you with questions. Make sure to specify your desired difficulty level.
Here are some other benefits:
- Generate realistic interview questions: Covering a wide range of topics relevant to your target roles and experience level.
- Provide feedback on your answers: Analyzing your responses and highlighting areas for improvement in terms of technical accuracy and communication clarity.
- Simulate interview scenarios: Allowing you to practice your responses in a timed and structured environment.
- Offer insights into common interview patterns: Helping you understand the types of questions and approaches used by different companies.
- Suggest areas to focus your preparation: Identifying your strengths and weaknesses based on your practice sessions.
Conclusion
Frankly, I can’t imagine not using AI to help me with programming now, if only to speed things up a bit. However, it’s important to keep in mind that you need a solid base of knowledge in coding before you can trust an AI too much; for example, you need to be able to evaluate the true worth of code snippets or whether a chatbot is generating the right kind of data to meet your needs.