Sign in to follow this  
fir

about lines of code

Recommended Posts

How many lines of code you had written in you life till now?

How many lines of code project you are working on now or was working in the past?

How many lines of code have good well known games ?

How many lines of code have todays big titles?

How many lines of code is a big project game, how many is medium project?

 

I hope this post is apropriate, It would be interesting to me to know.

 

As to myself I wrote till today about 100-150k lines of c (2-3MB of source) (its quite precise) I consider 100k as a medium size project, think that big project probably is 1M-lines (20MB) or more - but I am not sure, never worked on big 3d game. I would like to know what do other think about this and If can give some values related to their experience. Thanx for answers.

Edited by fir

Share this post


Link to post
Share on other sites

While I figure it is an appropriate post, it is unfortunately a completely invalid measurement.  Lines of code measurement is a stupid and obnoxious way to measure productivity.  I've had days where my only line of code was changing a 0 to a 1 and EVERYONE was insanely happy because I fixed a nasty ass and hard to track bug with that modified line.  Does that count as a line of code?  I've had other days where I remove nearly 1k lines of code by encapsulating a copy/paste viral pattern saved everyone major amounts of hassles in the future.  Does removing large swatches of stupid code and replacing it with a cleaned up API (or by adding a 10 line helper function) count?

 

Lines of code is a silly measurement.  I've worked on 3 million line codebases and all I can say is that they should have been at least 1/3rd of that had the people involved stopped reinventing wheels and simply talked to folks to find out what already existed.

 

So, overall, a really horrible way to measure things IMO.

 

Ok, but personally I was not talking about measuring productivity- (or less more creativity) its quite different topic : programming is very abstract domain some like writing novels. I am not saying also that bigger is better.

 

But quite not related to that it is interesting how big projects are, how much lines somebody had written etc - Its quite interesting, though I agree most of the work in programming is abstract and is learning and its behind the lines  (the lines written is 10% of it all)

Share this post


Link to post
Share on other sites

You could have a large game with only 10k LOC...

 

 

Nay, I wouldnt belive that - 10k lines is say 10 medium sized files, a  couple  of procedures each - its quite a small game like extended tetris or something not a big or even medium one.

 

Im sorry that I do not know how big in loc are the famous games.

 Vaguelly remember that Quake 2 (not so much good game, depressing, though quite solid and I played it) had about 100-150k-lines, 

Famous rogualike ADOM (terribly good game at least for me in v15 I was playing a lot) I vaguelly remember was also about 100k lines

 

Do not know how big in loc are other games, (say Gothic-like games or so, I do not know many modern games ) older classics and more modern AAA-killers, if somebody do know, thanks for posting info about it 

Edited by fir

Share this post


Link to post
Share on other sites

fir, you should give up.  You are talking to two moderators who have been making games for a while.  Not sure about Hodge but I've been at it for a bit over 20 years now.  I'm not going to start posting a list of my games and LOC's and I suspect Hodge is of the same opinion.  LOC has no bearing on reality unless you then include team size, measure it over years of development, average salaries etc.  You'd be better off asking EA for such stats because they track it all, of course they make a lot of shitty games, go figure...

Share this post


Link to post
Share on other sites

Nay, I wouldnt belive that - 10k lines is say 10 medium sized files, a  couple  of procedures each - its quite a small game like extended tetris or something not a big or even medium one.

You could write the graphics and audio subsystems, and a VM/interpreter for a visual/node-based scripting language wink.png
How do you count LOC for non-line-based programming systems?

But yes, if I were quoting numbers for "big" projects, I'd go with a million. Edited by Hodgman

Share this post


Link to post
Share on other sites

fir, you should give up.  You are talking to two moderators who have been making games for a while.  Not sure about Hodge but I've been at it for a bit over 20 years now.  I'm not going to start posting a list of my games and LOC's and I suspect Hodge is of the same opinion.  LOC has no bearing on reality unless you then include team size, measure it over years of development, average salaries etc.  You'd be better off asking EA for such stats because they track it all, of course they make a lot of shitty games, go figure...

 

I see no reason to give up the question. If youre 20 years in gamedev  it does not mean that people have differen approaches to that than yours and their approaches are bad. I like line counting and searching for answers from people interested in that too, some knowledge related to that, just like i was asking about.

 

As to 'go figure' I do not know how to find that, many project sizes are probably  avaliable in google - could somebody help with finding that?, I would appreciate

 

[PS.Im asking a big amount of question I know, Its becouse I am new in world wide community and got a couple of question on my mind - then it will become gradually lower i think, but now still have a couple of them, regardz]

Edited by fir

Share this post


Link to post
Share on other sites

 

You could have a large game with only 10k LOC...

 

 

Nay, I wouldnt belive that - 10k lines is say 10 medium sized files, a  couple  of procedures each - its quite a small game like extended tetris or something not a big or even medium one.

 

Im sorry that I do not know how big in loc are the famous games.

 Vaguelly remember that Quake 2 (not so much good game, depressing, though quite solid and I played it) had about 100-150k-lines, 

Famous rogualike ADOM (terribly good game at least for me in v15 I was playing a lot) I vaguelly remember was also about 100k lines

 

Do not know how big in loc are other games, (say Gothic-like games or so, I do not know many modern games ) older classics and more modern AAA-killers, if somebody do know, thanks for posting info about it 

 

 

Code adds or controls functionality though, not content(Allthough some games make heavy use of scripted content which does require a bit of code for new content as well), so a game like Quake2 would require pretty much the same amount of code even if it was just a single short level (and thus a very small game).

 

10k LOC is enough to make a huge game but its not enough to implement all the functionality you'd expect to find in a modern game, most of the code written for todays AAA games have nothing to do with the size of those games but rather with the functionality the games have.

Share this post


Link to post
Share on other sites

[PS.Im asking a big amount of question I know, Its becouse I am new in world wide community and got a couple of question on my mind - then it will become gradually lower i think, but now still have a couple of them, regardz]

 

 

You're just wasting time by asking those questions. If you wan't to make games, they're totally irrelevant. They just stop you from doing something.

Also, it seems like you have a fixed mindset of the answers to every question you ask, so there's no point in answering your question, either.

 

You'd be better off appreciating the detailed answers like those from Hodgman and AllEightUp, because they seem to know what they're talking about.

 

Try to make games or program what you want to, and if you get *really* stuck, ask for help, there are some great devs around here.

Edited by weeska

Share this post


Link to post
Share on other sites

 


[PS.Im asking a big amount of question I know, Its becouse I am new in world wide community and got a couple of question on my mind - then it will become gradually lower i think, but now still have a couple of them, regardz]

 

 

You're just wasting time by asking those questions. If you wan't to make games, they're totally irrelevant. They just stop you from doing something.

Also, it seems like you have a fixed mindset of the answers to every question you ask, so there's no point in answering your question, either.

 

You'd be better off appreciating the detailed answers like those from Hodgman and AllEightUp, because they seem to know what they're talking about.

 

Try to make games or program what you want to, and if you get *really* stuck, ask for help, there are some great devs around here.

 

 

What mindset do I have here? What mindset did I have in the other place? (If you want you could unfold (develop/say more) on that - seem somewhat interesting) Some people say to me, what I should do, and what I should not, but I know, what I want to do, and I am not searching for advice what I should do, and what I should not to do - just for answer (mainly information (or opinion - but in much less extent) not really advice) on the topic I am asking about.

To tell somebody what he should do, when he is not asking about advice is not so much wise IMO. (Of course I must just ignore such advices, Im not happy even to read that, but i think its hard to avoid - many people like to make (impose) advices not asked.

Edited by fir

Share this post


Link to post
Share on other sites


As to 'go figure' I do not know how to find that, many project sizes are probably  avaliable in google - could somebody help with finding that?, I would appreciate

 

You can find source code for some of the old games from ID Software (aka Doom, Quake, etc..) on github and probably other places. Just google it, you'll find it smile.png

 

I am not sure how you can give such accurate estimates on how many lines of code you've written in your whole life (unless you started relatively recently and kept all your code so far), personally I've been coding for almost a decade and have probably written hundreds of thousands of lines of code, though most of it is boilerplate, straightforward, etc.. (a lot of your code is, really, if you go strictly on a per-line basis, as you said most of the work is in the reasoning and logic involved, not so much in the code itself). I would guess what most developers would consider their finest code probably doesn't span that many lines.

 

But lines of code is hardly a useful metric. Yes, more features = more lines of code on average, but it's not a straightforward relationship like saying "big 3D game = 2 million lines of code, 2D indie tetris = 3k lines of code, hello world = 5 lines of code". It depends on a lot of stuff, and I am not really sure it is helpful to compare your codebase to another purely on the basis of number of lines of code. In fact it's probably detrimental on some level.

 

For what it's worth, my current project (not a game) has around 7000 lines of code all around, and I do consider it a medium project, not because of the number of lines of code but because the concepts that I need to integrate into that code are far from trivial. If you start measuring project size by applying hard limits like "above 100k is a medium project, period" then you're in for a surprise, because I am sure some really, really fun and complex games have been made in far less than that. More isn't always better.

 

Lines of code quite simply isn't a useful metric, really. If you really need to attach some number to every codebase I would suggest using man-hours spent which is already a much more concrete metric for measuring, roughly, how "complex" something is, in relation to the amount of time a bunch of programmers have been working on it. Because I too can also write horribly bad tetris code unrolling every possible game state and spanning millions of lines - if not more - but that won't make my tetris game any better than a clever implementation fitting in 500 lines of code.

Share this post


Link to post
Share on other sites

 


As to 'go figure' I do not know how to find that, many project sizes are probably  avaliable in google - could somebody help with finding that?, I would appreciate

 

You can find source code for some of the old games from ID Software (aka Doom, Quake, etc..) on github and probably other places. Just google it, you'll find it smile.png

 

 

 

I did not say that this is good metrics, its just some element

(that counts, though)

Share this post


Link to post
Share on other sites

 

Nay, I wouldnt belive that - 10k lines is say 10 medium sized files, a  couple  of procedures each - its quite a small game like extended tetris or something not a big or even medium one.

You could write the graphics and audio subsystems, and a VM/interpreter for a visual/node-based scripting language wink.png
How do you count LOC for non-line-based programming systems?

But yes, if I were quoting numbers for "big" projects, I'd go with a million.

 

 

I found that someone said that "RainbowSixVegas" is 1.7M,

GCC compiler 7M. I am searching for such type of numbers,

so if someone could post it, thanx 

Share this post


Link to post
Share on other sites
1. Not sure... probably less than 500K
2. Current project is 10K, probably will be more like 15K when done. 1K of those are comments, and 2K are blank.
3. Don't know
4. Don't know
5. I'd say <10K is fun size, <100K is small, <500K is medium, <1M is big, past that is monster.
 
In general, I consider more lines of code to be a negative side effect of adding functionality smile.png That is, the less the better, up to the point that you start sacrificing readability to save lines.
 
A related statistic is comments. I generally consider self-documenting code to be the best of all, but a lot of things aren't so straightforward so I add a line of comment explaining why I'm doing something. Or a big block comment explaining what I'm about to do with a lot of lines of code. And if I have a brilliant idea how to solve a complex problem in relatively few lines of code, it's perfectly fine if it takes more lines of commentary to explain what's happening than the actual code it's talking about.
 
Here's a good example function of pushing the boundary between "less is more" and "OMG what have I done"
void SpriteSystemYSort()
{
    Sprite *sprite = gSpriteActiveListHead;
    Sprite *activeListTail;

    if (sprite == NULL || sprite->next == NULL)
        return; // No sorting to be done unless there's more than one sprite

    // Start from the tail of the list, for minimal insert time if the order hasn't changed since last frame
    while(sprite->next)
        sprite = sprite->next;

    // Rebuild the active list in Y sorted order. Start by adding the first sprite, to save a couple null checks in the loop
    gSpriteActiveListHead = activeListTail = sprite;
    sprite = sprite->prev;
    gSpriteActiveListHead->prev = gSpriteActiveListHead->next = NULL;
    while(sprite)
    {
        Sprite *prev = sprite->prev;
        Sprite *insert = gSpriteActiveListHead;

        while(insert != NULL && insert->pos.y > sprite->pos.y)
            insert = insert->next;

        if (insert == NULL)
            sprite->prev = activeListTail, sprite->next = NULL, activeListTail->next = sprite, activeListTail = sprite;
        else if (insert == gSpriteActiveListHead)
            sprite->prev = NULL, sprite->next = gSpriteActiveListHead, gSpriteActiveListHead->prev = sprite, gSpriteActiveListHead = sprite;
        else
            sprite->prev = insert->prev, sprite->next = insert, insert->prev->next = sprite, insert->prev = sprite;

        sprite = prev;
    }
}
Specifically those 3 long multi-statement lines. On the one hand, they'd be more readable if I separated them into multiple lines. But on the other hand, they're run-of-the-mlll linked list operations, which most programmers should be familiar with. And this way, you can clearly see the whole loop (and even the whole function) at once, which makes following the flow of execution easier.
 
Another interesting point of this function is "design time optimization". I could have gone with a fancy sorting algorithm because insertion sort is technically O(n2) complexity, except that I know most of the time sprites won't change order between frames. So if I iterate through the list backward when choosing who to insert, and forward when inserting them, the new list will be built up from tail to head, inserting each sprite right at the head of the list, making the whole thing linear time.

Share this post


Link to post
Share on other sites
Personally I tend to submit 2k - 3k lines per month of polished and QA'd code. Initial dev adds lines quickly, bug fixing adds lines slowly. This number seems typical across most developers I know.

Quality of the code is variable, but number of lines tends to be similar.

Extrapolate lifetime LOC accordingly.

Share this post


Link to post
Share on other sites

Personally I tend to submit 2k - 3k lines per month of polished and QA'd code. Initial dev adds lines quickly, bug fixing adds lines slowly. This number seems typical across most developers I know.

Quality of the code is variable, but number of lines tends to be similar.

Extrapolate lifetime LOC accordingly.

 

Could be close to my values, too: when I am producing code I do it a couple times faster (though it is not polished), but then are days when I need to read and think up, test, experiment, polish and so on, so effecitively it seem to be about close to that 

Share this post


Link to post
Share on other sites

imho LOC is completely useless without specifying the language.

Also one can write 1k lines of stupid code or 100 lines of awesome code accomplishing the same. 

 

EDIT:


5. I'd say <10K is fun size, <100K is small, <500K is medium, <1M is big, past that is monster.

Sorry for voting your post down, except for the above quoted statement i'm sharing your opinion.

Actually there seems to be no way to revert that vote :/ 

Edited by LJ_1102

Share this post


Link to post
Share on other sites

fir, you should give up.  You are talking to two moderators who have been making games for a while.  Not sure about Hodge but I've been at it for a bit over 20 years now.  I'm not going to start posting a list of my games and LOC's and I suspect Hodge is of the same opinion.  LOC has no bearing on reality unless you then include team size, measure it over years of development, average salaries etc.  You'd be better off asking EA for such stats because they track it all, of course they make a lot of shitty games, go figure...

 

Yeah, I don't really know what fir is driving at here. I don't have any clue how many lines I write or how big my current project is. I suppose I could look at the revision control stats but it's been over a year since I have and I don't even remember.

 

By the way, I don't personally enjoy any recent EA games, and I'm still upset over SimCity. However:

 

http://www.metacritic.com/feature/game-publisher-rankings-for-2012-releases

Share this post


Link to post
Share on other sites

 

Yeah, I don't really know what fir is driving at here. I don't have any clue how many lines I write or how big my current project is. I suppose I could look at the revision control stats but it's been over a year since I have and I don't even remember.

 

By the way, I don't personally enjoy any recent EA games, and I'm still upset over SimCity. However:

 

http://www.metacritic.com/feature/game-publisher-rankings-for-2012-releases

 

I did not want to 'drive' something or anything (weak english) really. Close to that, when Im asking if procedural c is in usage in modern big games I do not want to drive discussion if c is better than c++ (really) but I am searching/waiting for some 'informative' answers, waiting if somebody can say something 'informative' on that. Got some answers 7k, 37k - small projects really (37k is medium imo ). Curious what do people say, If they have different approach than my own its interesting also. 

Edited by fir

Share this post


Link to post
Share on other sites

I was asked by an obnoxious dick some time ago at a project defense how many lines of code I had contributed to the project I was working on, which was a question I was in no way prepared to answer because I had absolutely no idea, nor a mechanism of finding out.  I told him I had no idea, but a random guess would be in the ball-park of 20K of code written in areas that didn't exist prior to my creating them. He just sighed and rolled his eyes at me like I just admitted to doing nothing for the whole time I was there, and used that as justification for trying to give me a bad review.

 

Should have just told him I wrote a billion lines.  What an ass.

Share this post


Link to post
Share on other sites

How many lines of code you had written in you life till now?
How many lines of code project you are working on now or was working in the past?
How many lines of code have good well known games ?
How many lines of code have todays big titles?
How many lines of code is a big project game, how many is medium project?

 

i've probably written millions if not tens of millions of lines of code. mostly c, some pascal, a little basic, plus numerous other languages for school.

 

my current project is about 70,000 line of c code. its an open world  rpg/person sim with fps interface.

 

i don't work for a big game studio, so i couldn't say how many line of code one of their titles is.

 

the terms "big project" and "medium  project" are subjective. a typical large game for me is about 100,000 lines of c code. a typical smaller game for me would be 50,000 lines of c code. a trivial game like pong, space invaders, galaga, missile command, tetris, a side scroller jump and shoot, pac man etc might be 1000 to 5000 lines of code. perhaps 10000 for a complex title. i only did one game like that once, a missile command like thing in basic, maybe 200-500 lines of code. and that was before i got into building games. you see, when i fist started to learn programming, i started by writing one of each major type of app, just to learn how it was done. so i wrote word processor, and a spreadsheet, and a database system, and a paint program, and a telecom program, and then stuff like a clone of tree pro gold and  a clone of windows 95. only then, after programming for a decade already, did i seriously get into building games. but i'd always been into games. D&D and wargames before the PC was invented, and PC games once they became available. it was my disgust at the available selection of Star Trek games that made me write my own.

 

note that theses numbers do not include the code in 3rd party libraries i use. and these numbers do include the blank lines in the source code. IE the caveman source code file(s) are about 70,000 lines in size, including all white space.

 

while lines of code is one way to measure things. as you can see, its not always the best way. 

 

when i stared out, i too wondered "how many line of code is this program i'm looking at on my screen?". its a natural question for any new programmer.

 

however, there are lines of code, and then there are lines of code. not all code is created equal, and not all code is equally lean.

 

and comparing lines of code between different languages / syntaxes is apples and oranges.

 

these days, i find man-hours required to be the best all around metric for things. but even that is subjective, depending on the productivity of the worker. so i tend to think in terms of "how many many hours it OUGHT to be if you know what you're doing and do it right" to produce CORRECT code - IE tested,  debugged, bulletproof, no chasing a bug for two months to fix a one line typo, none of that BS. that should have been fixed by the original developer at the time - even if it was you - and should have been added to the original man-hour cost. actually in that case, a review of the developer's design that allowed such a bug to occur would be called for, and perhaps they should be removed from algo design tasks. what can i say? i'm hardcore. if the guy can't write bulletproof code, he shouldn't be writing critical code. me personally, i'd probably fire them, as they couldn't be trusted to not muck up whatever part of the game you put them on (even UI or whatever). the only bugs in a program are one the developers put in. if the developers are putting in bugs, they're working against you, not for you.

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this