560 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owls only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Coding in SQL, Python, VBA, JQuery and OfficeScript using AI tools
Part three of an eight-part series of blogs
One of the immediate and obvious ways to use AI tools is to boost your productivity as a programmer. This blog shows how you can use ChatGPT 4 and Google's Bard to write programs in SQL, Python, VBA, JQuery and Office Script (probably the 5 languages Wise Owl use most).
The next AI challenge was to get help writing the following Python program:
"Create a Python function which - given a passage of text - will return a dictionary containing all of the unique words"
Again I've been deliberately slightly vague, to see how well the AI tool can guess what I meant. Let's start with ChatGPT 4 again.
Here's ChatGPT 4's answer for my question:
This is an astonishingly good answer, and scares this programmer!
How on earth can this possibly work? Not only has ChatGPT come up with a superb first answer, but it's come up with a second variant in case the first one runs too slowly.
Here's why the first answer is so impressive:
Most humans would (like Bard - see below) have just used a split function to split the input text into different words. Not only has ChatGPT used a more demanding regular expression, but it's also made sure that it accounts for case sensitivity too.
Again, most human programmers would probably have converted the words to a set to get just the unique ones, then looped over this to get the number of occurrences of each, and then somehow stored the results in a dictionary. ChatGPT has produced a concise list comprehension to do all of this in a single line of code.
ChatGPT has not just included comments within its code, but also added an insightful explanation at the end of how the code works.
Here's Bard's response to my question:
Python programming in Bard.
As for the previous SQL example this initially looks good, until you realise that the sample answer is wrong (it misses out half the words in the text). On the plus side Bard has included excellent comments, and its function would give a list of the unique words in the text passed in (albeit that it wouldn't do what the question asked, and count the number of occurrences of each word).
ChatGPT is (by a very long way) the winner here: it's hard to imagine firstly how on earth an AI tool can do this, and secondly how much better it could get. Python programmers of the world, be very scared!
|Parts of this blog|
25 Aytoun Street