Live data from Hacker News

Ask HN: Does anyone still use code snippets?

news.ycombinator.com

31–40 of 61 posts

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

#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.

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

#32

No snippets, no LLMs, no autocomplete.

Almost Iron-Man coding by todays standards...

Not really. It's how it should be, except maybe autocomplete. If your code is predictable, it means it has low entropy and you are not using the right abstractions.

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

#33
I use snippets almost exclusively in markdown/latex, where typing math is at least twice as fast with snippets.

When doing some quick experiment in C/C++, scaffolding `int main ...` and classes is nice too.

In nicer languages I use snippets only if I forget syntax, than snippet serve as a quick reminder(e.g. for loop in lua)

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

#34

I use only one snippet both before and after integrating copilot (provided by my employer) into my workflow, which is for creating a empty arrow function (in JavaScript / TypeScript.) Copilot have not been able to generate arrow functions when I intend to, in my experience. I found it pretty incompetent, and unable to provide relevant assistance if there is any bit of abstraction. YMMV. I reckon my need for this spec…

> which is for creating a empty arrow function

you have a snippet for four characters? `()=>`?

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

#35
Only for memoized boilerplate, and that’s the way I’ve used them since I realized I could do it. “AI” hasn’t supplanted the practice for me at all for me, and I’m still surprised that apparently it had for most people. I can insert a template faster than a round-trip to an LLM.

That’s not to say that “AI” assisted coding isn’t useful -in fact it can be indispensable. For me, the value is mostly it being a seemingly perpetually slightly drunk, yet prescriptive, pair coding partner.

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

#36

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.

A good usecase for LLMs seems to me to be the quick exploration of unknown codebases.

My issue with the code they generate is mostly that the style of abstractions chosen is inconsistent and seems to replicate whatever was the source at any given point. Programming is still about understanding what is going on, not about just writing code, so either way you need to put in the brainwork to understand it.

But as a "just show me an example"-helper it can save you a lot of time, especially if you load highly undocumented and convoluted codebases into it.

In some cases I had the LLM hallucinate functions that would have been wonderful if they existed, but hey.

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

#37
I do, via luasnip. I type some things a lot and it's just second nature for me now. The snippets I use most don't do a lot, but save me from hitting enter and typing 'end', or from closing a HTML tag.

I have some configured to enter the names of colleagues I've paired with to commit messages in the format GitHub expects too.

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

#38
post #26

I use https://emmet.io snippets to save a lot of typing all the time: - You can just type a CSS selector (actually a superset of CSS), then expand it into the analogous HTML. - In VS code if you select some HTML then hit ALT-W, you can enter an Emmet snippet that surrounds that HTML. Examples: https://docs.emmet.io/cheat-sheet/

It’s integrated into Sublime Text. I use this all the time.

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

#39
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.

You're correct it could mean that, but alternatively:

- the use cases covered by the language could be so varied that it would be misguided to expect special functions for each of those cases

- what one programmer describes as scaffolding could be seen as essential part of the setup for others. I have seen essential parts been called "scaffolding" by beginners who had no idea this was not just "text that needs to be there", but it had implications for the whole thing.

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

#40

I use only one snippet both before and after integrating copilot (provided by my employer) into my workflow, which is for creating a empty arrow function (in JavaScript / TypeScript.) Copilot have not been able to generate arrow functions when I intend to, in my experience. I found it pretty incompetent, and unable to provide relevant assistance if there is any bit of abstraction. YMMV. I reckon my need for this spec…

> 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`.
Post reply on HN