5 ms·
Get Rid of Source Code Templates
- jrockway 17y agoI use templates. My Perl template is: use MooseX::Declare; class $classname { } My Haskell template is: module $module where If you need anything more complicated than that, it's time to write code to fix the problem, rather than have your editor type the same text again and again and again and again.
- Legion 17y agoComment not related to the article. The "templates" the article is talking about are large boilerplate comment blocks at the top of source code files, with license, attribution, changelog, etc. information. Nothing about executable code.
- jrockway 17y agoYup, and my templates include that section.
- _delirium 17y agoFor smallish (one or a few files) library/API/snippet type stuff, I kind of like the style of putting the authors and changelog at the top of the file, along with brief documentation of using it and a statement of license terms. Bigger libraries will of course have separate ChangeLog and README files and such, but for one-file stuff, I often just end up copying the file into my own project, and it's nice when it's a self-contained file with the relevant info all in there. How common that is might vary in different programming languages. It's quite common to share Javascript code by just swapping standalone .js files, and it's not uncommon in the Lisp world either.
- ggchappell 17y agoSemi-off-topic comment: Figlet output. Yay!
- ggchappell 17y agoAlas, ego gets in the way of karma, once again. Time to move on to things people will upvote, I guess ....
- cgranade 17y agoHey, Figlet is an awesome library. I'm glad to see your work getting used!
- buster 17y agoErrr, but how does someone know that something is copyrighted and what license if nobody is writing this info? Who do i contact when i have no info of copyright and want to use some others code? It may be ridiculous for that author but it's quite important.
- blaix 17y agoIf there is no notice you can assume it is copyrighted. Because unless explicitly stated otherwise, it is.
- dagw 17y agoSure, but under what license is it made available. If I find some source code floating around on the internet while looking for the solution to some problem I'm having, knowing what license it's under is kind of important.
- j_baker 17y agoHow often does that happen really? I can't recall the last time I saw source code where you couldn't tell: 1. What license it's released under. 2. Who you can contact to get permission to use it. If there's really no way to tell who the author is or what license it's under, then I'd say not to use it. It's probably better in the long run that way anyhow.
- wooster 17y agoFrom GPLv2: "You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change." http://www.gnu.org/licenses/gpl-2.0.html http://www.gnu.org/licenses/gpl-2.0.html
- jister 17y agoI don't know. I didn't find the article interesting. I mean copyright, comments and what not on files...? Come on! These templates are written for a reason. Some companies DO write templates to make their files "standard". This is nothing new especially in a corporate environment.
- Daniel_Newby 17y agoYikes! "This means that you don’t need to do anything to have copyright over your works." But you DO need a copyright notice to collect damages for infringement. Without a notice, the most you can get is an injunction to stop infringement. "Often, source code files repeat the file name in the file itself." So you can tell which file when printing, or when viewing through a broken web interface.
- TorKlingberg 17y ago"But you DO need a copyright notice to collect damages for infringement." Really? I would need some kind of source for that claim.
- Daniel_Newby 17y agoYeah, that is wrong. The distinction is that damages are often a pittance unless the copyright is registered.
- j_baker 17y agoI doubt it would be worth the time and money of litigating in court to collect damages on a copyright case anyway unless you're Google or Microsoft.
- tophercyll 17y agoI loathe source code templates. To use web (newspaper?) terminology, it puts the content below the fold. It also raises the cost of factoring code out into its own file. Even a simple code header can easily be double the amount of code I consider worth extracting. I know many IDEs add them automatically, so it doesn't feel like much of a cost to the writer, but as the reader, you pay it every time. Why waste brain power thinking "Ok, ignore everything above, this down here is the real source code"?
- j_baker 17y agoIn emacs, hs-hide-initial-comment-block works miracles. I'm sure other editors have ways to do that as well. (That said, I totally agree with you. I wouldn't use them at all if I wasn't forced to at work.)
- tel 17y agoCan't the major complaints be addressed by just moving all this to the bottom of the file? # foo.py: objects that manage the interaction between foos and bars # (see eof for license and detailed description)
- motters 17y agoI don't agree with most of this. Yes it is pointless to include the filename within the file itself, but it's still a good idea to retain the copyright statement and author names/email addresses. In an ideal world everyone would use version control all of the time and nobody would ever swap individual source files between projects having incompatible licenses, but in the real world of software development things don't always happen that way. Having the license within each file makes it unambiguous exactly what rights are being asserted, and if someone wants to change the terms they have to make actual modifications to the code (they can't just claim to have changed their opinion, or whatever). If you're running a large project with thousands of files license changes can be automated with some trivial amount of coding, so this isn't a major issue. In large projects the license terms don't change very often anyway.
- wglb 17y agoJust a couple of questions. So if I see a file lying somewhere around the internet, how do I tell who owns the copyright? How can I tell when it expires? And if I find an executable, say, lying around in a coffee shop, how do I tell who it belongs to? The berne deal doesn't require you to label these things, but without them, how can someone else tell?