From owner-freebsd-questions@FreeBSD.ORG Tue Mar 31 22:53:54 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 566A810656D8 for ; Tue, 31 Mar 2009 22:53:54 +0000 (UTC) (envelope-from will.rutherdale@utoronto.ca) Received: from mail.vex.net (smaug.vex.net [208.76.104.132]) by mx1.freebsd.org (Postfix) with ESMTP id 0C0DD8FC24 for ; Tue, 31 Mar 2009 22:53:53 +0000 (UTC) (envelope-from will.rutherdale@utoronto.ca) Received: from [192.168.110.8] (unknown [207.35.13.75]) by mail.vex.net (Postfix) with ESMTPA id 4ECF4170F0 for ; Tue, 31 Mar 2009 18:53:51 -0400 (EDT) Message-ID: <49D29EFF.4060104@utoronto.ca> Date: Tue, 31 Mar 2009 18:53:51 -0400 From: William Gordon Rutherdale User-Agent: Thunderbird 1.5.0.14ubu (X11/20080505) MIME-Version: 1.0 To: FreeBSD Mailing List References: <20090331025726.GA10888@thought.org> <20090331112122.ae329221.freebsd@edvax.de> <49D202F0.9010104@utoronto.ca> <20090331140845.a1ece3c0.freebsd@edvax.de> In-Reply-To: <20090331140845.a1ece3c0.freebsd@edvax.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: Why?? (prog question) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Mar 2009 22:53:56 -0000 Polytropon wrote: > On Tue, 31 Mar 2009 07:48:00 -0400, William Gordon Rutherdale wrote: > >> Tabbing is the worst form of indentation. It is *much* better to use >> spaces consistently. >> > > may I ask what exactly you mean by "consistently"? I've seen > various opinions about how many spaces make up one indentation level, > beginning from 1, over 4, up to 10. Where's the consistency, or is > it defined on a per-programmer basis? > > Are you serious? You set the standard on a given project. You decide whether you are using spaces or tabs. If spaces, you decide how many spaces per indent level. You ask the programmers to submit code in that format. It doesn't jump around randomly from one line to the next. You are trying to make it sound like a big problem, but it isn't. > And why is this much better? > Just my view based on years of experience. Don't take it too seriously. > When I would compare both indentation forms, I'd say that tabbing > is the better form because > + you can set your individually preferred tab with using the > settings of your editor, be it 1, 4 or 8, > Why is this flexibility important? The more important thing is to have consistently indented code. There is no great benefit in letting different programmers see the code indented to different levels. They just want to be able to read it. > + you can change the indentation while you're coding, e. g. when > the indentation level makes the code exceed the right margin > of your editor's window, So what? How many times have you actually done this in the past year? Be honest. > + you need more keypressing to get through the indentation with > the spaces, one keypress per space, while you only need one > keypress per tab (which equals one indentation level), > Not true. You set up your editor settings to automatically do this for you. Most editors have this capability. On my editor (vim) it only takes at most one keypress to indent. You still might use the tab key, or even have the editor automatically format for you based on syntax. Editors have done this for decades. Your objection is specious. > + per indentation level only 1 byte is needed (tab = ASCII 9), while > spacing requires more bytes, one per space (space = ASCII 32), > Are you telling me that in an age when most cheap user workstations have hundreds of gigabytes of disk space, you need this kind of savings? This is a *very* weak point. > + while you can convert tabs into spaces, you cannot easily convert > spaces back into tabs, and finally > Not true. It is extremely easy to convert both directions. The unix 'expand' command converts one direction, and 'unexpand' goes the reverse direction. These unix utilities have been around as long as 'cat' and 'ls'. Moreover the whole point is moot anyway. There are lots of high quality code formatters available. One called 'Artistic Style' is well known and very capable. On a lot of projects these days, people get sick of these kinds of arguments and just run all the code they receive through a code formatter like astyle. It lets you set all kinds of options such as brace placement, spacing between parameters, indentation method, and so on. If asking people to change their editor settings doesn't work, this thing fixes it up. > + even FreeBSD uses the tabbing style. > > And therefore if I submit code for FreeBSD then I will use that format. However I wouldn't recommend it for other projects where that decision has not been established. > I'm aware that one can argue about where { is to be placed, but > I don't see any valid reason to use spaces for indentation instead > of tabs (which I would even call "standard"). > > It's a honest question: What are your arguments for using tabs? > Hint: "it is *much* better" doesn't count. :-) > > There are lots of cases where it's hard to make code line up the way you want it with tabs. Often code that looks good with one tab length setting (say 8) doesn't look so good with another (say 4). It gets especially bad when there are a few space characters thrown in, which people often do. -Will