Do we still need application developers?

I read an article at the weekend about the ChatGPT system, which included a link about how it might be useful for programmers. A lot of the recent material on this service has concentrated on its use for generating plausible text – essays and the like. But I thought it might be interesting to take a quick look for myself at the coding capability. How much can be delegated; do we still need application developers?

Spoiler: Yes we do. But it can be useful to look a bit deeper at the good and bad.

First experiment

My first experiment was to ask it to generate a skeleton for a technology and API that I am thinking of working with in the future. What it displayed looked to be a better sample than I had been able to find with direct Google searches. Though as that Guardian piece had quoted, you had to have some idea about what you are doing first.

A friend asked me how it compared to looking up something on StackOverflow. My response was that without the discussion threads underneath, it was even harder to tell whether the generated material was accurate (and, believe it or not, SO does not always give a good answer).

Writing an MQ application

So I then asked it about writing an MQ application. I didn’t spend very long on devising complex scenarios; just the kind of thing someone might be asked to do as a beginner.

Here’s the transcript, followed by some thoughts on it:

ChatGPT Transcript

Me: How should I write a program to put a message to IBM MQ

GPT: To write a program to put a message to IBM MQ, you will need to do the following:

  1. Install the IBM MQ Client libraries on the machine where your program will run.
  2. Import the necessary libraries in your program. In Python, you can use import pymqi to import the IBM MQ libraries.
  3. Create a connection to the IBM MQ Queue Manager. You will need to provide the hostname, port number, and queue manager name for this.
  4. Create a queue object by calling pymqi.Queue().
  5. Put the message to the queue by calling the put() method on the queue object and passing the message as an argument.

Here is an example of how this can be done in Python:

import pymqi

queue_manager = "QM1"
channel = "CHANNEL1"
host = "localhost"
port = "1414"
queue_name = "Q1"

# Connect to the queue manager
qmgr = pymqi.connect(queue_manager, channel, host, port)

# Open the queue
queue = pymqi.Queue(qmgr, queue_name)

# Put the message to the queue
queue.put("Hello, World!")

# Close the queue
queue.close()

# Disconnect from the queue manager
qmgr.disconnect()

Me: and how about in C

GPT: To put a message to IBM MQ using C, you will need to do the following:

  1. Install the IBM MQ Client libraries on the machine where your program will run.
  2. Include the necessary header files in your program.
  3. Create a connection to the IBM MQ Queue Manager. You will need to provide the hostname, port number, and queue manager name for this.
  4. Create a queue object by calling MQOPEN().
  5. Put the message to the queue by calling the MQPUT() function and passing the message as an argument.

Here is an example of how this can be done in C:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cmqc.h>

int main(int argc, char **argv)
{
    MQHCONN conn;
    MQOD objdesc = {MQOD_DEFAULT};
    MQMD msgdesc = {MQMD_DEFAULT};
    MQPMO putmsgopts = {MQPMO_DEFAULT};
    MQLONG compcode;
    MQLONG reason;
    MQHOBJ obj;
    char buffer[1024];

    // Connect to the queue manager
    MQCONN("QM1", &conn, &compcode, &reason);

    // Open the queue
    strcpy(objdesc.ObjectName, "Q1");
    MQOPEN(conn, &objdesc, MQOO_OUTPUT, &obj, &compcode, &reason);

    // Put the message to the queue
    strcpy(buffer, "Hello, World!");
    MQPUT(conn, obj, &msgdesc, &putmsgopts, strlen(buffer), buffer, &compcode, &reason);

    // Close the queue
    MQCLOSE(conn, &obj, MQCO_NONE, &compcode, &reason);

    // Disconnect from the queue manager
    MQDISC(&conn, &compcode, &reason);

    return 0;
}

Me: can I use Node?

GPT: Yes, it is possible to use Node.js to put a message to IBM MQ. There are several libraries available for Node.js that provide an interface to the IBM MQ Client libraries, such as “mqlight” and “ibmmq”.

One library you can use is the “ibmmq” which provides a set of classes that wrap around the IBM MQ C client libraries.

Here’s an example of how you can use the “ibmmq” library to put a message to IBM MQ in Node.js:

const ibmmq = require('ibmmq');

const mqQueueManager = "QM1";
const mqChannel = "CHANNEL1";
const mqHostname = "localhost";
const mqPort = 1414;
const mqQueue = "Q1";
const mqMessage = "Hello, World!";

// Create a new MQI connection handle
const mqConn = ibmmq.open();

// Connect to the queue manager
mqConn.connect({
    qMgr: mqQueueManager,
    channel: mqChannel,
    host: mqHostname,
    port: mqPort
});

// Open the queue
const mqQueueDesc = {
    ObjectName: mqQueue,
    ObjectQMgrName: mqQueueManager
};

mqConn.openQueue(mqQueueDesc, (error, handle) => {
    if (error) {
        console.log(`Error: ${error}`);
        process.exit(1);
    }

    // Put the message to the queue
    mqConn.put(handle, {
        buffer: mqMessage
    }, (error) => {
        if (error) {
            console.log(`Error: ${error}`);
            process.exit(1);
        }
        
        // Close the queue
        mqConn.closeQueue(handle, (error) => {
            if (error) {
                console.log(`Error: ${error}`);
                process.exit(1);
            }
        });
    });
});

// Disconnect from the queue manager
mqConn.disconnect();

You can also use other libraries too like “mqlight” to interact with IBM MQ, you should check the documentation and samples of that library as well and decide based on your requirements.

Me: how do I compile the C program

GPT: To compile a C program that uses IBM MQ libraries, you will need to have the IBM MQ client libraries and header files installed on your machine. You will also need a C compiler such as GCC (GNU Compiler Collection) or CLang.

Once you have the IBM MQ client libraries and header files installed, you can use the following command to compile your program:

gcc -o <executable_name> <source_file.c> -I<path_to_mq_header_files> -L<path_to_mq_library> -lmqm
  • -o <executable_name> specifies the name of the executable file that will be created.
  • <source_file.c> is the name of the C source file that you want to compile.
  • -I<path_to_mq_header_files> specifies the path to the IBM MQ header files.
  • -L<path_to_mq_library> specifies the path to the IBM MQ libraries.
  • -lmqm specifies the IBM MQ library that your program will link against.

For example, if the header files are located in /opt/mqm/inc and the libraries are located in /opt/mqm/lib, you can use the following command to compile your program:

gcc -o myprogram myprogram.c -I/opt/mqm/inc -L/opt/mqm/lib -lmqm

This will create an executable named “myprogram” that you can run to put the messages to IBM MQ. Note: the above command is for Linux and Unix based system. For windows the process is different and it may vary depending on your installed runtime and system.

Some thoughts on the transcript:

  • My first thought was the interesting choice of Python as the default language to demonstrate a program.
  • It is maintaining context that I’m asking about MQ, when also asking explicitly for a C example. The C program is not obviously derived from the MQ product samples; the variable names are different for a start.
  • Using strcpy is a surprising (and possibly dangerous) choice.
  • The Node.js question does point at the “right” library, but the example code is broken in several ways. It would not work.
  • The C context still persists when asking about the compile steps. I liked that it first gave a generic answer for compiling any program but then gave an MQ-specific version using the default paths.

Conclusions

This is only one of a number of code generating services. GitHub Copilot is another well-known resource. It does look to be useful as a bootstrap capability, to get something that is close to runnable. But you really do need to know what you are looking at, and to be able to correct problems.

Just like copy/paste from StackOverflow you cannot just assume correctness. Development skills in interpretting fragments are still going to be essential.

2 thoughts on “Do we still need application developers?”

Leave a Reply

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