Blog_Lead (19)
PK
Paul Keelan Consultant & and Data/Software Engineer

Gen AI, Tech Focus Thu 29th February, 2024

Could AI code tools be your new favourite pair programming partner?

There is a lingering concern in some circles that AI is coming for our jobs. I’ve been using Jetbrains AI Assistant to create better, more efficient code for five months and I can tell you: AI is a tool for helping developers, not replacing them. 

What JetBrains AI Assistant can do

JetBrains AI Assistant helps me to work on code, and particularly to identify and solve problems in code. Working alongside JetBrains AI, I can get feedback on code as I go. If I have a problem, I give the system context and ask a question. If I’ve provided clear context, I’ll generally get decent answers. 

For example: I recently used JetBrains AI to create scripts that would convert a CSV file into the format required by the database. The AI came up with scripts far faster than a human coder, taking just half an hour to do something that would have taken me half a day. I could have programmed the code myself, but not nearly as quickly. 

…but it does have its limitations

Firstly, it’s important to remember that AI tools are using data that was acquired in 2021. So if you’re trying to use the latest framework, the AI isn’t always going to give a good answer, because the underlying data is outdated. 

Secondly, AI lacks human intuition, so the results are contingent on it having enough context to provide a good answer. As users, we need to be clear about what language, what framework, what version we’re using.

If you’re inspired to give JetBrains AI a try, here are some tips on getting the most from the system: 

Top tips for using JetBrains AI  

Give the tool as much context as possible 

This means explaining the language and framework but also the structure of your data. I keep a list of headers and data sources in my database, which I can use to instantly provide context to the AI. I also keep a file with a paragraph of context information that I can add into requests when needed. 

Use AI to identify errors in code 

One of the best ways that JetBrains AI supports my work is that if I get an error in code, I can run the error past the tool and it will often find the error, because in the past someone else has made that error, so the AI understands that from historical context. The integration extends so well that if you do get an error you can click on the error and the AI will spring into action with full context of the error provided to it.

Don’t keep doing the same thing if it’s not working 

If the AI assistant gets confused or stuck in a loop, give it a way out of the loop. Suggest an alternative or provide more context. Otherwise, it’s just going to stay in that same loop. 

Stop thinking that AI has to be perfect 

Generally the code is good, but we need to stop assuming it’s perfect and always check for things like security problems. For instance, I’m using Neo4j version 5. I’ve told the AI assistant that I’m using Neo4j version 5, but randomly sometimes it switches to Neo4j version 4 and combines the code together. It’s easily identified because as soon as you put the code into Neo4j version 5, it will throw up an error, but it’s definitely a pitfall to look out for.  

Use AI to help support your learning

I’ve found JetBrains AI really useful in multiple languages, including Java, Python, Vue and Cypher. It handles them all really well and has been a good way to learn more about new languages and frameworks, and the differences between old and new versions. 

If you’re using a well known API, then often Jetbrains AI will know about it. This helped a lot when using the Slack API as I was able to provide a use-case for what I wanted to do. When Jetbrains AI suggested which endpoints and scopes would be good to use, I was then able to ask questions around parameters for the API and how best to use the API to minimise API calls. The interactivity of the AI was a lot more enjoyable than scouring API documentation!

Get in touch with us to find out how we can help you get the best from AI.