Maximizing Productivity for Web Developers: How to Use GPT-3 for Day-to-Day Tasks
Published: 2023-02-16 02:56:57

---
title: Maximizing Productivity for Web Developers: How to Use GPT-3 for Day-to-Day Tasks
published: true
date: 2023-02-12 08:41:32 UTC
tags: 
canonical_url: https://elephas.app/blog/maximizing-productivity-for-web-developers-how-to-use-gpt-3-for-day-to-day-tasks-cle150mji2713931kteprmtaev6
---

LLM(Learning Language Models) has made a big entry in recent times. They have applications in a wide range of domains. One of which is web development.

 GPT-3, one of the popular LLMs, can be used to tackle some of the day-to-day challenges for web developers. Given the fact web developers spend considerable time searching the web, this can cut down the time to handle tasks.

Let me cover a few in this article. I have given GPT-3 specific instructions for common development tasks. You can use these on the OpenAI playground or directly on your Mac with the Elephas app. 

**Debugging an error**

So you run your code and get a weird error that does not make sense at first. You can ask GPT-3 to answer to it. Simply giving the prompt,

> Explain in detail why this error shows up and ways to fix it.

Here is an error in a python code to test it,

![](https://superblog.supercdn.cloud/site_cuid_cl495vqej08071jpawt8inf39/images/cleanshot-2023-02-12-at-14-1676192139396-compressed.png)

I got,

![](https://superblog.supercdn.cloud/site_cuid_cl495vqej08071jpawt8inf39/images/cleanshot-2023-02-12-at-14-1676192242673-compressed.png)

Generating SQL

When you need to write SQL and have clear instructions, you can easily turn into a SQL query with GPT-3.

> Turn the instruction to a MySQL query.

You can replace with the respective database type, such as, Postgres or SQL Server.

Let's say I want to generate a MySQL query for this requirement,

_Fetch the three highest salaries from the Worker table._

When you run the instruction above, 

```
_SELECT salary FROM Worker ORDER BY salary DESC LIMIT 3;_  

```

Note: I use [Elephas.app](https://elephhas.app?ref=dev-blog-1)'s snippet feature to run GPT-3 everywhere on my Mac.

<iframe src="https://www.youtube.com/embed/3YebeG0BCxs" style="width: 100%; height: 100%;" data-index="0" data-file-name="3YebeG0BCxs" data-file-size="0" data-origin="100%,56.25%" data-size="100%,56.25%"></iframe>

## Translate code

Want to translate code from one programming language to another? That would normally require hours for even a simple program. Now, GPT-3 can translate them in seconds. Here is an instruction you can use,

> Translate the following code Python.

Here is a sample PHP code I gave,

```

<?php

$filename = 'cars.csv';

// The nested array to hold all the arrays

$the\_big\_array = []; 

// Open the file for reading

if (($h = fopen("{$filename}", "r")) !== FALSE) 

{

 // Each line in the file is converted into an individual array that we call $data

 // The items of the array are comma separated

 while (($data = fgetcsv($h, 1000, ",")) !== FALSE) 

 {

 // Each individual array is being pushed into the nested array

 $the\_big\_array[] = $data; 

 }

 // Close the file

 fclose($h);

}  

```

and the output I got,

```

import csv

filename = 'cars.csv'

# The nested list to hold all the lists

the\_big\_list = []

# Open the file for reading

with open(filename, 'r') as f:

# Each line in the file is converted into an individual list that we call data

# The items of the list are comma separated

data = csv.reader(f, delimiter=',')

     # Each individual list is being pushed into the nested list
     for row in data:

the\_big\_list.append(row)

# Display the code in a readable format

print(the\_big\_list)

​

```

In a few cases, you may need to tweak a bit.

## Enforcing coding standards

When you want to make sure your code follows the coding standards, you can use GPT-3 to update it as required.

Instruction,

> Convert this PHP code to PSR-4 standard but without changing the logic or used methods.

Input code,

```

<?php 

  $num = mt\_rand(100000,999999); 

  printf("%d", $num);

?>

```

The output I got,

```
namespace App;
class RandomNumber
{
    public function generate()
    {
        $num = mt_rand(100000, 999999);
        printf("%d", $num);
    }
}

```

## Boilerplate code

You don't want to write all the basic code. What if you can generate boilerplate code easily for common tasks?

> Write a bootstrap 3 boilerplate code for a website. 5 menus, three body region, and a footer.

Output included the full HTML. I would double the external links before using the code.

## Understanding code

You can understand any code with GPT-3. If you use Elephas, you can get explanation for code across apps. Here is the instruction you can use,

> Explain the following code as if I were a new developer.

![CleanShot 2023-02-02 at 21.21.04@2x.png](https://superblog.supercdn.cloud/site_cuid_cl495vqej08071jpawt8inf39/images/cleanshot-2023-02-12-at-15-1676197544831-original.gif)

## Slow code?

Find bottleneck in your code with ease.

> ​Explain why the following code is slow and propose better ways.

Input code,

![](https://superblog.supercdn.cloud/site_cuid_cl495vqej08071jpawt8inf39/images/cleanshot-2023-02-12-at-16-1676198318223-compressed.png)

Recommendations,

![](https://superblog.supercdn.cloud/site_cuid_cl495vqej08071jpawt8inf39/images/cleanshot-2023-02-12-at-16-1676198331477-compressed.png)

## Write documentation

You can have GPT-3 write technical use cases.

> We wish to develop a broad-ranging corpus of regular expressions that tests a variety of real-world use cases. Give 10 general categories that would be appropriate for organizing this corpus and several subcategories for each. Give your response as a hierarchically numbered list.

This might produce,

![](https://superblog.supercdn.cloud/site_cuid_cl495vqej08071jpawt8inf39/images/cleanshot-2023-02-16-at-07-1676513044753-compressed.png)

I hope you find this useful. Check out [https://elephas.app](https://elephas.app), which lets you use GPT-3 as a layer on top of your Mac to save you hours every day.