about lines of code

Started by
37 comments, last by Satharis 10 years, 8 months ago


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

Advertisement


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


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)

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

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.

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

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.

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

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 for Xe-Engine™Beta

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

This topic is closed to new replies.

Advertisement