<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jay Mojnidar on Medium]]></title>
        <description><![CDATA[Stories by Jay Mojnidar on Medium]]></description>
        <link>https://medium.com/@jay.mojnidar?source=rss-e6ae7289318a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UBfP-tQ_aZzSm5Sxz1_8Yw.jpeg</url>
            <title>Stories by Jay Mojnidar on Medium</title>
            <link>https://medium.com/@jay.mojnidar?source=rss-e6ae7289318a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 23:55:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jay.mojnidar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ChatGPT Corner]]></title>
            <link>https://medium.com/@jay.mojnidar/chatgpt-corner-e46da9eee3ac?source=rss-e6ae7289318a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e46da9eee3ac</guid>
            <category><![CDATA[generative-ai]]></category>
            <category><![CDATA[ai-regulation]]></category>
            <category><![CDATA[code-generation]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[ai-replacing-jobs]]></category>
            <dc:creator><![CDATA[Jay Mojnidar]]></dc:creator>
            <pubDate>Fri, 14 Apr 2023 23:13:36 GMT</pubDate>
            <atom:updated>2023-04-14T23:13:36.453Z</atom:updated>
            <content:encoded><![CDATA[<p>Curious about the impact of generative AI on developer jobs, I tested the popular language model ChatGPT. What I found out was that while such models are here to stay and will improve our lives, they are more likely to serve as a co-pilot than to replace jobs. TL;DR below…</p><h3>Prompt Engineering</h3><p>To create content with generative AI tools like ChatGPT, we must understand its primary mechanism: prompting. This involves generating code through iterative queries and corrections based on a described solution. See the demonstration below.</p><h3>The Task</h3><p>I wanted to find a task that is small enough but still is complete, so I decided to use a task on hand at my day job: generating thumbnails for images that our users upload. My approach was to</p><ol><li>create a proof of concept code that would generate a thumbnail for a given image</li><li>integrate that with our company production code base</li></ol><p>The last time I had written thumbnail generation was 10 years ago and in C. My current code base is Go and I wanted to check and use more performant modern packages, if any. My estimation for the first step was 3–4 hours. Mind that my exposure to ChatGPT was only from a non-code perspective. I started using ChatGPT to create the proof of concept step first.</p><h3>The First Prompt</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9TbTTmq8Yw4zmR4s" /></figure><p>Within a few seconds, it came up with the below code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/0*R_PBIOC-GFhgTVkQ" /></figure><p>It gave a good explanation of the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/0*5w-vl0NP76FE5HLh" /></figure><h3>Analysis of the generated code</h3><p>Now, the analysis. I took a cursory look at the generated code. Here is my notes:</p><ul><li>Generated code is of pretty good quality and compiles with no problem.👍</li><li>It is decently organized. 4 simple steps: open the input file, decode to get the real image, resize, and save it on the file system 👍</li><li>CatmullRom is a great scaling choice for generating thumbnails of generic pictures. It is built-in in Go and is better than other choices which are suitable for images with straight lines. ChatGPT certainly made this decision easy for me 👍👍</li><li>Error handling is OK for a POC kind of code 👍</li><li>It feels like someone else’s code 👎 and of course it is… 🙂</li></ul><p>Blindly I copied the code into a Go project, compiled and built it. I fed an image to the application, and it didn’t work. That is the time I had to dig a bit deeper and understand the code. The reason it didn’t work is because the image I used was in png format. Even though I did not say what type of image it would be, ChatGPT assumed it to be JPEG, but did not mention anything about that. That is a red flag. It blew one of coding fundamentals: State your assumptions. This, especially generated code, can lead to expensive bugs.</p><h3>Prompt-Analyze-Prompt Flow</h3><p>Thus, started the prompt-analyze-prompt flow. Since the purpose of my exercise is to have ChatGPT generate the code, I want to let it fix the code. I went back to “prompt” again.</p><h3>Prompt</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/0*kHHTk2_Vbg7vsszt" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/0*lDhF44RDrxE1bw2V" /></figure><h3>Analysis</h3><ul><li>The generated code handles the PNG format.👍</li><li>But, the generated code is not compile-able. 👎</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/0*o_PE429VxyHcwLUF" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*5Hy2o22JbFjsIUYMBdEKFg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/0*uA_wkzsNHZMezLob" /></figure><h3>Analysis</h3><ul><li>The above message makes me think that it is learning👍</li><li>But, the code generated had some other problems. The tussle continued… 👎</li></ul><h3>Prompt</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/0*POC8QnfcCm98JAaD" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/0*bh_uULqL_k0QfsHr" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/0*y0-EpJW2YpVyGP6e" /></figure><h3>Analysis</h3><ul><li>Finally this code can handle both jpeg and png files. 👍</li><li>But, look at the highlighted portion of the code. It is determining the type of image format based on file extensions, which can be changed by users intentionally or accidentally. That is a code smell 👎This can lead to bugs in the field which will be hard to reproduce internally. Go back prompting again.</li></ul><h3>Prompt</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/0*JYz1R_yPtVkgnJfh" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/0*PD_yng3njnqvchoI" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/0*Yb9R_uyLInaWlrKl" /></figure><h3>Analysis</h3><ul><li>Figuring out the image format by checking the header is a better approach 👍</li><li>However, there is a hidden bug in this. An experienced developer would see that it does not work because when the code reads the header, the file reader pointer has moved, and if you decode at that point, it fails. The file reader pointer has to be reset to the beginning. I did not want to intervene. Wanted ChatGPT to fix it.</li></ul><p>Went back to prompting again.</p><h3>Prompt</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/0*ZOX18EChQrFtKeP-" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/0*HZn3E34IZWXXhvu8" /></figure><h3>Analysis</h3><ul><li>This code is the same as what ChatGPT generated earlier.👎👎</li></ul><p>There was a long cycle of me prompting and ChatGPT generating the same unworkable code over and over again. For brevity sake, I am not listing them here. Finally, I had to prompt the exact problem for ChatGPT to generate the working code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/0*aEAxgu6mKbjqeGIy" /></figure><p><strong>Note</strong>: ChatGPT does not have a way to start a new thread from a random discussion point. That is purely a ChatGPT UI issue. So, the prompt should provide enough context to switch to an earlier discussion point. GPT4 the model that the ChatGPT is using, can follow that amazingly!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MEo63csWNAFvdyue" /></figure><h3>Analysis</h3><ul><li>The highlighted code is the fix!!👍</li><li>Finally, the above generated code works well. 👏</li></ul><p>The above exercise took about 2 hours of back and forth –less than my estimated time if I had not taken the help from ChatGPT</p><h3>Step Two: Integrate generated code with production code base</h3><p>Now, to the step two mentioned in the Task section above. I did not pursue the step of integrating the generated code with the production code base for a couple of reasons</p><ol><li>With the above arduous experience in generating a proof-of-concept code where ChatGPT is using mostly publicly available code, I felt the time and effort needed to generate production quality code usable on our code base which is not publicly available would be exponentially high.</li><li>More importantly, we do not know what would be the implications of exposing our proprietary code to ChatGPT.</li></ol><h3>Conclusion</h3><p>ChatGPT, trained on GPT 3.5, is a great “getting started” code generator tool. Only with a good dose of “prompting” it can do that. In order to prompt better, one needs to understand the code, and guide it towards the right direction.</p><p>For non-coders, in order to prompt efficiently you need to understand the generated code. Otherwise you are shooting in the dark and hoping to hit the target. So, do not fire your coders yet.</p><p>For coders, generative AI genie is out of the bottle and is here to stay. Learn to live with it. Learn to “prompt”. It is both art and science just like coding. Get ready to leverage it. And keep your coding skills shining!</p><p>You can find the actual code generated by ChatGPT here: <a href="https://github.com/jaymoj/chatcorner.git">https://github.com/jaymoj/chatcorner.git</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e46da9eee3ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>