Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Page 2 of 3 < 1 2 3 >
Topic Options
#267307 - 20/10/2005 05:25 Re: Humor For Programmers [Re: tman]
sn00p
addict

Registered: 24/07/2002
Posts: 618
Loc: South London
Quote:

What's next on the discussion list? Vi or Emacs? Code formatting style? OS distribution?


Yeah, while we're at it, anybody using K&R style bracketing needs to be taken out into the parking lot and shot. Harsh, but fair!

Top
#267308 - 20/10/2005 06:28 Re: Humor For Programmers [Re: sn00p]
andym
carpal tunnel

Registered: 17/01/2002
Posts: 3996
Loc: Manchester UK
Quote:
Yeah, while we're at it, anybody using K&R style bracketing needs to be taken out into the parking lot and shot. Harsh, but fair!


Had to look it up, but agreed, I hate it. According the webpage i looked at my bracketing follows the Allman/BSD style.... nice!
_________________________
Cheers,

Andy M

Top
#267309 - 20/10/2005 09:34 Re: Humor For Programmers [Re: sn00p]
andy
carpal tunnel

Registered: 10/06/1999
Posts: 5916
Loc: Wivenhoe, Essex, UK
Quote:

Yeah, while we're at it, anybody using K&R style bracketing needs to be taken out into the parking lot and shot. Harsh, but fair!


Indeed. I have been forced to use K&R style for the last two days (on my new contract), as that was the standard here. As of ten minutes ago we have just changed the standard, so that I can go back to sane bracketing. Hurrah !

P.S. if anyone is looking for a decent coding standards doc for C#, take a look at http://home.comcast.net/~lancehunt/CSharp_Coding_Standards.pdf


Edited by andy (20/10/2005 09:35)
_________________________
Remind me to change my signature to something more interesting someday

Top
#267310 - 20/10/2005 09:42 Re: Humor For Programmers [Re: andy]
tahir
pooh-bah

Registered: 27/02/2004
Posts: 1914
Loc: London
Quote:
I have been forced to use K&R style for the last two days


Is that a bit like Crane style....

Top
#267311 - 20/10/2005 10:21 Re: Humor For Programmers [Re: andy]
JeffS
carpal tunnel

Registered: 14/01/2002
Posts: 2858
Loc: Atlanta, GA
I hate K&R Bracketing, but I have a guess as to where it came from. Not all languages have a "begin" construct (only "end"), and so putting the starting brace on the same line as the comparison makes the code look a similar style. Althouth why Ritchie specifically felt this was necessary is beyond me, since if he wanted a language without a "begin" construct he could have just left the beginning brace out when he creatd the thing. Of course, I might be wrong on why they used that style- I'm just speculating.

Personally I think I could probably learn to work in K&R, but I would be pretty unhappy for a while. It just seems fundamentally wrong not to match braces up visually.

Interestingly enough, on the thedailywtf forum yesterday there was someone ranting against standard bracing, complaining that the extra white space (the line with the starting brace) was useless and made the code difficult to read. Whatever.

I think I read somewhere that Steve Mcconnell said there is no room for religion in programming (his dad was a preacher, btw), and I think he's right. There are certainly a lot of wrong ways to do things, but there is no single "one right way" to solve problems or write code, and when people start talking that way (I'm thinking specifically of managers), then I start worrying. Mcconnell even makes a case that using the *very* occassional goto could be considered OK if the need is warranted, saying that the old standard "never use gotos" is a bit to hard line*. He does a good job arguing this in "code complete", especially with some of his "rewrite this without a goto" examples, though I must admit to having been in the "never use gotos" camp forever and not having ever had need of one. Still, I think the overarching point is valid. Programming principles are important, but when it comes to specific implementation leave religion out and be accepting of other people's choices, even if they are different from your own . . . unless it's just plain 'ol bad code.

*What Mcconnell says about gotos is, as a rule of thumb try not to use them, and if you do you can get rid of 90% fairly easily. Once you are down to the 10% where gotos seem necessary, work very hard to get rid of 90%. When you've done that, you may have a legitimate need for the reamaining goto.
_________________________
-Jeff
Rome did not create a great empire by having meetings; they did it by killing all those who opposed them.

Top
#267312 - 20/10/2005 10:45 Re: Humor For Programmers [Re: JeffS]
sn00p
addict

Registered: 24/07/2002
Posts: 618
Loc: South London
I used a goto a while back when I found that one of our recursive routines could use up all the stack in a specific circumstance.

The routine itself makes most sense being recursive, so in this situation I opted for a malloc+setjmp+longjmp to save & restore data and address and then used a goto to get to the start of the routine. I guess I could have used a while(1) loop (or possibly another setjmp/longjmp), but the goto seemed most logicial.

Only time I've ever used a goto in 'C'.

Top
#267313 - 20/10/2005 11:41 Re: Humor For Programmers [Re: JeffS]
JeffS
carpal tunnel

Registered: 14/01/2002
Posts: 2858
Loc: Atlanta, GA
Incidently, since I mentioned Mcconnell a few times, I should mention that I disagree with him on the subject of braces. He says that you should use either of the following:

Code:

if (x) {
doSomething()
}



-or-

Code:

if (x)
{
doSomething();
}



And specifically NOT to use

Code:

if (x)
{
doSomething();
}



I have never seen the second format style used (which doesn't mean that it isn't) and am much more comfortable with the third style that I use every day. His arguments that the braces hinder understanding program flow in the third example don't hold water with me, or the majority of programmers it seems. He could be right, but it makes me feel good to know that I disagree with him on something (because on just about every other concept of programming I buy his logic, hook, line, and sinker).
_________________________
-Jeff
Rome did not create a great empire by having meetings; they did it by killing all those who opposed them.

Top
#267314 - 20/10/2005 12:23 Re: Humor For Programmers [Re: JeffS]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Although I understand the notions behind not using it, I still use K&R. (Then again, I'm not a programmer by trade.) The other two make enough sense, but I actually have a harder time finding braced sections using those methods than with K&R. GNU (aka "My terminal isn't wide enough yet") is horrid, but actually makes the most logical sense to me; it just doesn't work out in reality. Of course, all that goes out the window if indenting isn't done properly. Thank god for indent.
_________________________
Bitt Faulk

Top
#267315 - 20/10/2005 12:46 Re: Humor For Programmers [Re: sn00p]
Tim
veteran

Registered: 25/04/2000
Posts: 1525
Loc: Arizona
Quote:
I've never really understood why some people get majorly obsessive about commenting code - I don't know how many times I've heard "code without comments is bad".

Generally speaking, your code should speak for itself, if it isn't then there's something wrong somewhere! I know that in practice this isn't always possible, but when I come across a situation like this, a single line comment usually suffices.

Like above, giving variables and functions proper descriptive names is about the biggest favour you can give yourself and others who access the code.

Bad code is bad code, no amount of commenting is going to fix it!


I think a lot of it has to do with what you are actually working on. When I'm doing a flight model, I comment the hell out of the code - with multiline explanations in certain areas to make sure I remember what term I am currently calculating and how it fits into the big picture. Even with all that code, going back over some of my old stuff that I haven't seen for six years or so is still confusing.

I guess there is a direct relationship between the amount of commenting necessary and the complexity of the problem.

- Tim

Top
#267316 - 20/10/2005 17:49 Re: Humor For Programmers [Re: tman]
canuckInOR
carpal tunnel

Registered: 13/02/2002
Posts: 3212
Loc: Portland, OR
Quote:
It is all a balance. You need a concise function name and a concise set of comments. Just because the compiler gives you the ability to have a 255 char long function name doesn't mean you should have an insanely long function which describes exactly what it does. You shouldn't put a comment in for every single line either.

Agreed. [Edit: snipped stuff I already said in earlier post.]

Top
#267317 - 20/10/2005 18:15 Re: Humor For Programmers [Re: wfaulk]
canuckInOR
carpal tunnel

Registered: 13/02/2002
Posts: 3212
Loc: Portland, OR
For everyone else that doesn't know the basic styles off the top of their head:
Code:

Allman/BSD Horstmann GNU Whitesmiths K&R

if (b) if (b) if (b) if (b) if (b) {
{ { x = 1; { { x = 1;
x = 1; y = 2; x = 1; x = 1; y = 2;
y = 2; } y = 2; y = 2; }
} } }



Personally, I use K&R, though I disagree with Jeff's theory about how/why it evolved. I tend to think it's just so that you can fit one more lines of real code on the screen, instead of taking a line for an opening brace on its own. The if() line is sufficient to signal the opening of a block.

I disagree with the "braces should line up" theology -- I can always tell where a compound statement block starts, based on the indent level. Of course, if there's no indenting, you're hosed, but in that case, having all the braces line up doesn't help any, either. If I need to find the corresponding opening brace for some reason, I can just use the % key*.

IMHO, Horstmann is awful -- in the example given, how easy would it be to swap those two variable initialization lines, if you wanted to (compared to doing the same in any of the other styles)?

The problem with GNU is that you end up with a non-standard indent level that's special just for braces, so you have to tab/indent twice (as opposed to once) for the code within the block. Laziness rules.


* -- yes, this is an implicit admission that I use VIM.

Top
#267318 - 20/10/2005 18:50 Re: Humor For Programmers [Re: canuckInOR]
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3584
Loc: Columbus, OH
I'm a K&R guy too, but not religious about it. As long as it's consistent, I don't have too much trouble working with it.

Some thoughts:

Horstmann seems bad to me because it'd be too easy to grab a curly brace when copying and pasting a block of code.

I agree that GNU is too much indentation. No thanks.
_________________________
~ John

Top
#267319 - 20/10/2005 19:49 Re: Humor For Programmers [Re: JBjorgen]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
My favorite hate about GNU indentation is the fact that each indent is four spaces, but each eight spaces are replaced by a tab, which makes an assumption that tabs occur every eight spaces. It also makes finding matching indents in vi a real PITA.

Personally, I set my tabstops to 2 spaces and indent once for each K&R indentation.

Actually, I don't know what K&R style is for switch statements, but sometimes I put braces around the bodies of switch cases, and when I do that, it ends up being somewhat GNU-like. Actually, looking back at some old code, I can't remember why I did that.
_________________________
Bitt Faulk

Top
#267320 - 20/10/2005 20:27 Re: Humor For Programmers [Re: JeffS]
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3584
Loc: Columbus, OH
Jeff said:
Quote:
I hate K&R Bracketing


So I'm assuming that when coding in Delphi, you use:

Code:

if (x > y) then
begin
statement1;
statement2;
end;



Whereas I (preferring K&R) would use:
Code:

if (x > y) then begin
statement1;
statement2;
end;


Top
#267321 - 20/10/2005 21:07 Re: Humor For Programmers [Re: canuckInOR]
JeffS
carpal tunnel

Registered: 14/01/2002
Posts: 2858
Loc: Atlanta, GA
Quote:
Personally, I use K&R, though I disagree with Jeff's theory about how/why it evolved.
Yeah, I'm kind of out there on that one. It's one of those things that soudns reasonable until you acually speak/type it. I hearby retract my theory!
_________________________
-Jeff
Rome did not create a great empire by having meetings; they did it by killing all those who opposed them.

Top
#267322 - 20/10/2005 21:15 Re: Humor For Programmers [Re: JBjorgen]
JeffS
carpal tunnel

Registered: 14/01/2002
Posts: 2858
Loc: Atlanta, GA
Quote:

So I'm assuming that when coding in Delphi, you use:
. . .

You are correct.

And of course, by "hate" I simply mean that it drives ME nuts, not that I think other people shouldn't do it. I'm simply not used to it and therefore have difficulty reading/writing code that way, but I don't believe my way is superior.

Mcconnell suggests that K&R is good because it keeps the starting brackets part of the control structure and Whitesmiths is good because it makes the brackets part of the block. He reasons that either of these options is reasonable so that your code is formatted to properly illustrate logic flow. Allman/BSD is a no, no because the brackets are displaced from both the block and the logic statement. Personally, I don't feel that you need to take it that far (and that he's getting a little "religious")- as long as your blocks are intedented and you do it consistently you've met the major objectives.
_________________________
-Jeff
Rome did not create a great empire by having meetings; they did it by killing all those who opposed them.

Top
#267323 - 20/10/2005 21:22 Re: Humor For Programmers [Re: JeffS]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Personally, I'm a fan of languages that make you indent properly and avoid block delimiters altogether. Python comes to mind.
_________________________
Bitt Faulk

Top
#267324 - 20/10/2005 21:27 Re: Humor For Programmers [Re: wfaulk]
canuckInOR
carpal tunnel

Registered: 13/02/2002
Posts: 3212
Loc: Portland, OR
Quote:
Personally, I set my tabstops to 2 spaces and indent once for each K&R indentation.

Gah! I want to maim people that do this! tabstop should never be set to anything other than 8. You really should be using what vim calls 'softtabstop' (along with 'shiftwidth'), which allows you to edit as though a tabstop is 2 spaces, but leaves the tabstop definition at the standard 8 spaces. I really hope you also have 'expandtab' set (which, for the non-vim users, turns tab stops to spaces).

Cheers,
Tab-nazi.

Top
#267325 - 21/10/2005 08:18 Re: Humor For Programmers [Re: canuckInOR]
Anonymous
Unregistered


Are there any members of this BBS that are NOT programmers?

Top
#267326 - 21/10/2005 08:33 Re: Humor For Programmers [Re: ]
JeffS
carpal tunnel

Registered: 14/01/2002
Posts: 2858
Loc: Atlanta, GA
I think many of the members of this BBS are not programmers- especially if you mean as a profession. But even then there are several who've probably never touched a piece of code in their lives. We do probably have a rather high concentration for a non-programming bbs though.
_________________________
-Jeff
Rome did not create a great empire by having meetings; they did it by killing all those who opposed them.

Top
#267327 - 21/10/2005 08:49 Re: Humor For Programmers [Re: ]
furtive
old hand

Registered: 14/08/2001
Posts: 886
Loc: London, UK
Quote:
Are there any members of this BBS that are NOT programmers?


Hello
_________________________
Mk2a RioCar 120Gb - now sold to the owner of my old car
Rio Karma - now on ebay...

Top
#267328 - 21/10/2005 09:40 Re: Humor For Programmers [Re: canuckInOR]
JeffS
carpal tunnel

Registered: 14/01/2002
Posts: 2858
Loc: Atlanta, GA
Quote:
tabstop should never be set to anything other than 8. You really should be using what vim calls 'softtabstop' (along with 'shiftwidth'), which allows you to edit as though a tabstop is 2 spaces, but leaves the tabstop definition at the standard 8 spaces.
I'm trying understand what you're saying here, but I don't get it (not a vim user if that matters). Why would you want your tabs set to 8?

I usually indent everything 2 spaces and have my editor set to insert spaces instead of tabs. Of course, with the editors I use (VS.net and Delphi) the whole tab functionality is really obsolete anyway. VS.net formats your code as soon as you put your closing brace and Delphi has a "smart tab" which inserts spaces up until you reach the next character-after-a-space on the previous line (or the most recent line that extends as far as you're typing).

However, on this subject, tabs in general just drive me nuts. In fact, if the editor doesn't have the option to insert spaces instead of tabs, I just ignore the tab button. I hate opening code in a different editor and having it look like garbage because the previous program used a different tab setting than the one I have now. I am experiencing this most with SQL code right now.

And on THAT subject, why is it that no one seems to ever format SQL code? I realize it's a totally different animal than regular code, but certainly you can find something consistent to do with it.
_________________________
-Jeff
Rome did not create a great empire by having meetings; they did it by killing all those who opposed them.

Top
#267329 - 21/10/2005 13:28 Re: Humor For Programmers [Re: canuckInOR]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Quote:
tabstop should never be set to anything other than 8.

GNU/Emacs freak.

Quote:
You really should be using what vim calls 'softtabstop' (along with 'shiftwidth'), which allows you to edit as though a tabstop is 2 spaces, but leaves the tabstop definition at the standard 8 spaces.

Nope, just "tabstop=2 shiftwidth=2". Interesting idea, though.

Quote:
I really hope you also have 'expandtab' set (which, for the non-vim users, turns tab stops to spaces).

Nope.

See, I find it useful for indents to be one character. It helps me find matching indents better when they span a screen's worth of data.


Edited by wfaulk (21/10/2005 13:33)
_________________________
Bitt Faulk

Top
#267330 - 21/10/2005 18:25 Re: Humor For Programmers [Re: JeffS]
canuckInOR
carpal tunnel

Registered: 13/02/2002
Posts: 3212
Loc: Portland, OR
Quote:
Quote:
tabstop should never be set to anything other than 8. You really should be using what vim calls 'softtabstop' (along with 'shiftwidth'), which allows you to edit as though a tabstop is 2 spaces, but leaves the tabstop definition at the standard 8 spaces.
I'm trying understand what you're saying here, but I don't get it (not a vim user if that matters).

I used the names of vim settings, since I believe Bitt mentioned using vi in another post, and it's the terminology I'm most familiar with.

A 'softtabstop' set to two spaces means that when you hit tab in the editor, rather than inserting a tab character, "\t", it will insert two spaces. Once you tab over a full tab stop, it replaces spaces with a tab character. This last behaviour is actually quite odious.

Fortunately, vim also has a setting called 'expandtab', which changes all literal tab characters into the equivalent number of spaces (depending, of course, on what your tabstop is).

Shiftwidth is a setting that allows you to shift lines of text (in- or outdent) by a certain number of spaces.

In vim, I never actually use the tab key. I use a shift operation to do all my non-automatic indenting.

Quote:
Why would you want your tabs set to 8?


Using your favourite language, do the equivalent of the following:
Code:
perl -e'print "\n\t#\n        #\n";'

There are 8 spaces in that last part. Run that wherever you choose and let me know how often those hash marks don't line up (assuming a fixed width font, of course). Next, create a simple text file containing those two lines. Print it out on paper, again with a fixed width font. I bet the colons line up, right? Then, in a shell, cat the file (I think the old DOS command was 'type'). How big are the tabs? Throw some <pre></pre> tags around it, and view it in a webpage. I bet those hash marks line up, right? They do in Firefox, links, lynx, and konqueror.

Aside from a text-editor where someone has manually changed the tabstop to something other than 8, a tabstop is 8 spaces. If you look at the documentation of the text-editor that person is using, I'd be willing to bet that the default tabstop (which they've changed) is 8.

Where else, other than your text editor, can you change how a tabstop is displayed? I'd bet nowhere. That's because 8 spaces is the standard. Don't change what's standard.

Quote:
I usually indent everything 2 spaces and have my editor set to insert spaces instead of tabs.

This sounds like it's the equivalent of having 'expandtabs' turned on in vim.

Quote:
Of course, with the editors I use (VS.net and Delphi) the whole tab functionality is really obsolete anyway. VS.net formats your code as soon as you put your closing brace and Delphi has a "smart tab" which inserts spaces up until you reach the next character-after-a-space on the previous line (or the most recent line that extends as far as you're typing).

Yes, smartindent is great -- vim has that, as well, and I use it. It doesn't make tab functionality obsolete, however, as, if there are literal tab characters in your file when it gets saved, then they're still there regardless of how your editor displays them.

Quote:
However, on this subject, tabs in general just drive me nuts. In fact, if the editor doesn't have the option to insert spaces instead of tabs, I just ignore the tab button. I hate opening code in a different editor and having it look like garbage because the previous program used a different tab setting than the one I have now.

Now you know why you should never change the tabstop setting from 8. If you have, the only place your formatting will ever look "correct" is in the place it was originally edited.

Quote:
And on THAT subject, why is it that no one seems to ever format SQL code?

We do -- it's a department coding standard.

Top
#267331 - 21/10/2005 18:47 Re: Humor For Programmers [Re: canuckInOR]
JeffS
carpal tunnel

Registered: 14/01/2002
Posts: 2858
Loc: Atlanta, GA
Quote:
Aside from a text-editor where someone has manually changed the tabstop to something other than 8, a tabstop is 8 spaces.
Not true in my world, I'm afraid. VS.NET has it set to 4 and it messes me up when I try to open SQL code that I generated in Sql Query Analyzer.

In fact, I only just now realized that VS.NET inserts tabs when it auto formats rather than spaces- I guess it hasn't tripped me up because I always open c# files in vs.net. Now I'm going to have to see if there's an option to convert to spaces . . .

I also just realized that vs.net indents four rather than two. It's funny I've been programming in c# for two years now and didn't realize that.

Anyway, I guess in my early days I ran into too many apps where tabs were not 8 spaces that I just gave up on tabs altogether. And I experienced it just this week trying to edit SQL code, so there you go.
_________________________
-Jeff
Rome did not create a great empire by having meetings; they did it by killing all those who opposed them.

Top
#267332 - 21/10/2005 19:02 Re: Humor For Programmers [Re: wfaulk]
canuckInOR
carpal tunnel

Registered: 13/02/2002
Posts: 3212
Loc: Portland, OR
Quote:
Quote:
tabstop should never be set to anything other than 8.

GNU/Emacs freak.

Au contraire. The first thing I do after installing a linux distro is remove Emacs. (Historically, it was because I never used it, and when using tiny hard-drives, it took up waaaay too much space for something I never used. Now it's just a matter of principle.)

Don't mistake my advocacy of 8 space tab stops as advocacy of GNUs standard for mixing tabs and spaces. That's even worse than using non-standard tabstops, since the tabs are at least internally consistent.

Quote:
Quote:
You really should be using what vim calls 'softtabstop' (along with 'shiftwidth'), which allows you to edit as though a tabstop is 2 spaces, but leaves the tabstop definition at the standard 8 spaces.

Nope, just "tabstop=2 shiftwidth=2". Interesting idea, though.

Do you ever look at your code with something other than your text editor? grep? less? more? cat? in a text editor at someone else's desk? in a cvs repository via the web? How do you set the tabstops in all those, so your code formatting appears consistent no matter how you're viewing your code? You don't like the assumption that tabstops are always 8 spaces, but where, other than where you've manually changed away from the default of 8 spaces, are tabstops anything but 8 spaces?

Anywhere other than your editor, what you wrote to look like this (on an 80 character terminal):
Code:

if (!statOnly) {
if (result.errorCode) {
if (result.messages.size() > 0) {
TXT_Printf(stderr, SEV_ERROR, "%s\n", (const char *)result.messages[0]);
}
else
TXT_Printf(stderr, SEV_ERROR, "Unknown error.\n");
exit(result.errorCode);
}


will now look like this:
Code:

if (!statOnly) {
if (result.errorCode) {
if (result.messages.size() > 0) {
TXT_Printf(stderr, SEV_ERROR, "%s\n", (const cha
r *)result.messages[0]);
}
else
TXT_Printf(stderr, SEV_ERROR, "Unknown error.\n"
);
exit(result.errorCode);
}



Of course, if that were printed out on paper, those lines would just get lopped off, instead of wrapping.

Quote:
Quote:
I really hope you also have 'expandtab' set (which, for the non-vim users, turns tab stops to spaces).

Nope.

See, I find it useful for indents to be one character. It helps me find matching indents better when they span a screen's worth of data.

The important thing isn't that the indent is "one character", but that indents are always the same number of characters, whether that's one tab, or two spaces.

[edit: fixed quoting.]

Top
#267333 - 21/10/2005 19:13 Re: Humor For Programmers [Re: canuckInOR]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
While it's certainly something of a defacto standard that tabstops are at 8 characters, I've seen all sorts of places where that's not true. (The only one that comes to mind is a glass tty I used to use where it was ten. Took me days before I figured out some weird-ass tab-related problem. Which is, of course, why I remember it.)

Personally, I don't see the big issue with how many spaces tabs are or spaces versus tabs as long as you're consistent. The only real problem I have along those lines is GNU indenting, where they assume that tabs are 8 characters (despite there being no real standard to that effect) and that they mix spaces and tabs. Personally, I always use tabs to indent, but I make sure to be consistent.

For example, if I have some code that looks like:
Code:

if ( a<b ) {
if ( c<d ) {
if ( e<f ||
g<h ) {
doit();
}
}
}


then I format it like this:
Code:

if ( a<b ) {
ttif ( c<d ) {
ttttif ( e<f ||
ttttsssssg<h ) {
ttttttdoit();
tttt}
tt}
}


Where "t"s represent space taken up by tabs and "s"s represent space taken up by spaces. That way, no matter what you tabstops are set to, it lines up properly, as long as you're using a fixed-width font. The worst that can happen is that the tabs are too wide, but it's easy to ":set tabstop=2" or ":%s/^I/ /g" or whatever the eqivalents might be in your editor.
_________________________
Bitt Faulk

Top
#267334 - 21/10/2005 19:31 Re: Humor For Programmers [Re: JeffS]
canuckInOR
carpal tunnel

Registered: 13/02/2002
Posts: 3212
Loc: Portland, OR
Quote:
Quote:
Aside from a text-editor where someone has manually changed the tabstop to something other than 8, a tabstop is 8 spaces.
Not true in my world, I'm afraid. VS.NET has it set to 4

Huh. I haven't used windows since... uh... NT 4.0, I think, so I'm coming to this primarily from a unix standpoint. I'm certainly not up on all the fancy IDE editors out there, particularly on Windows.

Quote:
I also just realized that vs.net indents four rather than two.

Well, at least it's a good indent. 2 space indents are too small, IMHO. I like 4 space indents.

Quote:
Anyway, I guess in my early days I ran into too many apps where tabs were not 8 spaces that I just gave up on tabs altogether.

I used to like tabs. Then I started working with other people.

Tabs just shouldn't be used for formatting code.

Top
#267335 - 25/10/2005 00:17 Re: Humor For Programmers [Re: canuckInOR]
rob
carpal tunnel

Registered: 21/05/1999
Posts: 5335
Loc: Cambridge UK
Code:

...
else
TXT_Printf(stderr, SEV_ERROR, "Unknown error.\n");
exit(result.errorCode);


Tsk, always brace, could be a macro!

Rob

Top
#267336 - 25/10/2005 00:41 Re: Humor For Programmers [Re: JeffS]
DLF
addict

Registered: 24/07/2003
Posts: 500
Loc: Colorado, N.A.
Quote:
... never touched a piece of code in their lives.

Do macros or markup languages count? (Tech writer here.)
_________________________
-- DLF

Top
Page 2 of 3 < 1 2 3 >