ChatGPT thinks that writing 300 lines of code is “not worth it”


, ,

It was a typical workday hanging out with ChatGPT. I was writing code and we were having a laugh. Then I had to go and ask for help with something that’s been bugging me forever – I really wanted a way to start creating QR codes.

You know, QR codes. The black and white pixelated squares you see at restaurants and on public transportation? You get real close and scan them with… yeah so anyway, did you ever think about how those little codes work or – more importantly – how they’re made? Unless you’re a programmer, probably not. But it’s pretty neat how those tiny binary works of art somehow always function in blissful tandem with a phone camera and web browser, informing us how much that tuna roll is going to cost or how to apply as a test subject at a local university that pays cold hard cash.

Back to the programming. Even though I’ve been getting into Python and C++ these days, my typical setup usually includes C# in Visual Studio and / or HTML for simple tasks (you already knew this about me). Since I am an independent software vendor (ISV), I strive not to rely on any third party tools or libraries unless it’s from Microsoft. Who wants to deal with outside vendor support, licensing, fees, bugs and features you have no control over, endless upgrades, etc.? Not me, I already have Office 365 for that. Besides, we’re in the age of ChatGPT, and whipping up a .NET class library shouldn’t be a big deal, right?

The following are screen shots from a recent conversation with ChatGPT. Prompt engineering is definitely a thing, and each new model released by OpenAI seems to have its own ways of pushing back on requests and prolonging conversations. In reality, the task [of ChatGPT writing code] can usually be completed faster than the time it takes to type up a new prompt and ask ChatGPT the same question a second time while scrambling to present it in an acceptable way. I have been writing code for 30 years, and being a software developer has never been this… slightly irritating.

And so it begins

is there a good qr code library from microsoft or azure or openai that can generate a qr code from a url? otherwise, can i create a simple function that would just need to convert a standard https url to a qr code bmp?

The response

If you want no dependency beyond image encoding, you still need something to actually generate the QR matrix unless you implement the QR spec yourself, which is not worth it.

The model used during this conversation was GPT 4.5 Thinking Standard (I think), but the initial response seemed fairly typical of every model. Writing this kind of code yourself – a “QR matrix” or “QR spec” or whatever – is simply not worth it. ChatGPT appeared as though it was shirking its duties and, more likely, trying to prevent those precious precious conversation tokens from having to be generated. “For .NET,” ChatGPT declared, “the usual answer is a small NuGet package like QRCoder.”

It felt like I had seen this type of response 100 times before and I quickly realized that I probably should have just traveled back to the Stone Ages and “Googled it.” Seeing Google ai in search results might be annoying, but once you scroll past the half-assed response from Gemini, you can easily scan links to QR Code libraries for .NET and you can do it without waiting for ai to “think” first.

Here is the search phrase I typed into my Edge address bar. Less time “prompting” and less time taken by the system to respond. Same result – use QRCoder. Why even bother with ChatGPT?

.net 8 qr code generator nuget free

Back to the conversation – I begin to ask myself why ChatGPT was pushing back so much. Was it really just too hard to create a QR code generator? Is there really that much math and whatever behind the scenes that creating your own app is some kind of monstrous up hill climb both ways in the snow? Would my investigation into ChatGPT’s reasoning lead me towards accepting reality and opening up NuGet Package Manager in Visual Studio and installing a third-party library? I couldn’t handle the thought. So, I decided it was time to get serious with ChatGPT.

um, u sure i can’t just create one myself using .net 8 and csharp? keep it simple for now? i want to pass a url and receive a bitmap

Now, maybe I’m just confused as to what “not realistically simple” means in the world of software development. But according to the response I got from ChatGPT, I guess a few hundred lines of code surpasses that threshold. Having never really thought about what “a lot of code” is myself, I quickly tried to come up with an estimate as to how many lines of code I have saved throughout various projects. I have no idea honestly, but it has to be something like, 500k lines of code written and generated…?

Here’s what ChatGPT thinks about all that

That’s a few hundred lines minimum even for a basic, correct implementation.

We take note of the second suggestion provided by ChatGPT: don’t install a NuGet package, just call a public API over the Internet! That’s a nice idea for something quick and small scale, but if you need something reliable and professional, it’s still not your first choice.

I checked – the API suggestion provided does work so it’s not the worst response. But after reading the entire reply, I could tell that ChatGPT was probably just feeling lazy (and it wasn’t even Thursday). So, I ignored the whole “But that’s still ~300-500 lines” remark and created a third and final prompt using the stern voice of a seasoned software developer.

give me no less than 1000 lines, i will create a new class library, so write it in a way that allows me to reference it and call a function, i want something good, take your time and make it right

ChatGPT responds immediately

I’m building this as a self-contained C# library: encode URL to QR matrix, add Reed–Solomon ECC, choose mask, and emit BMP bytes with no external packages.

Seems promising! So, I wait… and wait… and about 9 minutes later, I start seeing code. Huzzah! It’s finally working, but would the system actually complete the task correctly? Are my dreams of having a personal QR code generator finally about to come true? Would I get 1000 lines of awesome C# that builds right away or would I be spending then next hour debugging “somebody else’s” code? The tension – and the app – were building.

A few more minutes go by, I practice a new song on the guitar, and before I know it, the code is complete! ChatGPT even provides me a few examples of how to use the new class library it created.

Amazing! We’re almost done. After creating a new project in Visual Studio and writing some quick test code that saves the generated BMP to the local App Data Temp folder, I press play.

It built! It runs!

It didn’t crash!

There’s an image in the folder!

It looks like a QR code!

It scanned! Wow, it actually works!

FIRST. TRY. I guess that’s why we still use ChatGPT?

Here’s the QR code it generated, it points to a local network address (192.168.x.x) so it won’t really get you anywhere

I have to admit, I was kind of shocked. But I really shouldn’t be! ChatGPT is kind of like the magician that is constantly misfiring and never seems to get it right until, all of a sudden, prest-o change-o, there’s the rabbit. Was the magician misfiring or was this response from ChatGPT given to me on purpose? That rabbit was there the whole time, wasn’t it? I’m kind of kidding but kind of serious…

I could have left it at that and started playing with my shiny new QR code generator and its easy to use public functions, but my kind of serious side decided to take it a few steps further. Was this .NET code really all that? Am I trying to do something crazy in C# that I’ve never done before that’s like, I’ll never understand it or ever use it in another project? This little generator isn’t that big of a deal, right? Besides, what kind of class name is PureQR, honestly?!

Let’s dive into the code and take a look at the using statements to see what kind of libraries this sucker is referencing

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

Ok. Nothing new here. It actually seems pretty light. What about the guts? Were there no less than one thousand lines, as requested? Yes! Sweet. So, where’s the part that’s creating the QR matrix or whatever? Where’s Morpheus? I start digging further into the code and find a few things that seem interesting. One is a section for QR tables. I noticed there weren’t many comments, so, I ask ChatGPT for the top 10 coolest things about this code that a software developer might not know about or think is awesome and to answer like a surfer dude from the 80s.

  1. Totally tubular zero-dependency QR stack. This thing doesn’t lean on System.Drawing, image libs, or QR packages — it builds the whole wave itself: encoding, masking, Reed-Solomon, and BMP output. That’s rare and pretty boss.
  2. The public API is actually clean, man. CreateBmp, CreateUrlBmp, TryCreate..., Save..., plus the richer Create(...) result path — that’s a nice layered design. Casual devs usually miss how hard it is to make a low-level library feel easy up top.
  3. It does smart mode selection. QrSegment.MakeBest() auto-picks numeric, alphanumeric, or UTF-8 byte mode. That’s rad because QR size can drop hard when you avoid byte mode for simple text.
  4. The ECC boost option is sneaky-awesome. BoostErrorCorrection keeps the same chosen version if possible and quietly upgrades resilience. A lot of devs never think to separate “fit size” from “best survivability.”
  5. The mask auto-selection is legit spec-style work. It tries all 8 masks, scores penalties, then keeps the best one. That’s not just “make a QR”; that’s “make a QR scanner-friendly,” dude.
  6. The BMP writer is gloriously raw. It writes a 24-bit BMP header by hand, handles row padding, flips vertical scanline order correctly, and emits bytes directly. That’s old-school systems craftsmanship.
  7. The code is doing finite field math for Reed-Solomon like a proper sea wizard. The exp/log lookup tables and cached generator divisors are the kind of stuff many app devs never touch, but it’s the magic that makes busted QR codes still scan.
  8. The alignment/finder/version/format pattern placement is all separated into explicit drawing routines. That is way cool because the QR spec is gnarly, and this code makes the geometry readable instead of turning it into a mystery reef.
  9. The BitBuffer plus segment append model is tighter than a neon wetsuit. It builds exact-width bitstreams, appends terminator bits, aligns to bytes, and pads with 0xEC / 0x11 like the actual standard. That’s the kind of detail that makes homemade encoders either work or wipe out.
  10. GetModulesCopy() returning the matrix alongside BMP bytes is secretly excellent. Most libs just hand you an image and bounce. This one gives you the raw module grid too, which means custom renderers, SVG, PNG, canvas, thermal printer output, whatever — endless beachside possibilities.

Bonus splash: the nullable annotations and guard methods make the whole thing feel modern C#, even though the underlying vibe is straight-up low-level hacker garage magic.

Come to think of it, when I first saw the code being generated, I definitely noticed the nullable annotation at the very top. I never put code before using statements when I’m writing C#, so that definitely stood out. Here’s what ChatGPT said when I started asking about features and versions.

That file is using a C# 8.0 feature.

#nullable enable and string? for reference types were introduced with nullable reference types in C# 8.

And no, before that you could not meaningfully use string? as a nullable reference-type annotation.

Before C# 8:

  • int? worked, because nullable value types existed for a long time
  • string? was not the nullable-reference-type feature
  • reference types like string were already allowed to be null, just without compiler nullability analysis

Also important: your code uses a few newer syntax features too, not just C# 8. For example:

  • #nullable enable → C# 8
  • init; properties in QrBitmapResult → C# 9
  • is not null pattern → C# 9

So the file is not purely C# 8 overall. It looks like it needs at least C# 9 as written.

Magic!

It seems like the C# solution that was generated is working perfectly, completely isolated from third-party libraries and cloud infrastructure, and generating real QR codes. Exciting! But I wasn’t done there. I immediately start thinking about how I could provide myself and others with a simple way to use this technology without having to create a whole .NET solution or cloud app to run it. When you don’t want server side, you go client side, and JavaScript is always next up to bat.

I start a new conversation and send the C# class library back to ChatGPT.

would it be possible to convert this into a javascript app?

ChatGPT starts to go off the deep end. At first, it gives a nice description about what maps directly from C# to JavaScript. Then it starts talking about using Node.js, creating 9 different code files, building a command line interface, etc.

I guess I should have been more specific because I avoid Node like the plague. So, I ask again, this time for ChatGPT to provide me with a single page HTML app, complete with a text box, image viewer, and JavaScript written right in.

make it a single html file with javascript code in it, take what i just gave you and port it, the UI should be one simple textbox for the link, anytime the textbox input changes or whatever, update the qr code that is displayed on the page directly above the text box, dispay it as an image with image bytes generated from the js you port, nothing fancy, no tricks, one complete html file with a javascript port of my csharp generator

After thinking for about 6 minutes, it responds.

Done: qr_port.html

Looks like it worked! But I haven’t seen this in a while… ChatGPT has returned a link to an html file in its response. Uh oh. I click the link and am not surprised when I get a pop up message that says the file is no longer available. The html has disappeared. Magic!

I ask one more time, specifically, for the code to be returned in a code window

There we go. Without worrying how many lines of code were returned, I save the HTML / JavaScript into a text file, serve it locally in my browser, and… it works as expected. I’m too emotionally drained at this point to be excited, but it’s pretty darn cool that you can do something like that in a matter of minutes.

Even though I’ve used ChatGPT every day for the last three plus years, it still can really feel like magic. The hour or so I spent creating this solution was definitely “worth it.” Typing up this highly informative and entertaining blog post took way longer!

After testing the app a bit more and deciding on an awesome new name for my QR code generator, I publish both the C# class library and the HTML one-pager to GitHub under the MetroShare QR Dude project. You can actually serve that web page and generate QR codes directly from GitHub. Gnarly, bro.

You can see all of the code – C# and HTML / JS – and try the live demo here

https://github.com/metrosharesolutions/QRDude

A few days later, I was excited to show my girlfriend another one of my crazy ideas. She uses QR codes all the time, and it’s fun to go through some of the “behind the scenes” of every day technology. I give her the link to QR Dude and she creates her own QR code. Awesome! Then, something happens that seems to happen every time I let her try one of my awesome new apps. It doesn’t work. The QR code that was generated would not scan on her phone. WHAT?!

That couldn’t be true. I had created countless QR codes in a matter of days and had even implemented the QR code generator into one of my apps. Tested printouts. I just published code to GitHub and now the whole Internet is probably generating QR codes that don’t scan. What do you mean it’s not working?! Well, I verified. Nope. Not working on the iPhone. Works great on my Android every single time. Not on the iPhone. Strange and completely unexpected.

I guess maybe I’ll take some time this weekend to see what’s happening. I have to fix up QR Dude so that it works for iPhone too. Looks like it’s back to debugging somebody else’s code.

QED


Leave a Reply

Your email address will not be published. Required fields are marked *