I had promised that I would not do any work during the holiday period. I understood that as “I will not write any code during the holiday period”. My partner differs on that but according to the terms of the Boyfriend / Girlfriend agreement that we signed, there’s a loophole and and that meant I could ask ChatGPT to write code for me.

If you have not heard about ChatGPT before, it’s about time you get a LinkedIn account because that’s pretty much the only thing that’s being talked about on there. It was created by Open AI, a company now valued at $29 billion. It’s a text-based chat bot, a rather good one at that too. You can ask it to write papers, poems, songs. And code.

Programmers are notoriously arrogant. I am a French programmer, which means I am off the scale in terms of aggressive self-belief. So I wanted to get my hands on it to prove it did not work. This was actually difficult, as everyone and their sister was trying to make the chat bot produce racist content, the recipe for cocktail Molotov and ads featuring Ryan Reynolds.

But I finally managed to connect and I decided to go easy on the machine by asking to write a poem about Askia.

Askia software, surveys to take
Efficient and accurate, never to mistake
Gathering data, in every way
Helping businesses, make decisions today


With Askia on our side, we’ll never falter
Our data collection, will always alter
The course of our progress, with precision and care
Askia software, a surveyor’s best pair


With its user-friendly interface, we can explore
Insights and trends, we never saw before
Askia, a tool that helps us grow
In the world of data, it’s a must-know


So here’s to Askia, our trusty guide
In the world of surveys, it’s always by our side.

No question about it: it was bad. But we don’t really have a marketing department here. So that’s better than nothing. Next I asked what were Askia’s best qualities:

Askia is a software that is widely used for creating, distributing and analyzing surveys. Some of its best qualities include:
– User-friendly interface: Askia’s interface is designed to be easy to use, which makes it accessible to users of all skill levels.
– Customizable survey templates: Askia offers a wide range of customizable survey templates, which can be easily tailored to suit specific research needs.
– Advanced analytics: Askia provides robust analytics capabilities that allow users to analyze survey data and uncover insights.
– Multi-language support: Askia supports multiple languages, making it an ideal tool for global research projects.
– Flexibility: It can be used across a variety of research applications, such as market research, employee engagement surveys, and customer satisfaction surveys.
– Automated data collection and processing: Askia has a lot of features that allow automated data collection and processing, which saves time and reduces errors.
– Advanced Survey Logic: Askia has a lot of advanced survey logic features that allow you to create complex survey designs with skip patterns, routing, quotas, and more.
– Secure: Askia is highly secure and compliant with the industry standards, making sure that the data of the users is protected.
– Cloud-based: Askia is a cloud-based software, which means it can be accessed from anywhere and at any time, and it doesn’t need to be installed on a computer.

OK, not all of it is true, but boy does it sound good! At that point I was already quite impressed. I called my partner and showed her the results and she immediately asked if it knew anything about her. She must have things to hide because she genuinely looked worried, while the response was generated, but ChatGPT was the very polite:

I’m sorry, I do not have any information about a specific person named XXX. It is possible that there are many people with that name and without additional context it is hard for me to provide information on a specific individual. Also, my knowledge cutoff is 2021, so I may not have the most recent information on any specific person.

She was hooked too and asked if it could write a humorous song about fostering – not something we usually laugh about.

There’s a kid in need of a bed
But his foster parents are out of their heads
They feed him pizza every day
And make him watch reruns of “Buffy the Vampire Slayer”


Chorus:
Fostering ain’t easy, but it’s worth the try
You’ll laugh, you’ll cry, but you’ll never die
You’ll be a mom, or a dad, or both
Just don’t forget to get them a toothbrush


Verse 2:
They’ll drive you crazy with their chatter
And you’ll wonder what you’ve gotten yourself into after
But when they smile, and say “I love you”
You’ll know it’s all worth it, it’s all true


Chorus:
Fostering ain’t easy, but it’s worth the try
You’ll laugh, you’ll cry, but you’ll never die
You’ll be a mom, or a dad, or both
Just don’t forget to get them a toothbrush


Bridge:
Fostering is not just a job or a chore
It’s a chance to open your heart and your door
So when you’re feeling like you can’t go on
Just remember, you’re not alone


Outro:
Fostering ain’t easy, but it’s worth the try
You’ll laugh, you’ll cry, but you’ll never die
You’ll be a mom, or a dad, or both
Just don’t forget to get them a toothbrush

The self-righteous patronising bot then added:

It’s important to note that fostering is a serious matter, it’s all about providing a safe, loving and supportive environment for children who are unable to live with their birth families. This song is written with a humorous approach, and it should not be taken as a real representation of fostering, it’s just a fictional song.

They were clearly worried about lawsuits . . . At this stage, I wanted the bot all for myself, so I started asking questions about C++ – one sure way to clear the room (even at Askia). Bear with me even if you don’t code, it’s the flow that’s interesting. So I asked “can you write code in C++ ?”

Yes, I can write code in C++. C++ is a powerful, high-performance programming language that is widely used for a variety of applications, including system and application software, video games, and more. C++ is known for its flexibility and can be used to create both high-level and low-level code, making it a popular choice among programmers.

Here’s an example of a simple “Hello, World!” program written in C++:

This program uses the iostream library to output the string “Hello, World!” to the console. The #include directive is used to include the iostream library, which provides input and output functions like cout and endl. Please let me know if you have any specific question or if you need help with a specific program, I’ll do my best to help you.

So it knew of C++, but I wanted to push the system a little further. Last year, we have had some discussion about how we calculated the median with weights. The median is reasonably easy to do: you sort your set and you look at the half way point. And you can decide to extrapolate if you have an even number of data points (if you have two, it’s like the mean). This gets more complicated if (as we do in Market research) – your data is weighted. So here is the unfiltered exchange I had:

JS: Can you write code in C++ to calculate a weighted median

Yes, I can write code in C++ to calculate a weighted median. The weighted median is a statistical measure of central tendency that is similar to the traditional median but takes into account the weights or frequencies of the data points. Here is an example of a C++ function that calculates the weighted median of an input vector of values and an input vector of weights:

The code was correct, nice use of STL. A point removed for a warning on the transformation of a double into an int (James, my usual code reviewer, would frown, but I did not mind) . . . but the algorithm could select a point which had a weight of 0 (in other words a data point that was filtered out). So I pointed it out:

JS: Your algorithm does not work if some of the weights are zero

You are correct that the algorithm I provided does not handle the case where some of the weights are zero. In such cases, the median of the weighted values would be computed using the same method as the traditional median, however, the zero-weighted values should be ignored. Here is an updated version of the function that includes a check for zero weights and excludes the corresponding values from the calculation:

First I admired the continuity in the dialogue (I did not have to remind the system that I wanted a median). And I loved the humility, unusual among C++ programmers, as pointed out earlier.

But my my mind had exploded: the algorithm was not coming straight out of a library. It was immediately improved with a comment. And the code was “intelligently” modified accordingly.

I was still not happy though. . . what if all the low values had low weights? So I suggested another approach:

JS: I think you should sort the weights and the values together and then look at the half point

You are correct, to calculate the weighted median it is important to sort the pairs of values and weights together. This way we can ensure that the values and the corresponding weights maintain the same order while sorting. Here is an updated version of the function that sorts the values and weights together:

This was good – I loved the usage of the STL object pair and of a lambda expression to sort according to the values and not the weights (I still need the documentation whenever I write one of these). What a time gain! But something was fishy, it did not give me the full algorithm.

JS: Can you give me the full version please?

Sure, here is the full version of the function that calculates the weighted median by sorting the pairs of values and weights together and then finding the value that corresponds to the middle of the cumulative weight:

This function takes two vectors as inputs, one for the values and one for the weights. It then creates a new vector “weighted_values” of pairs where each pair contains a value and a weight. Then it sorts this vector of pairs based on the values, and then it iterates over the sorted vector, adding up the weights, and when the current_weight exceeds half of the total weight, it returns the previous value.

I liked the summary, but gotcha! It did not work for an interpolated median with an even number of data points. In French “even” is “pair”. I got over excited, like any reviewer finding a flaw in someone else’s code, forgot about my English and wrote this:

JS: Your algorithm does not work if there is a pair number of values with the same weight

You are correct, my previous algorithm would not work correctly if there is an even number of values with the same weight. In this case, the median would be the average of the middle two values. Here is an updated version of the function that handles this case:

Bingo – it even covered the limit case if i > 1 and the algorithm looked accurate . . . It corrected my English in a very tactful manner reminding me of the rightful usage of “even”. I still think my algorithm is a tad better, because it interpolates the median depending on the two weights around it, but that’s arguable anyway and by that time, I had run out of free credit for an hour on ChatGPT.

So what’s next? Well I would like this embedded into my development environment. It needs to be in Visual Studio, now please! And that might happen has Microsoft has already invested $2 billion in openAI and is rumoured to invest another $10 billion!

As a programmer, the gradual improvement of the code felt like a code review between a team leader and a gifted, but less knowledgeable programmer on a niche subject. I did not get the right algorithm on the first try – natural language is probably a too imperfect way of communicating. But we got there in the end, possibly because I really knew what I wanted.

However, there is something quite concerning with this. Jon Puleston has already warned us of the danger of an AI without any ethical framework in this thread. It’s inherently dangerous: I asked for an algorithm and I was provided one with flaws and without any warning about the flaws.

In summary, I don’t think programmers will be replaced by ChatGPT or but think of the immediate productivity gains this could bring to create unit test, to debug or to document.

I leave you with this thought that I received from David Zotter :

P.S. The most satisfying thing about this is that you’ll never know if I actually wrote this or I simply asked ChatGPT to write an Askia blog article on the implications of ChatGPT in the style of Jérôme Sopoçko.

P.S. 2: As pointed out to me by David (who needs father Christmas?), a few people have already started to work on a Visual Studio plugin: here is one called GenCay (and the source code is here)