Archived

This topic is now archived and is closed to further replies.

How many lines of code does an average prog.....

This topic is 5300 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Guest Anonymous Poster
Some days I write thousands of lines of code, some days I remove just as many. To quote Dijkstra: "What kind of measurement is that?"

Share this post


Link to post
Share on other sites
Amortized, most programmers in a business setting code 10-50 lines per day. Before you start talking about how low that is, though, keep in mind that programmers also spend a lot of time designing, documenting, testing, supporting, etc.

<flame>Programmers who use hungarian notation tend to be "slow", in more ways than one, and churn out about two lines per day. And one of them is buggy.</flame>

EDIT: to expand on what the AP said:


/// Programmer A writes:

for(i=0; i<MAX_FOO; i++)
{
if(foos[i] == bar)
{
if(dblfoo == true)
{
return baz[i] * 2;
}
else
{
return baz[i];
}
}
}

/// Programmer B writes:

for(i=0; i<MAX_FOO; i++)
{
if(foos[i] == bar)
return dblfoo ? baz[i]*2 : baz[i];
}


Programmer A writes three times as many lines of code as Programmer B.


How appropriate. You fight like a cow.

[edited by - sneftel on June 5, 2003 1:03:37 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Sneftel
<flame>Programmers who use hungarian notation tend to be "slow", in more ways than one, and churn out about two lines per day. And one of them is buggy.</flame>


ROFL!

Share this post


Link to post
Share on other sites
If you're actually 'coding' 8 hours a day.. no doubt much of that time isn't productive, it's pretty tough to just code that long.

If an experienced programmer could actually program 8 hours nonstop It'd most likely really speed that project on. As Sneftel said, often the time isn't spent programming, but if it somehow was the 8 hours would roughly equal the amount of time available to code over the course of 1-2 weeks.

If you're like many, you'll code while you check out gamedev or some other sites, substantially slowing you down, while increasing your tolerance of this 8 hour stretch.



[edited by - cozman on June 5, 2003 1:06:11 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by cozman
If you''re like many, you''ll code while you check out gamedev or some other sites, substantially slowing you down, while increasing your tolerance of this 8 hour stretch.

Er... yup. *Guiltily goes back to work.*


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
with 8 hours i mean 8 hours of work (planing coding, drinking, playing...rofl)

to be true i hardly use this type of comparsion


dblfoo ? baz*2 : baz[i];

since my if state ments are much more complexe in general

if i wouldn t see this comparsion some times i d forget it pretty soon

Share this post


Link to post
Share on other sites
If you are going to use lines of code as a metric, arguing notation means less work gets done is silly - tracking LOC isn''t terrifically meaningful, but at least approach it reasonably. Saying that lines which are whitespace or just brackets count against the typical number is silly.

Part of the reason the count seems so low is the cost of integrating code into huge, complex million line code bases (which is small by corporate standards). Debugging, supporting and documenting take a lot of time and those count against hours as well.

Code maintainence is much more expensive than writting code, and much of what you do while at a company is combat against entropy.

Share this post


Link to post
Share on other sites
How about if I cut and paste 2000 lines of code out of the help files and online tutorials ? Does that count as "written" code ? Programming is 50% pladgerism. The other 50% is knowing what code to copy.

Share this post


Link to post
Share on other sites
lets rate it down to 25%
since c&p isn t always the best way

from my experience i have to say
recode simple things or you forget how to do it

best example is the texture stuff in 3d engines

you write the texture code once and never touch it again
after some time your forget how you have done that and that makes me really feel bad

Share this post


Link to post
Share on other sites
quote:
Original post by Sneftel

/// Programmer A writes:

for(i=0; i<MAX_FOO; i++)
{
if(foos[i] == bar)
{
if(dblfoo == true)
{
return baz[i] * 2;
}
else
{
return baz[i];
}
}
}

/// Programmer B writes:

for(i=0; i<MAX_FOO; i++)
{
if(foos[i] == bar)
return dblfoo ? baz[i]*2 : baz[i];
}

/// Programmer C writes:

for(long i=0; i<MAX_FOO; i++)
if(foos[i] == bar)
return dblfoo ? baz[i]*2 : baz[i];




added Programmer C


.lick

Share this post


Link to post
Share on other sites
pipo, why stop there?

void calculateObj() { for(long i=0; i == bar) return dblfoo ? baz[i]*2 : baz[i]; };

...This remindes me of that obfuscated c++ programming contest.. anyone remember the link??

[edited by - superdeveloper on June 5, 2003 2:13:05 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Pipo DeClown

/// Programmer A writes:

for(i=0; i<MAX_FOO; i++)
{
if(foos[i] == bar)
{
if(dblfoo == true)
{
return baz[i] * 2;
}
else
{
return baz[i];
}
}
}

/// Programmer B writes:

for(i=0; i<MAX_FOO; i++)
{
if(foos[i] == bar)
return dblfoo ? baz[i]*2 : baz[i];
}

/// Programmer C writes:

for(long i=0; i<MAX_FOO; i++)
if(foos[i] == bar)
return dblfoo ? baz[i]*2 : baz[i];


/// Programmer D writes:

for (long i=0; i!=MAX_FOO; ++i)
if (foos[i] == bar)
return dblfoo ? baz[i]+baz[i] : baz[i];




added Programmer D, which runs faster

--- Edit ---
Fixed typo

[edited by - Ready4Dis on June 5, 2003 2:17:25 PM]

Share this post


Link to post
Share on other sites
while(p)
{
int l;
retp(&i,&j);
viz[j]=1;
for(l=0;l<4;l++)
{
if(dx[l]+i>=1 && dx[l]+i<=n && dy[l]+j>=1 && dy[l]+j<=n
&& (b[i+dx[l]][j+dy[l]] > b[i][j]+a[dx[l]+i][dy[l]+j] ||
b[i+dx[l]][j+dy[l]]==-1))
b[i+dx[l]][j+dy[l]]=b[i][j]+a[dx[l]+i][dy[l]+j];

if(dx[l]+i>=1 && dx[l]+i<=n && dy[l]+j>=1 && dy[l]+j<=n)
if(!viz[i+dx[l]][j+dy[l]])adauga(i+dx[l],j+dy[l]);
}
}


this is a part of the code i wrote at a programming contest. it took 10 min to write and it and has an bug somewere. i couldn't correct it in 3 hours actualy i couldn't correct it in 3 months. (i would like to know why the program didn't work because if it did i would have gotten the first place. if i really wanted to fix it i would rewrite it ) . this is why i preffer very long variable names instead of i,j,l,k,dx,dy..... even if they slow me down apparently (debuging much faster) . maybe if i used more functions and longer names i wouldn't have made the mistake.



[edited by - razvan on June 5, 2003 2:37:30 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by superdeveloper
...This remindes me of that obfuscated c++ programming contest.. anyone remember the link??



This one? www.ioccc.org

Share this post


Link to post
Share on other sites
quote:
Original post by Ready4Dis
quote:
Original post by Pipo DeClown

/// Programmer A writes:

for(i=0; i<MAX_FOO; i++)
{
if(foos[i] == bar)
{
if(dblfoo == true)
{
return baz[i] * 2;
}
else
{
return baz[i];
}
}
}

/// Programmer B writes:

for(i=0; i<MAX_FOO; i++)
{
if(foos[i] == bar)
return dblfoo ? baz[i]*2 : baz[i];
}

/// Programmer C writes:

for(long i=0; i<MAX_FOO; i++)
if(foos[i] == bar)
return dblfoo ? baz[i]*2 : baz[i];


/// Programmer D writes:

for (long i=0; i!=MAX_FOO; ++i)
if (foos[i] == bar)
return dblfoo ? baz[i]+baz[i] : baz[i];




added Programmer D, which runs faster

--- Edit ---
Fixed typo

[edited by - Ready4Dis on June 5, 2003 2:17:25 PM]
I think Programmer D is a better example. While the other programmers may have written more/less code, programmer D spent more time figuring out the best way to handle the problem. In the end, it doesn''t matter how much code there is. What matters is how well it works.

Share this post


Link to post
Share on other sites
I could easily spend 3-4 hours coding but after that my eyes start twitching and my brain starts trailing off and I start playing games or whatever. I spend lots of time reading though, which I believe is just as important as coding. You can''t code that good if you don''t know what you''re doing, right?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

/// Programmer E writes:
for (long i=0; i!=MAX_FOO; ++i)
if (foos == bar)
return dblfoo ? baz[i]<1 : baz[i];


Would programmers E code run faster? I think bit-shifting might be faster.

Share this post


Link to post
Share on other sites
quote:
Original post by Big Sassy
I think Programmer D is a better example. While the other programmers may have written more/less code, programmer D spent more time figuring out the best way to handle the problem. In the end, it doesn't matter how much code there is. What matters is how well it works.

No, programmer D obviously doesn't understand how compilers work, and hasn't taken the time to profile his application before adding a micro-optimization that decreases readability while doing nothing to increase efficiency. Programmer D should be kindly but firmly told that cute operator tricks are rarely, if ever, worth it.

EDIT: Programmer E should be told the same thing. He should also be reminded what the bitshift operator is.

How appropriate. You fight like a cow.

[edited by - sneftel on June 5, 2003 4:49:33 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Whoops!
Should be:

/// Programmer E writes:
for (long i=0; i!=MAX_FOO; ++i)
if (foos == bar)
return dblfoo ? baz << 1 : baz[i];


I think bit shift operator would be faster than *2.

Share this post


Link to post
Share on other sites