My son is still at school and told me about ChatGPT, the OpenAI natural text tool that can write entire essays for you. With my mind currently wrapped around FLTK, naturally I had to find out what ChatGPT knows about our software:
>>> "FLTK (Fast Light Toolkit) is a cross-platform, lightweight graphics library for developing graphical user interface (GUI) programs. It provides a simple, easy-to-use interface for creating windows, buttons, menus, and other GUI elements, and has been widely used for developing applications in a variety of fields, including engineering, scientific computing, and finance. FLTK is written in C++ and is released under the GNU Lesser General Public License (LGPL)."
So, here is my first surprise. Sure, our synopsis is similar, but even as a non-native English speaker, this "new" synopsis seems to have much more flow to it.
When I write documentation, my German always shines through. Senteces are stilted and overly complicated, not to mention all the typos. Naturally, I asked ChatGPT for help:
> Rephrase "Widget_Bin_Window_Button: This button is used by the widget bin to create new windows by drag'n'drop. The new window will be created wherever the user drops it on the desktop."
>>> "The Widget Bin Window Button allows users to create new windows by dragging and dropping it onto the desktop using the widget bin. The location where the button is dropped on the desktop determines where the new window will appear."
Not only did ChatGPT create a nicer sentence structure with better flow, but it feels like it added information (I never wrote anything about dropping on the desktop). It feels like it read the entire FLUID docs already and has a grasp of the context. And if you don't like the response, just click "Regenerate".
Now on to the scary part. I asked:
> write a unittest for Fl_Group::add()
>>> Here is an example of a unit test for the add() method of the Fl_Group class in FLTK:
#include <FL/Fl_Group.H>
#include <FL/Fl_Button.H>
#include "gtest/gtest.h"
TEST(FlGroupTest, AddButton) {
// Create a group and a button
Fl_Group group;
Fl_Button button("Button");
// Add the button to the group
group.add(button);
// Check that the group has one child
EXPECT_EQ(group.children(), 1);
// Check that the child is the button
EXPECT_EQ(group.child(0), &button);
}
This test creates a group and a button, adds the button to the group using the add() method, and then checks that the group has one child and that the child is the button. The test uses the Google Test framework to define the test case and to check the expectations.
I mean, holy shit, it obviously knows not only that FLTK exists, it knows that FLTK has a method named Fl_Group::add(), it not only knows what that function does, it even knows how to write a freaking test to see if that function works correctly, outputting a complete and compilable piece of code that I could paste into FLTK and nobody would know. Actually I would probably be praised for adding the first true unittest.
Is that insane or what?
Maybe I can finally write the urgency needed documentation for FLUID... .
- Matthias