Live data from Hacker News

Ask HN: Does anyone still use code snippets?

news.ycombinator.com

41–50 of 61 posts

Re: Ask HN: Does anyone still use code snippets?

#41
Lots of them, not only fu -> function, but whole blocks of code with parameters (snipmate style). A few of half-pages of code and then dozens of little expansions, for many filetypes.

This is a result of a process I call experience distillation. I notice what code I write often but tend to either forget (bash) or outthink much faster than I can type (common syntax, libs, boilerplate), and routinely add it to snippets in hope that it sticks. Then I learn to actually use it. Once in a while I delete the unused or reshape it for second attempt with the understanding why it failed the first time.

Re: Ask HN: Does anyone still use code snippets?

#43
post #31

For scaffolding? I still use snippets (with tooling ofc). Around 85% of the time, it seems like it takes me more time to write what I want to code in natural language to an AI prompt (and then correct it) than it would to actually code what I want. The 15% of the time when I want something like "Write test cases to cover this module" is something a snippet couldn't do anyway.

> Around 85% of the time, it seems like it takes me more time to write what I want to code in natural language to an AI prompt (and then correct it) than it would to actually code what I want. That's how it should be, actually 100%. If you need scaffolding (and snippets) it means your language doesn't have (or worse, can't have) the right abstractions in its library.

I am generally fine with duplicating some of the "scaffolding" between projects to aid with readability and have less magic when trying to understand the code.

Eg. most languages would enable you to build a custom library, but then it becomes non-obvious what's exactly happening to someone diving into the project, a most engineers never bother fixing/improving the original library, and you end up with crap on top to "work-around" the poorly understood behaviour.

Eg. recently, I've fixed an internal library holding multiple locks around one tiny block of async code, rendering the entire thing synchronous, which was being worked around by devs using multiprocessing or multithreading for a couple years. I've reduced that library code to basically a couple of functions, but my preference would be to actually copy-paste those 200 lines into every component using it — while you have the problem when you want to update it everywhere, your average engineer focused on solving a different business problem will be better equipped to handle it.

My personal gripe is with the abuse of @decorators in Python, which are side-effect pits of hell (yes, the code can look really nice).

I personally don't use snippets, but I do copy-paste some of that scaffolding between projects (though I am mostly a manager these days and hardly get any time to code, so take that with a huge grain of salt) — snippets as such never added much value to me.

Re: Ask HN: Does anyone still use code snippets?

#44

I still use snippets and, since I wholly reject generative AI from my life, I don't see it changing anytime soon.

AI for search of your own snippets (or eg Xcode bookmarks) is nice even if you don't end up using any generative AI output in your code

Re: Ask HN: Does anyone still use code snippets?

#46

Earlier quoted context omitted.

> which is for creating a empty arrow function you have a snippet for four characters? `()=>`?

There's also brackets. More importantly, it is easier for me to type `afn` than `shift + 9`.

Interesting, I have not found this to be the case. Can probably get yourself a foot pedal and crank out those arrow fn snippets.

Re: Ask HN: Does anyone still use code snippets?

#50
I don't use an LLM in my editor whatsoever. I use snippets all the time for repetitive things and common expressions.

If I ever do use llms it's for searching for something like "what kind of expression is this called: (i = 0; I < x; i++)" so that I can do better research myself.

Post reply on HN