Ghost in the IDE: Testing Replit’s AI Helper, Ghostwriter
Replit is advancing with the spirit of AI, and has more than a ghost of a chance to succeed with its Ghostwriter product, says David Eastman.
Sep 30th, 2023 7:00am by
Image via Unsplash
My aim is to use Ghostwriter on a ‘Repl’, so I’ll start with 1000 [Flags] public enum OccurrenceType {
None = 0,
OccurrenceA = 1,
OccurrenceB = 2,
OccurrenceC = 4,
OccurrenceD = 8
}
…
private OccurrenceType occurrences { get; private set; } = OccurenceType.None
This technique is a compact way of storing events; it is also cheap to check whether the event has occurred. So I can represent OccurrenceA and OccurrenceC happening by bitwise ORing them together in a variable:
0000 (Nothing has happened)
OR
0001 (OccurrenceA happened)
OR
0100 (OccurrenceC happened)
-----
0101
Oddly, the Run button didn’t seem to work…at first. Then I noticed that my CPU maxed out, but it did eventually manage to print out “Hello World”. Hmm. I guess I can throw
That is:
public void SetOccurrences(OccurrenceType occurrence)
{
this.occurrences = occurrence;
}
This is wrong, but I didn’t really help much: this would have been better named “AddOccurrence”.
I rejected the hint and tried again, this time improving the name a little:
And this is correct. It is ORing the new occurrence in, not setting it directly. I still should have named it better, however.
I was less fortunate with the method to check whether an occurrence has, er, occurred. It took many rejections, but eventually, I got the right bitwise calculation answer:
This is the correct way to use the flags. It ANDs the storage variable with the occurrence to check for, treating it as a mask. Any non-zero result shows that the occurrence occurred. Again, maybe if I gave my ethereal partner a better clue in the name, perhaps HasOccurrence, it would have come to the right answer a little quicker.
I wanted to see if I could persuade it to use HasFlag, which is available in .NET 7. While it didn’t suggest this (had I looked in the project file, I would have seen that it wasn’t using this framework, so it never would suggest this) it did improve the suggestion a little:
public bool IsOccurrence(OccurrenceType occurrence)
{
return (occurrences & occurrence) == occurrence;
}
Just one more thing; a debugging task. For the flags attribute to work, the enums must have the expected binary values. What would happen if I set OccurrenceD to 5? Ghostwriter didn’t appear to notice, and there did not appear to be a “debug” option. However, I asked it to “Explain the code” and got this excellent response while the error was in place:
This is absolutely correct, and even finds the bug during analysis — which is almost human.
Altogether, while Ghostwriter didn’t appear to perform very proactively for me, it was certainly quicker to set up than Visual Studio and Copilot. I suspect with more CPU available, and a fair wind, it could behave in a more forthright style. It takes time to get used to any pairing partner, whether corporeal or otherwise. And as Ghostwriter does its haunting closer to the Replit infrastructure, I suspect sightings will be more reliable and system health will be easier to show. In short, Replit is definitely advancing with the spirit of AI. It has much more than a ghost of a chance to succeed.
YOUTUBE.COM/THENEWSTACK
Tech moves fast, don't miss an episode. Subscribe to our YouTube
channel to stream all our podcasts, interviews, demos, and more.