Skip to main content
GameDev.net gamedev.net
🔒 Locked

about lines of code

Started by fir Aug 18, 2013 at 7:28 AM 37 replies 11.9k views
Original Post
fir
fir

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.

Hodgman
Hodgman

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

...[insert generic rant about how LOC is an absolutely useless and meaningless metric]...
...Some of the most important changes that I've comitted to a project have decreased the total LOC counter (e.g. replacing 100 lines of buggy code with 50 lines of working code)...
...Some of the longest and most important tasks don't produce very many lines of code (e.g. there was a critical bug stopping the game from being shipped, which took me two months to find/fix, and fix resulted in one line of code being modified)...

1) No way to know.
2) I'm writing a game engine at the moment, which has 38366 LOC (374791 if you include third party libraries).
3/4/5) The big games I've worked on have often had 1-3 million LOC by the end (including engine). There's no strong link between the size of a project and the LOC count though. You could have a large game with only 10k LOC...
fir
fir

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)

fir
fir

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

Hodgman
Hodgman

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.
fir
fir

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]

SimonForsman
SimonForsman

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.

[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
weeska
weeska

[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.

fir
fir

[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.

Bacterius
Bacterius




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.

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”
fir
fir

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)

fir
fir

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

DekuTree64
DekuTree64
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.
Cosmic314
Cosmic314

“I have only made this letter longer because I have not had the time to make it shorter." -- Blaise Pascal

frob
frob
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.
fir
fir

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

LJ_1102
LJ_1102

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 :/

Jan F. Scheurer - CEO @ Xe-Development Sign Up fo
Pink Horror
Pink Horror

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

fir
fir

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.

Oolala
Oolala

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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.