Talk:Snippet (programming)

From Wikipedia, the free encyclopedia
Jump to: navigation, search
WikiProject Computer science (Rated Start-class, Low-importance)
WikiProject icon This article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Start-Class article Start  This article has been rated as Start-Class on the project's quality scale.
 Low  This article has been rated as Low-importance on the project's importance scale.


FoxPro was the first IDE with snippets. Mathmo Talk 20:41, 28 May 2007 (UTC)

Difference between snippet and some other concepts[edit]

How does a snippet differ from other reusable programming constructs, such as functions, macros, objects, and the like? Perhaps the article could go into some detail on this subject? I don't know enough to do the edits myself. Flewellyn (talk) 21:43, 18 February 2009 (UTC)

IMHO, a snippet is just a piece of code, normally (but not necessarily) contiguous. It is not necessary a modular unit; for instance, four arbitrary sequencial lines of a routine would qualify as a snippet.
It does not even need to be valid (compilable/executable) code as is. For instance, suppose an algorithm implemented in a given programming language. In a snippet extracted to discuss the implementation of that algorithm, the contents of one of its inner loops may be omitted and replaced by "..." to explain the basics of a portion of that algorithm while ignoring irrelevant details to that explanation. So a snippet does not need to be created with reuse in mind; there can be snippets for didactical reasons too.
Thus, snippet would be an umbrella term for all those modular units you have mentioned and even pieces of code that are just part of a module (or parts of different modules). However, the term is typically used to refer to a small piece of code. It would be somewhat misleading to call a module of many KLOC a snippet. --Antonielly (talk) 22:10, 18 February 2009 (UTC)

I’ve given an answer to this question in this edit, with contrasting examples. My understanding is that snippets are literally (statically) included text, as opposed to the abstraction of macros and functions; this accords with how it’s used in the cited source code editors. You thus can’t change snippets after they’ve been inserted, but OTOH they avoid overhead because they simply include code, without requiring indirection (“what does this macro expand to?”). Hope this helps!

—Nils von Barth (nbarth) (talk) 09:47, 3 May 2013 (UTC)

Application support[edit]

"The following is a summary of snippet support in some applications such as text editors and IDEs. For more details, see also Comparison of text editors."

The link to "comparison of text editors" does not lead to a snippets section on the comparison page... there is no catergory on the comparison page for snippets... No longer relevant? Fix? or Remove? Red Summer Rain (talk) 18:03, 7 April 2009 (UTC)


What is snipplet? Can it redirect to this art? q# (talk) 11:07, 19 September 2009 (UTC)

Provide an in-context definition and we can determine from that. Where did you see this term? dr.ef.tymac (talk) 11:32, 10 December 2009 (UTC)

POV issues with copy-paste programming pejorative[edit]

The copy-paste programming pejorative added into the context of this article seems to be conflating the basic feature of "snippet management" with a programming methodology, purportedly used by inexperienced programmers.

The copy-paste programming phenomenon (to whatever extent it exists) is not the same thing as "snippet management" which is simply a basic feature of professional programming tools such as IDEs and Programmer-oriented text editors. These tools allow editors to simply reduce the risk of repetitive strain injury and other related issues, by obviating the need to manually type keystrokes for routine tasks.

See e.g., Saving Keystrokes with Macro-Like Snippets

dr.ef.tymac (talk) 15:43, 30 May 2014 (UTC)

Examples/Alternatives section is inappropriately long[edit]

The "alternative" gives an in-depth explanation of implementing a swap macro in C. While it's not wrong, it's way too specific and out of place for a general article on snippets, so I'm blanking the section and adding a note that snippets may sometimes be replaced with macros. --Polm23 (talk) 09:55, 9 May 2016 (UTC)

  • Turns out macros are already mentioned as an alternative multiple times in the article, so no need for me to leave a note. --Polm23 (talk) 09:57, 9 May 2016 (UTC)