Quantcast
Viewing all articles
Browse latest Browse all 133

Exploring AI for developers: First impressions

In this article, we want to gather first impressions on the ubiquitous new AI tools that are supposed to render us programmers obsolete.

First learnings are: Yes, AI can certainly save you some effort — for instance, by generating basic structures for unit tests and the like. It also can support you during development suggesting more or less useful code completions.

Experimenting with CodeGPT and the like

To start, I experimented with the CodeGPT plugin for IntelliJ IDEA. One of its strengths is the ability to test various providers and language models. The downside: Most of them don’t work out of the box without registration and unless you’re willing to invest some money.

I chose a small, straightforward Kotlin code snippet for this experiment:

object : ColumnDefinitionResolver {
    override fun resolve(sourceDatabase: DatabaseMetaData,
       targetDatabase: DatabaseMetaData,
       column: ColumnMetaData) =
   ColumnTypeDefinition(column, column.columnTypeName,
       column.precision, column.scale)
}

I asked the different AI tools to transform this into a sleek lambda expression, aiming for something like this:

ColumnDefinitionResolver { sourceDatabase: DatabaseMetaData, targetDatabase: DatabaseMetaData, column: ColumnMetaData ->
    ColumnTypeDefinition(column, column.columnTypeName, column.precision, column.scale)
}

Better yet, I wanted an even more concise version:

ColumnDefinitionResolver { _, _, column -> ColumnTypeDefinition(column, column.columnTypeName, column.precision, column.scale) }

The magic words (aka prompt) I used were:

“Please convert the selected code to a lambda expression and optimize it.”

Here’s what the tools came up with:

Gemini 1.5 Pro

val resolver = ColumnDefinitionResolver { sourceDatabase, targetDatabase, column ->
    ColumnTypeDefinition(column, column.columnTypeName, column.precision, column.scale)
}

Not bad, although I didn’t ask for a variable declaration.

GPT-4o-mini

val resolver: ColumnDefinitionResolver = ColumnDefinitionResolver { sourceDatabase, targetDatabase, column ->
    ColumnTypeDefinition(column, column.columnTypeName, column.precision, column.scale)
}

A very similar result.

Ollama (codellama)

val resolver = { sourceDatabase: DatabaseMetaData, targetDatabase: DatabaseMetaData, column: ColumnMetaData ->
    ColumnTypeDefinition(column, column.columnTypeName, column.precision, column.scale)
}

Unfortunately, this version missed the mandatory type declaration ColumnDefinitionResolver.

GitHub Copilot

ColumnDefinitionResolver { _, _, column ->
    ColumnTypeDefinition(column, column.columnTypeName, column.precision, column.scale)
}

Great, that’s what I wanted!

Final Thoughts

While none of these tools can replace us (yet), they certainly make life easier by automating repetitive coding tasks. Exploring AI-assisted programming has been an enlightening experience and I’m excited to see how these tools will evolve.


Viewing all articles
Browse latest Browse all 133

Trending Articles