Hacker News new | ask | show | jobs
by wisnoskij 1327 days ago
I really wonder about the usefulness of implementing a language feature to reduce the need to copy paste in an editor.
4 comments

Generics are a language feature to reduce the need to copy and paste in an editor. For that matter, functions are a language feature to reduce the need to copy and paste in an editor.
As a library maintainer, you can't copy-paste a line for a type that isn't written yet.

As a library user, you can't copy-paste a line for a type you just created in a library you don't maintain.

Being able to do what you describe lets a maintainer create an interface for all the future types that satisfy given requirements.

Isn't that basically all language features? I could also write

    print("Hello")

    print("Hello2")

    print("Hello3")

    print("Hello4")

    print("Hello5")
(which I partially copy-pasted above) but I use a for-loop instead.
Really? You don't see the problem with trying to maintain code that's been copy-pasted everywhere with slight differences? Doesn't it seem easier to maintain one implementation of something than N implementations?