In Perl, a scalar is represented as $scalar, an array as @array, and a hash as %hash. In PHP all variables are represented as $var. In C or C++, you declare your variables, so int i; int array[25];. Java uses C like declarations.
JavaScript can’t make up its mind, so everything can be anything.
I also program in Python and other languages. The syntax gets me. In addition, each language has its set of libraries to do more complex things.
My fingers get confused. In addition, when programming in JavaScript, you need to know what framework you are using and what style sheets you are working with.
I decided to use Grok as a co-worker for coding.
The server will be sending a
The framework is Bootstrap. We have jquery available but I would like to avoid using it.
We need to provide a multilevel drop-down that will allow the user to make selections within that large select element. We need to display their current selections. The user needs to be able to remove a selection.
Tell me the goals, and what needs to be done before providing code.
What Grok gave me was an excellent starting point. The HTML was clean. The JavaScript was well structured. The code matched my prompt.
And it was broken.
I explicitly stated that I was providing the input data as a hidden, multi-level, unordered list. Grok took that list and cloned it, including all the ids. This breaks things. There was no reason to do the clone. It just happened to be a pattern Grok had seen on the net.
For the next five hours I fought with the code. At first, Grok was able to do revisions exactly as I expected and wanted.
Then it went off the reservation.
I had refactored a large anonymous event listener to an explicitly defined function. Grok had no problems doing that. Then it proceeded to revert to the anonymous event listener again and again.
This is because anonymous event listeners are the norm in JavaScript. Nobody has an issue with attaching duplicate event listeners to a few hundred or thousand elements. Nobody cares that the code gets crowded, with it being difficult to see what is outside the scope of the listener and what isn’t.
Grok also had a horrible time sticking with the current version. I would tell it to correct one line, and it would decide I was talking about something else entirely and revert a revision or more.
Overall, it took me about 8 hours to get the JavaScript, CSS, and HTML to the point where I was happy with the code.
The biggest strength was in how it knew the different patterns. My first pass used dropdown menus. That wasn’t working. I switched to accordion style. Grok originally used Bootstrap-5, when I told it to use Bootstrap-4, it just made the changes.
One of the things that was extremely helpful was getting rapid confirmation that a feature didn’t exist.
When a feature does exist in a library or framework, it is often trivial to locate it. When it doesn’t exist, that is harder. Do you have the correct search terms? Does the function exist under a different name? Does that feature not exist, but there is a quick, well known, method that does the same thing?
Grok is a tool in the tool chest. I will continue to use it. It is getting better every month.

