Can Chat GPT write complex web applications?

And more importantly, should it work in the direction to replace programmers?

Abhishek Dey
5 min readJan 11, 2023
Source: https://openai.com/blog/chatgpt/

A couple of weeks back, I woke up only to find that Chat GPT has taken social media by storm. Some individuals opine that soon it will give Google search a run for its money, and put several entry-level jobs at risk (Content/Copy Writers, Customer Support, Programmers, etc).

What is Chat GPT?
In the words of openai.com, ChatGPT is a chatbot launched by OpenAI in November 2022. It is built on top of OpenAI’s GPT-3 family of large language models and is fine-tuned with both supervised and reinforcement learning techniques.

In simple words, It is an AI (Artificial Intelligence) chatbot that is capable of having conversations with human beings and is equipped to provide smart responses just like an intelligent person.

Sounds Interesting, Let me check it out
Being a Software Engineer, My area of interest has been the programming abilities offered by Chat GPT. So after traversing through a series of youtube videos, Instagram posts, and medium articles depicting the capabilities of chat GPT being able to write codes from scratch, I decided to give it a go and check if it could write complex applications on the web.

How well can this perform?
Well, I am not going to just ask and expect Chat GPT to write a simple to-do list application or a script that sends an email. But I would look forward to it being able to generate code for a far more convoluted system.

Time for the Challenge
Ummm, My wish for Chat GPT, the genie would be to:

“Write a web application in javascript that allows users to sign up using their phone numbers, allows them to add other users using their phone numbers, and then calls them using the number of the added contact. The voice call can be initiated by Web RTC using Session Initiation Protocol. It can use libraries like Js SIP”

Let us see How does Chat GPT take this challenge up:

Chat GPT AI in action

So this was the response and code block generated by Chat GPT.

“Here is an example of a basic web application in JavaScript that allows users to sign up using their phone numbers and add other contacts using their phone numbers, and then initiates a voice call using WebRTC and the Session Initiation Protocol (SIP):”

// Import the necessary libraries
const SIP = require('sip.js');
const WebRTC = require('webrtc');

// Create an instance of the SIP.js library
const sip = new SIP.UA({
uri: 'sip:user@example.com',
transport: 'ws',
wsServers: 'ws://example.com:5060'
});

// Set up event listeners for SIP events
sip.on('registered', () => {
console.log('Successfully registered with SIP server');
});

sip.on('invite', (session) => {
console.log('Received call invitation');
// Accept the call and set up the WebRTC connection
session.accept({
media: {
stream: new WebRTC.MediaStream()
}
});
});

sip.on('connecting', (session) => {
console.log('Connecting to call');
});

sip.on('connected', (session) => {
console.log('Connected to call');
});

sip.on('disconnected', (session) => {
console.log('Disconnected from call');
});

// Log in to the SIP server
sip.register();

// Function to add a new contact
function addContact(phoneNumber) {
// Add the contact's phone number to the SIP address book
sip.addressBook.push({
uri: `sip:${phoneNumber}@example.com`
});
}

// Function to initiate a call
function callContact(phoneNumber) {
// Look up the contact's SIP URI in the address book
const contact = sip.addressBook.find((item) => {
return item.uri === `sip:${phoneNumber}@example.com`;
});
if (contact) {
// Initiate a call to the contact's SIP URI
sip.invite(contact.uri, {
media: {
stream: new WebRTC.MediaStream()
}
});
} else {
console.log('Contact not found in address book');
}
}

Along with this, a smart response was added stating:

“This is just an example and not a fully functional code, you may need to update the code with your specific information. Also, depending on the environment and your setup you may have to make other adjustments, this should work only as a general idea on how to implement a web application that allow to use phone numbers with WebRTC and SIP.”

Well done Chat-GPT on the above response. 👏

Limitations noticed during this experiment
I would say that the above statement does confirm that when it comes to writing advanced web applications Chat GPT certainly has its limitations. This fact can be bolstered by the short and incomplete backend code which only depicts an example connection to a SIP server through WebSocket with no relation whatsoever to the client-end or showing any signup mechanism in the code snippet.

Oh, wait, Open AI themselves have also mentioned some of these limitations in the Chat GPT page.

Conclusion
To conclude, I would say that Chat GPT is a great tool when it comes to writing basic lines of code. But then again I would say that Open AI still has a mile to go in order to ensure that the system is able to handle complex problems or at least is able to direct the user in the right direction.

I would have loved it if the AI even though was not able to write the code had at least pointed me in the right direction by maybe telling me:

  1. How to set up a SIP server and enable WebRTC over it (In a Linux environment preferably).
  2. Using Sip.js to establish a connection to #1 (Even though the code generated shows this, a clearer picture would have helped, the AI might have just assumed that I’m smart. LOL! Imagine a newbie programmer or a non-programmer trying to learn about SIP, how it works, and how to implement it).
  3. Finally, a client-end code depicting how both the backend and front end would work (or at least links to the right resources) would have been amazing to have.

Who knows, maybe instead of Chat GPT AI trying to replace humans in the future (just like in Terminator movies 😅) would rather prove to be a beneficial tool aiding humans to function more effectively by guiding them in the right direction. Only time would tell ⏳.

If you enjoyed this article, please follow and subscribe to my medium account as it would encourage me to write more often :)

--

--