AI for Developers-to-be: Thoughts and Tips
The year 2023 is starting a new chapter in how we work and live as AI becomes more accessible to everyday people. The previous event of this scale was the coming of blockchain in 2017. However, the AI technological leap potentially brings more change to more people in a shorter timeframe.
Let’s start with programmers as their benefits are most tangible — they’ve got new powerful tools like Github Copilot. And while seasoned developers question the ethical grounds of GitHub using others’ opensource work to make profit, newcomers are hoping to accelerate their careers with these wonderful tools.
Copilot’s code completion abilities are pretty amazing. It saves time on repetitive tasks and offers solutions, many of which turn out to be right. However, don’t get too charmed with its seeming brilliance — it can also introduce some hard-to-catch bugs or omit essential details.
That said, stats confirm that developers using AI are overperforming the uninitiated: according to GitHub’s research, developers who used GitHub Copilot completed their tasks 55% faster than the those who didn’t [source].
Besides Github Copilot, there are other similar services like Tabnine or CodegeeX, plus some Python-only services, and of course, we’ve got AI-powered chatbots, first of all, the famous GPT chat.
One of possible effects of AI becoming available for the wide public could be the rise of no-code programming and the influx of AI-taught people without programming experience to the industry. Some of those newcomers could be pretty well educated, proactive, highly ambitious, and have the potential to surprise us with smart, out-of-the-box projects.
So how can AI help produce working apps with minimal to none prior programming knowledge? Let’s try creatiing an example minimal React to-do app without writing any code manually.
Head over to chat.openai.com and type: Help me build a minimal react todo app to deploy on codepen.
(Codepen is a free service providing preinstalled environements.)
OpenAI’s answer is fast and positive. The instructions follow:
“First, let’s create a new React app using CodePen. In CodePen, create a new Pen, and then select the React template from the dropdown menu. This will give you a basic React template to start with. Next, let’s add some code to create the todo app. Here’s an example of what your code might look like. Once you’ve added this code, you should be able to see a simple todo app in action. You can add new todos by typing them into the input field and clicking the “Add” button. To deploy this app to CodePen, simply save your Pen and it will be automatically deployed to a unique URL that you can share with others.”
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
function TodoApp() {
const [todos, setTodos] = useState([]);
const [inputValue, setInputValue] = useState('');
function handleAddTodo() {
if (inputValue !== '') {
setTodos([...todos, inputValue]);
setInputValue('');
}
}
return (
<div>
<h1>Todo App</h1>
<ul>
{todos.map((todo, index) => (
<li key={index}>{todo}</li>
))}
</ul>
<div>
<input
type="text"
placeholder="Add a new todo"
value={inputValue}
onChange={(e) => setInputValue(e.target.value)}
/>
<button onClick={handleAddTodo}>Add</button>
</div>
</div>
);
}
ReactDOM.render(<TodoApp />, document.getElementById('root'));
If you were following, now you probably see… a blank sreen. Yes, nothing will work until you: 1) fix the React scripts location (lines 1-2) and 2) add to the “HTML” section the indispensable code the AI forgot to mention.
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
import React, { useState } from "https://cdn.skypack.dev/[email protected]";
import ReactDOM from "https://cdn.skypack.dev/[email protected]";
...
Luckily, this issue can be easily fixed by googling codepen create react app
and using a working React app template instead of setting up a new one.
You can see the working example in action on Codepen.
The lesson is clear: better not take the AI’s hints at face value, however smart and bright they seem to be, and always check their validity before putting to use.
By accepting the AI’s hint, we’re including code of unknown origin, and if by chance that code was compromised, then our app can be compromised as well.
Be also aware of what you’re feeding into the AI. This information can stay forever in its immense depths and you never can’t be sure it won’t reappear elsewhere. Does running proprietary code through a generative AI tool count as disclosure?
These questions are just an example of uncertainty that still surrounds AI, and we can expect more in the near future.
Conclusion
AI is rapidly changing the programming landscape. As with any new technology, there are potential risks and ethical considerations to be aware of. It’s important to carefully vet and validate the suggestions made by AI tools before implementing them in order to ensure the security and reliability of our code.
Overall, the integration of AI in programming has exciting potential and can revolutionize the industry. Let’s just hope this revolution will bring more benefits to the people, be it new, more interesting and fulfilling work, or free time and universal basic income to travel on Mars! What are your thoughts and questions on this matter? Come to Telegram to share!