Photo by Chris Ried on Unsplash

Changing Programming Paradigm

Hitesh Bagchi

--

Since 2008, when stackoverflow.com (SO) was launched it has become customary for most programmers to search for answers to programming questions there. Even if you searched in Google, chances are that you will be redirected to SO. And this has been pretty much the universal pattern to write code for more than a decade now.

It is true, frameworks and programming languages documentation have been good for several years even before SO was launched. For instance, Java API docs in its Javadoc form was quite good. So was MSDN, if not better. Even then, it took more time to read, understand and develop the necessary code by using the docs. Moreover, not every method / function in the official docs had examples that we can copy. So SO was a great help and truly made the programmers more productive.

Today at we witness the wave of GenAI making inroads into the developer tools stack, things are changing all over again and in a very big way. Gen AI code generation tools, e.g., Github CoPilot, Amazon CodeWhisperer, etc., are definitely initiating another paradigm shift.

Recently, I participated in an AWS Jam on Amazon CodeWhisperer and my experience was mixed.

In the AWS Jam, there was a challenge in which I have to use Amazon CodeWhisperer to generate a code in Python inside a Lambda function that will validate an input for an email address. I was surprised by the quality of the code it generated and how good it was. But what surprised me even more was that the code comment used for the code generation or in other words the ‘prompt’ that you need to write to enable the code generation was driving the quality of the generated code.

For instance, when I wrote a code comment like this,

# Function to validate an email address

It generated a function body that was checking for the presence of a dot (.) and an @ in the input string and if both are present it was returning a True response. This was at best an average quality function for validating an email address.

However, when I changed the code comment to this

# Function to validate an email address using a regular expression

I got a much better quality code output.

import re
def validate_email(email):
regex = '^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}'
if re.search(regex, email):
return True
return False

It is easy to conclude that the above code is much more robust and of higher quality. It is a much more complete function to validate email addresses.

This is exactly why I named this post as “Changing Programming Paradigm”. My point is to leverage these new Gen API tools to the fullest we have to master a new way of interacting with it called Prompt Engineering. While I see no problem in adopting this new approach to programming as long as we can reduce development time, it does involve an unlearning and relearning phase. Also, it is lot less formal and intuitive way to writing code than using raw programming language syntax. Moreover, we may be restricted by the capability of the LLM that is being used in each of these tools.

I am sure these tools will only become more powerful with time and hopefully this new way of writing code through Gen AI tools will not impact their long term benefits negatively. Let us see how things unfolds in the days ahead.

--

--