Post by Dimiter_PopoffHere is a line count then a byte count (the latter seems to count
also temporary directories under the one I currently work I usually
make for quick backward reference hence the discrepancy).
http://tgi-sci.com/misc/scnt21.gif
This is since 1994-a or so, all I have written since I think.
Programming takes up 80 or may be 90% of my time, the rest goes on
hardware design for/on which the code is written.
There may be duplicates (other than temp directories) but the
error because of that would be well within 10%.
1.6 million lines in 25 years makes what, about 5k lines per month,
sounds close enough. I am not preoccupied with these figures of
course, had forgotten how to use the scripts I made doing that counting.
What's a line? A line of CODE? Raw comments? Assembler/compiler
directives? A "newline"?
When you count lines, it's really easy to distort measurements.
function(int argument) {
 int Y = 0;
 int X = MAGIC_X;
 int current = 0;
 for (iteration = 0; iteration < COUNT; iteration++) {
    trialX = X;
    if (argument > current) {
       trialX += (Y >> iteration);
       Y -= (X >> iteration);
       current -= table[iteration];
    } else {
       trialX -= (Y >> iteration);
       Y += (X >> iteration);
       current += table[iteration];
    }
    X = trialX;
 }
}
This can be seen as ~a dozen lines of code.
function(int argument) {
 int Y = 0;
 int X = MAGIC_X;
 int current = 0;
 iteration = 0;
 do {
    trialX = X;
    if (argument > current) {
       trialX += (Y >> iteration);
       Y -= (X >> iteration);
       current -= table[iteration];
    } else {
       trialX -= (Y >> iteration);
       Y += (X >> iteration);
       current += table[iteration];
    }
    X = trialX;
    iteration++;
 } while iteration < COUNT;
}
and it's 20% "bigger".
function(int argument) {
 int Y = 0;
 int X = MAGIC_X;
 int current = 0;
 for (iteration = 0; iteration < COUNT; iteration++) {
    trialX = X;
    trialX += (argument > current) ? (Y >> iteration) : -(Y >>
iteration);
    Y -= (argument > current) ? (X >> iteration) : -(X >> iteration);
-table[iteration];
    X = trialX;
 }
}
and it's 20% smaller.
The code generated will be exactly the same (for a good compiler).
Some folks will find one version more understandable than others
(I obviously prefer the initial implementation -- for readability).
Should I be rewarded -- or penalized -- for using the number of
semicolons (an easy way to count LoC in C) that I chose? Am
I more or less productive than either of these two alternative
"coders" hypothesized, here?
There's not *quite* as much flexibility in writing ASM (assuming
you don't do silly things like unroll loops needlessly or code
multiplies as shift/add sequences instead of just using a MUL
opcode).
But, there are other aspects that "generate lines" that may
or may not be counted as REAL lines of code.
If I build a macro, it, in itself, represents no PRODUCTION
code. Yet, applying it (likely) generates code. Do I count
each invocation as ONE line of code? Or, do I count the
lines of code that it generates as lines of code (that *I* wrote?)
Following is the interrupt dispatch table from my current project.
How many "lines" should it be regarded? The macro definitions aren't
technically "code" -- even though each creates several lines of
code! Are the invocations counted each as a single line of code,
despite the fact that they each generate ~5 lines of code?
The complexity of the resulting product (i.e., what the host
CPU will actually encounter) doesn't change -- despite the
fact that we can come up with rationalizations for various
LoC interpretations!
Yet, on inspection, you can see how creating such a "piece of code"
can be relatively trivial.
----8<----8<----8<----
/*
* An entry in the Interrupt Descriptor Table.
*/
#define   IRQ_ENTRY(vector,flavor) \
    .data   2       ;\
    .long   vector       ;\
    .word   KERNEL_MAGIC   ;\
    .byte   0       ;\
    .byte   flavor       ;\
    .text
/*
* An exception handler entry.
*/
#define   EXCEPTION(id,name) \
    IRQ_ENTRY(EXT(name),SYS_TRAP_GATE) ;\
MAKE_LABEL(name)Â Â Â Â Â Â Â Â Â Â Â ;\
    pushl   $(0)           ;\
    pushl   $(id)           ;\
    jmp   _svc_trap
/*
* A User Interrupt.
*/
#define   EXCEPTION_USER(id,name) \
    IRQ_ENTRY(EXT(name),USR_TRAP_GATE);\
MAKE_LABEL(name)Â Â Â Â Â Â Â Â Â Â Â ;\
    pushl   $(0)           ;\
    pushl   $(id)           ;\
    jmp   _svc_trap
/*
* A "Special" interrupt code.
*/
#define   EXCEPTION_SPECIAL(id,name) \
    IRQ_ENTRY(EXT(name),SYS_TRAP_GATE)
/*
* The error code is already at ToS!
*/
#define   EXCEPTION_ERROR(id,name) \
    IRQ_ENTRY(EXT(name),SYS_TRAP_GATE);\
MAKE_LABEL(name)Â Â Â Â Â Â Â Â Â Â Â ;\
    pushl   $(id)           ;\
    jmp   _svc_trap
/*
* A "regular" Interrupt Request
*/
#define   INTERRUPT(id) \
    IRQ_ENTRY(0f,SYS_IRQ_GATE)   ;\
0:Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ;\
    pushl   %eax           ;\
    movl   $(id),%eax       ;\
    jmp   _svc_irq
    .data   2
MAKE_LABEL(idt)
    .text
EXCEPTION(0x00,trap_div_by_zero)
EXCEPTION_SPECIAL(0x01,trap_debug)
INTERRUPT(0x02)Â Â Â Â Â Â Â Â Â Â Â /* NonMaskable IRQ */
EXCEPTION_USER(0x03,trap_int3)
EXCEPTION_USER(0x04,trap_into)
EXCEPTION_USER(0x05,trap_bounds_check)
EXCEPTION(0x06,trap_illegal_op)
EXCEPTION(0x07,trap_nofpu)
EXCEPTION(0x08,a_double_fault)
EXCEPTION(0x09,a_fpu_over)
EXCEPTION(0x0a,a_invalid_tss)
EXCEPTION_SPECIAL(0x0b,trap_segnp)
EXCEPTION_ERROR(0x0c,trap_stack_fault)
EXCEPTION_SPECIAL(0x0d,trap_protection)
EXCEPTION_SPECIAL(0x0e,trap_page_fault)
EXCEPTION(0x0f,trap_trap_0f)
EXCEPTION(0x10,trap_fpu_error)
EXCEPTION(0x11,trap_trap_11)
EXCEPTION(0x12,trap_trap_12)
EXCEPTION(0x13,trap_trap_13)
EXCEPTION(0x14,trap_trap_14)
EXCEPTION(0x15,trap_trap_15)
EXCEPTION(0x16,trap_trap_16)
EXCEPTION(0x17,trap_trap_17)
EXCEPTION(0x18,trap_trap_18)
EXCEPTION(0x19,trap_trap_19)
EXCEPTION(0x1a,trap_trap_1A)
EXCEPTION(0x1b,trap_trap_1B)
EXCEPTION(0x1c,trap_trap_1C)
EXCEPTION(0x1d,trap_trap_1D)
EXCEPTION(0x1e,trap_trap_1E)
EXCEPTION(0x1f,trap_trap_1F)
INTERRUPT(0x20)
INTERRUPT(0x21)
INTERRUPT(0x22)
INTERRUPT(0x23)
INTERRUPT(0x24)
INTERRUPT(0x25)
INTERRUPT(0x26)
INTERRUPT(0x27)
INTERRUPT(0x28)
INTERRUPT(0x29)
INTERRUPT(0x2a)
INTERRUPT(0x2b)
INTERRUPT(0x2c)
INTERRUPT(0x2d)
INTERRUPT(0x2e)
INTERRUPT(0x2f)
INTERRUPT(0x30)
INTERRUPT(0x31)
INTERRUPT(0x32)
INTERRUPT(0x33)
INTERRUPT(0x34)
INTERRUPT(0x35)
INTERRUPT(0x36)
INTERRUPT(0x37)
INTERRUPT(0x38)
INTERRUPT(0x39)
INTERRUPT(0x3a)
INTERRUPT(0x3b)
INTERRUPT(0x3c)
INTERRUPT(0x3d)
INTERRUPT(0x3e)
INTERRUPT(0x3f)
INTERRUPT(0x40)
INTERRUPT(0x41)
INTERRUPT(0x42)
INTERRUPT(0x43)
INTERRUPT(0x44)
INTERRUPT(0x45)
INTERRUPT(0x46)
INTERRUPT(0x47)
INTERRUPT(0x48)
INTERRUPT(0x49)
INTERRUPT(0x4a)
INTERRUPT(0x4b)
INTERRUPT(0x4c)
INTERRUPT(0x4d)
INTERRUPT(0x4e)
INTERRUPT(0x4f)
INTERRUPT(0x50)
INTERRUPT(0x51)
INTERRUPT(0x52)
INTERRUPT(0x53)
INTERRUPT(0x54)
INTERRUPT(0x55)
INTERRUPT(0x56)
INTERRUPT(0x57)
INTERRUPT(0x58)
INTERRUPT(0x59)
INTERRUPT(0x5a)
INTERRUPT(0x5b)
INTERRUPT(0x5c)
INTERRUPT(0x5d)
INTERRUPT(0x5e)
INTERRUPT(0x5f)
INTERRUPT(0x60)
INTERRUPT(0x61)
INTERRUPT(0x62)
INTERRUPT(0x63)
INTERRUPT(0x64)
INTERRUPT(0x65)
INTERRUPT(0x66)
INTERRUPT(0x67)
INTERRUPT(0x68)
INTERRUPT(0x69)
INTERRUPT(0x6a)
INTERRUPT(0x6b)
INTERRUPT(0x6c)
INTERRUPT(0x6d)
INTERRUPT(0x6e)
INTERRUPT(0x6f)
INTERRUPT(0x70)
INTERRUPT(0x71)
INTERRUPT(0x72)
INTERRUPT(0x73)
INTERRUPT(0x74)
INTERRUPT(0x75)
INTERRUPT(0x76)
INTERRUPT(0x77)
INTERRUPT(0x78)
INTERRUPT(0x79)
INTERRUPT(0x7a)
INTERRUPT(0x7b)
INTERRUPT(0x7c)
INTERRUPT(0x7d)
INTERRUPT(0x7e)
INTERRUPT(0x7f)
INTERRUPT(0x80)
INTERRUPT(0x81)
INTERRUPT(0x82)
INTERRUPT(0x83)
INTERRUPT(0x84)
INTERRUPT(0x85)
INTERRUPT(0x86)
INTERRUPT(0x87)
INTERRUPT(0x88)
INTERRUPT(0x89)
INTERRUPT(0x8a)
INTERRUPT(0x8b)
INTERRUPT(0x8c)
INTERRUPT(0x8d)
INTERRUPT(0x8e)
INTERRUPT(0x8f)
INTERRUPT(0x90)
INTERRUPT(0x91)
INTERRUPT(0x92)
INTERRUPT(0x93)
INTERRUPT(0x94)
INTERRUPT(0x95)
INTERRUPT(0x96)
INTERRUPT(0x97)
INTERRUPT(0x98)
INTERRUPT(0x99)
INTERRUPT(0x9a)
INTERRUPT(0x9b)
INTERRUPT(0x9c)
INTERRUPT(0x9d)
INTERRUPT(0x9e)
INTERRUPT(0x9f)
INTERRUPT(0xa0)
INTERRUPT(0xa1)
INTERRUPT(0xa2)
INTERRUPT(0xa3)
INTERRUPT(0xa4)
INTERRUPT(0xa5)
INTERRUPT(0xa6)
INTERRUPT(0xa7)
INTERRUPT(0xa8)
INTERRUPT(0xa9)
INTERRUPT(0xaa)
INTERRUPT(0xab)
INTERRUPT(0xac)
INTERRUPT(0xad)
INTERRUPT(0xae)
INTERRUPT(0xaf)
INTERRUPT(0xb0)
INTERRUPT(0xb1)
INTERRUPT(0xb2)
INTERRUPT(0xb3)
INTERRUPT(0xb4)
INTERRUPT(0xb5)
INTERRUPT(0xb6)
INTERRUPT(0xb7)
INTERRUPT(0xb8)
INTERRUPT(0xb9)
INTERRUPT(0xba)
INTERRUPT(0xbb)
INTERRUPT(0xbc)
INTERRUPT(0xbd)
INTERRUPT(0xbe)
INTERRUPT(0xbf)
INTERRUPT(0xc0)
INTERRUPT(0xc1)
INTERRUPT(0xc2)
INTERRUPT(0xc3)
INTERRUPT(0xc4)
INTERRUPT(0xc5)
INTERRUPT(0xc6)
INTERRUPT(0xc7)
INTERRUPT(0xc8)
INTERRUPT(0xc9)
INTERRUPT(0xca)
INTERRUPT(0xcb)
INTERRUPT(0xcc)
INTERRUPT(0xcd)
INTERRUPT(0xce)
INTERRUPT(0xcf)
INTERRUPT(0xd0)
INTERRUPT(0xd1)
INTERRUPT(0xd2)
INTERRUPT(0xd3)
INTERRUPT(0xd4)
INTERRUPT(0xd5)
INTERRUPT(0xd6)
INTERRUPT(0xd7)
INTERRUPT(0xd8)
INTERRUPT(0xd9)
INTERRUPT(0xda)
INTERRUPT(0xdb)
INTERRUPT(0xdc)
INTERRUPT(0xdd)
INTERRUPT(0xde)
INTERRUPT(0xdf)
INTERRUPT(0xe0)
INTERRUPT(0xe1)
INTERRUPT(0xe2)
INTERRUPT(0xe3)
INTERRUPT(0xe4)
INTERRUPT(0xe5)
INTERRUPT(0xe6)
INTERRUPT(0xe7)
INTERRUPT(0xe8)
INTERRUPT(0xe9)
INTERRUPT(0xea)
INTERRUPT(0xeb)
INTERRUPT(0xec)
INTERRUPT(0xed)
INTERRUPT(0xee)
INTERRUPT(0xef)
INTERRUPT(0xf0)
INTERRUPT(0xf1)
INTERRUPT(0xf2)
INTERRUPT(0xf3)
INTERRUPT(0xf4)
INTERRUPT(0xf5)
INTERRUPT(0xf6)
INTERRUPT(0xf7)
INTERRUPT(0xf8)
INTERRUPT(0xf9)
INTERRUPT(0xfa)
INTERRUPT(0xfb)
INTERRUPT(0xfc)
INTERRUPT(0xfd)
INTERRUPT(0xfe)
INTERRUPT(0xff)
Post by Dimiter_Popoff1000 lines a day would be a lot, I think I have been there at times
but only when I did not need to think, just program (e.g. when I did
a disassembler for the cpu32 many years ago, I remember this went
very fast but obviously it is a very primitive thing to do).
it all works quite well so it can't be just that. In fact the average
line length comes at 36 characters, it is there to see.
code of last at least 10 years if you want us to continue this nonsense.
be very very surprised (count each CR, not just non-null lines).
20 years old but will give you an idea.
new object types etc. things get higher level overall, but the
style has not changed that much.