Hacker News new | ask | show | jobs
by ellen364 1804 days ago
It’s early days for CoPilot, but I find myself wondering if it will eventually reduce idiomatic use of languages and increase the stickiness of old practices.

In the article, the author included this example:

  alternate_word_mapping = {words[i]: words_in_english[i] for i in range(len(words))}
That line is probably more readable than the Pythonic enumerate:

  alternate_word_mapping = {word: words_in_english[i] for i, word in enumerate(words)}
But it superficially reminded me of a style that I see on Leetcode, which rarely uses Python features like enumerate or dict.items.

CoPilot was trained on GitHub repos and many repos are mini-projects for learning a new language. Does that mean CoPilot will tend to suggest more generic, less language specific, implementations? If it does, will that change perceptions of what’s idiomatic? And will the volume of old code on GitHub influence CoPilot’s suggestions, making us slow to adopt new language features?

1 comments

I agree in general, but just wanted to add that the pythonic approach would be to avoid the explicit index entirely, with something like:

alternate_word_mapping = dict(zip(words, words_in_english))

Thumbs up, I totally missed this. Didn’t encounter this approach in the suggestions either.

That’s actually one reason why I don’t think it’s current incarnation is a good fit for learning new apis, it’s been trained on a lot of code, not all of it good.

Seems like something a future version might be able to fix, perhaps by training a new layer using just demonstrably ‘good’ code?

Agreed and an excellent point. Ironically, my example was not nearly as Pythonic as it could have been!

(V late reply as still learning how to keep track of replies on HN. But perhaps you’ll see it anyway.)