Re:It’s Like GPT-3 but for Code – Fun, Fast, and Full of Flaws
by jedimastert on Saturday March 19, 2022 @05:28PM
(#30737735)
Sometimes 2 lines of code is just better than 6 and not worth the extra brain cycles.
There's DRY, then there's premature optimization.
Re:It’s Like GPT-3 but for Code – Fun, Fast, and Full of Flaws
by josefx on Saturday March 19, 2022 @06:54PM
(#30738307)
> Sometimes 2 lines of code is just better than 6 and not worth the extra brain cycles.
I am unsure about what could possibly be better about them? Twice the chance to misspell one of the string constants? Twice the time to write the code, which in this case seems to be the big blocker? Twice the code to update in case any of it has to change? Twice the complexity per line of code?
Re:It’s Like GPT-3 but for Code – Fun, Fast, and Full of Flaws
by karmicthreat on Sunday March 20, 2022 @10:32PM
(#30749428)
This is pretty much the case. It was a quickly needed report of data from our ERP system and dumped into an excel sheet to use. I had not used Pandas before but seemed like a good fit for me t build this out. The people who needed this info were not very sure about what they needed, so being un-DRY is better. This is only a maybe 2 page Jupyter sheet. So it's not a huge deal.
In any case, DRY is just an optimization theme. And optimizing for understanding/intent is a higher priority for me. Sometimes they intersect, sometimes not.
Re:It’s Like GPT-3 but for Code – Fun, Fast, and Full of Flaws
by AnonCoward4 on Saturday March 19, 2022 @05:46PM
(#30737842)
I disagree that this is premature, but best practice. This example is actually a small lesson how this autocomplete can construct slightly less readable code. Of course not really a problem of the tool as you have to refactor anyway.
Re:It’s Like GPT-3 but for Code – Fun, Fast, and Full of Flaws
by karmicthreat on Sunday March 20, 2022 @10:26PM
(#30749385)
Yea, I could definitely improve this code. This was a quick excel report I build by extracting some data out of our ERP and building the report in Pandas. So those min and max values get surfaced in the output excel sheet.
It was a bit of an emergency and I was figuring Pandas out at the same time. The un-dry structure is handy for me because I can quickly tweak individual things since as a company we are still figuring out what is needed in the report.
Re:It’s Like GPT-3 but for Code – Fun, Fast, and Full of Flaws
by kimukasetsu on Saturday March 19, 2022 @10:36PM
(#30739530)
This. Copilot enables bad programming practices imo, especially through clunky APIs like pandas.
> result_dataFrame['yearOverYearMax'] = year_dataFrame.groupby('partId')['unitCost'].max()
> And big productivity booster on code entry.
Try reducing the DRY violations and you might have to write less. Almost the entire right side of the first two lines is repeated and third line is only that long because it has to recover the results from the map instead of using local variables.
While tools like boxing gloves reduce the damage your face takes it is usually better to just try and stop hitting yourself first.