No this isnโt what you expect, comments are useful but we are as developers at all levels bad at them. Could it be that the future of documentation code comments and tests amalgamated through AI?
Iโve seen GPT4s code interpreter understand, describe and test my code and itโs only a matter of time before we move to a workflow and pipeline that takes a wholistic perspective.
Such a tool would be a guidebook of the code with unit tests right in the code, it would make source maps and plug into dev tools, it would be the unified guide to your codebase.
I think this is the death of comments but what do you think?
Top comments (8)
I think AI will be fine at describing the what but not the why.
I also think that this lack will go on to encourage better separation and naming of weird business logic functions.
But I'm an optimist at heart.
I agree about this. But I also think that AI will be able to replace lots of forms of docs and comments, and we should anticipate this.
But the "why" comments should still be a thing, and it's up to people to get this right โ which is a big maybe as to whether they will ๐
I would love to write a tool that could do this but getting traction I suspect it will take a team.
Are you familiar with Gherkin test language itโs sort of plain English
I think a tool that can scrape an entire codebase and wholisticly generate such English like tests would be the first component.
I think it should assess the health of the source and identify pain points, cheep tech debt etc. finally the tool must run decentralised owned by the org and never share data with any third party.
Anyway I feel a side side side project coming on ๐
What chatGPT4 said:
While Gherkin's traditional line-by-line structure is designed for parsers like Cucumber to read and execute tests, if you write in a more natural paragraph-based format, I can certainly help you interpret and convert it back to a standard Gherkin format.
However, note that software like Cucumber won't directly interpret freeform paragraphs as executable tests.
For example, if you provided:
I could help translate this into:
So, while I can assist with interpreting more natural text, it's important to use standard Gherkin when you actually want to run the tests with BDD tools.
I am endeavouring to find out what it can do with my new tool Amalgam โฆ what does it do? No idea ๐
I donโt think GPT/LLMs could write/replace the comments in code. The whole reason to have comments is to add context that canโt be gleaned from the code itself. If you find yourself writing comments to explain what the code does, you should try to rewrite it in a cleaner manner.
That is not to say GPT couldnโt be helpful in documenting the code overall - especially listing out specific behaviours in a way non-technical end-users can understand. But in most cases this will be written long before a line of code is written, so most of this content would already exist.
For the moment yes I agree but I am talking more about the relationship we have with comments, it could be that in a decade we have AI assistants to co -author and add that context. ๐
So I started writing amalgam and itโs interesting, in rust I can request to openai to write some gherkin tests from the code of a sample project but it strikes me that if the criteria for the feature was misunderstood by the developer then you end up with tests for the wrong feature, the tests will always pass as they are always correct so I think tests need to be updated on commit only and also would need to compare the gherkin with the ticket that created them to see if the feature is actually doing the expected.
Some kind of new test is emerging here and itโs exciting!