playing with chatgpt

While I’ve been playing some with ChatGPT, I’m just not writing a blog post about it. It seems to be learning>L The first time I asked it about CodeRanch, it hadn’t heard of it. I tried again and got an answer. In this blog post, I show three different styles of questions.

Joke

I provided the prompt “tell me a joke about java lambdas” and got:

Sure! Here’s a joke about Java lambdas:

Why was the Java lambda feeling depressed?

Because it was an anonymous function without a name!

I hope you found that joke amusing. Do you have any other questions about Java or something else?

This joke amused me so mission accomplished.

Bio

When providing the prompt “who is jeanne boyarsky”, I got:

Jeanne Boyarsky is an American computer programmer and author who has written several books on Java programming. She is also a co-author of the popular Java certification study guide “OCA/OCP Java SE 8 Programmer Certification Kit.” In addition to her work as an author, Boyarsky is also an experienced Java developer and has worked on a variety of software development projects. She is a frequent speaker at software development conferences and has taught programming courses at both the college and high school level. Boyarsky is also known for her contributions to the open source software community and has been recognized as a Java Champion by Oracle.

A lot of this my bios, but not all of it. Taking it apart:

  • Jeanne Boyarsky is an American computer programmer – many of my bios say I’m from New York City. ChatGPT generalized that to the country.
  • and author who has written several books on Java programming – this is true although we usually listed the books rather than say “several”. But counting and generalizing is reasonable.
  • She is also a co-author of the popular Java certification study guide “OCA/OCP Java SE 8 Programmer Certification Kit.” – This language is in my conference bios. Scott actually wrote it this sentence and I copied it into my bio. However while this is factually accurate, that was published about 6 years ago. We’ve written Java 11 and 17 books since. A human would have highlight the more recent additions.
  • In addition to her work as an author, Boyarsky is also an experienced Java developer and has worked on a variety of software development projects. She is a frequent speaker at software development conferences and has taught programming courses at both the college and high school level. Boyarsky is also known for her contributions to the open source software community and has been recognized as a Java Champion by Oracle. – The rest of this is also paraphrased from various conference bios. I’m pleased ChatGPT didn’t attempt to do math to list my number of years of experience. I’ve read that arithmetic is not ChatGPT’s strong suit.

Coding

I tried a harder prompt of “how do i write a postgres sql statement to create a database table for id, link and a boolean toggle?” to see if I got ChatGPT to write a bit of code I was going to write for the CodeRanch forum software. I got

To create a database table in PostgreSQL with three columns – an ID column, a link column, and a boolean toggle column – you can use the following SQL statement:

Copy code
CREATE TABLE my_table ( id INTEGER PRIMARY KEY, link TEXT, toggle BOOLEAN );

This statement creates a table called my_table with three columns:

  • id: an integer column that is set as the primary key for the table. The primary key is a unique identifier for each row in the table and is used to identify and distinguish individual rows from one another.
  • link: a text column that will store a string value.
  • toggle: a boolean column that will store a true or false value.

Note that you can customize the names and data types of the columns to fit your specific needs. For example, you could use a different data type for the ID column, such as a serial data type, or you could give the columns different names.

I hope this helps! Let me know if you have any other questions.

The code was syntax highlighted and had a copy option. The explanation was detailed and ChatGPT inferred my key and types. It didn’t get the names of the fields (or table) right because i didn’t supply them in my prompt and can’t be expected to read my mind. And it was almost what I wanted. I needed “character varying” rather than “text” which shows the importance of knowing what you are doing in the prompt.

Leave a Reply

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