Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How many lines is your project?

Discussion in 'General Discussion' started by hippocoder, Oct 1, 2011.

  1. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I'm currently spanning 62 files and 40,000 lines of code. This does not include C# scripts or vectrosity or any addons, just my own code.

    It's getting to the point where its fairly tiring to hunt down a bug!

    The app is a music and lifestyle app that encourages experimentation and creativity for ipad.

    Post your stats, and a brief entry about your project for fun.
     
  2. sebako

    sebako

    Joined:
    Jun 27, 2009
    Posts:
    301
    I got one game prototype with about 26,000 lines and a small mobile game with ~7000 lines
    also some tools which are about 2000-3000 lines each (self written). Overall I do manage to have ~50k while maintaining
    a good level of extendable code, plugin usage, modules so that hunting down a bug will not end up in a hours task.
    If I get a bug I will exactly know where it is coming from, at least at this time, maybe this will get harder if the codebase
    gets bigger.
     
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yeah but you know, unity's managed to keep my project pretty well managed due to how flexible it is. I would argue I would be in a lot more trouble with classic C++ since the object/script based model allows a lot more containment and reusability.
     
  4. Cominu

    Cominu

    Joined:
    Feb 18, 2010
    Posts:
    149
    I wrote about my project size here: http://www.subvertgames.com/blog/28

    Lines of code: 16613 (120 scripts)

    I'm counting only original lines stripped from comments...it's a game project for iPad and desktop and only half of the features are in a completed state but the more I'm spending time with this project, the more I see the lines of code number going down :D
     
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I'm hoping for 10-20 for next project. This one is outlandish as it's an app which allows people to create content, so understandable :)
     
  6. TehWut

    TehWut

    Joined:
    Jun 18, 2011
    Posts:
    1,577
    20 lines (of my own code :p )
     
  7. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    80 lines (not my code:p).
     
  8. ant001

    ant001

    Joined:
    Dec 15, 2010
    Posts:
    116
    i've had three lines, and this stuff is looking great now!
     
  9. CoatlGames

    CoatlGames

    Joined:
    Apr 25, 2008
    Posts:
    773
    my project with the most lines is around 5000, still on the small scale, but im sure it will grow a lot more in the future
     
  10. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,608
    Estimating: 2-4000 atm.
     
  11. dogzerx2

    dogzerx2

    Joined:
    Dec 27, 2009
    Posts:
    3,964
    Last edited: Oct 2, 2011
  12. andorov

    andorov

    Joined:
    Feb 10, 2011
    Posts:
    1,061
    What are you guys using to get the stats, I ended up writing a program in case anyone wants it.

    Binaries here:
    View attachment $CodeMetrics.zip

    Code here:
    Code (csharp):
    1.  
    2. class Program
    3. {
    4.     static void Main(string[] args)
    5.     {
    6.         Int32 lines = 0;
    7.         Int32 numChars = 0;
    8.         ProcessFiles("./", ref lines, ref numChars);
    9.  
    10.         Console.WriteLine("Total lines: " + lines);
    11.         Console.WriteLine("Non-white space characters: " + numChars);
    12.         Console.WriteLine();
    13.  
    14.         Console.ReadLine();
    15.     }
    16.  
    17.     private static void ProcessFiles(string dir, ref Int32 numLines, ref Int32 numChars)
    18.     {
    19.         var files = Directory.GetFiles(dir);
    20.         foreach (var file in files)
    21.         {
    22.             var ext = Path.GetExtension(file);
    23.             if (ext == ".cs")
    24.             {
    25.                 var lines = File.ReadAllLines(file);
    26.                 foreach (var line in lines)
    27.                     numChars += line.Trim().Length;
    28.  
    29.                 numLines += lines.Length;
    30.  
    31.                 Console.WriteLine("Scanned " + Path.GetFileNameWithoutExtension(file));
    32.             }
    33.         }
    34.  
    35.         var dirs = Directory.GetDirectories(dir);
    36.         foreach (var d in dirs)
    37.             ProcessFiles(d, ref numLines, ref numChars);
    38.     }
    39. }
    40.  
     
  13. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    126 classes and 45k lines of code
     
    deus0 likes this.
  14. TehWut

    TehWut

    Joined:
    Jun 18, 2011
    Posts:
    1,577
    That's a nice game you got there! :D

    Reminds me of Donkey Kong Country...
     
  15. UnknownProfile

    UnknownProfile

    Joined:
    Jan 17, 2009
    Posts:
    2,311
    I'm working on an iPhone game and currently have about 100 lines of my own code so far and 3 scripts. The most functional code so far is for the player, so it has many more lines of code than the enemy as of yet. I also coded an intermittent waterfall which didn't take up many lines either.
     
  16. echologin

    echologin

    Joined:
    Apr 11, 2010
    Posts:
    1,078
    i have more midi notes controlling things in app then code, i think im at 90,000 midi events maybe 10,000 lines of code ( but the code is so l33t sometimes i amaze even myself )
     
  17. dogzerx2

    dogzerx2

    Joined:
    Dec 27, 2009
    Posts:
    3,964
    Yeah! Still not as good as papa hippo!

    We gotta work hard to get to the top!

    I estimate my project will have a grand total of 3k~4k lines of code :-0
     
    deus0 likes this.
  18. n0mad

    n0mad

    Joined:
    Jan 27, 2009
    Posts:
    3,732
    69 C# files here (no external script), 14553 real LOC (= by stripping out comments and blank lines).
    (I had a 20000 LOC version back in 2009, but entirely rebuilt it from scratch to a 5000 LOC version).
     
  19. ar0nax

    ar0nax

    Joined:
    May 26, 2011
    Posts:
    485
    ~ 36+ k lines of code in 130+ scripts. (all C#)
     
  20. HarvesteR

    HarvesteR

    Joined:
    May 22, 2009
    Posts:
    531
    I haven't checked in a while but I think I'm around 50,000 lines, on some 200+ scripts (not counting plugins). All C# too.

    Cheers
     
    deus0 likes this.
  21. dogzerx2

    dogzerx2

    Joined:
    Dec 27, 2009
    Posts:
    3,964
    How can anyone handle over 20k lines of code?
    My brain would collapse if I had to remember where I left my codez between 200+ scripts and 50k lines of codes!

    I bet debugging must be a b*! How do you do it?

    Any tips to organize code better?
     
  22. HarvesteR

    HarvesteR

    Joined:
    May 22, 2009
    Posts:
    531
    Well, I try really hard to keep each bit of code in it's proper place, and avoid cross-dependencies as much as possible. If code has to be added to a particular feature, it gets added either to a new script of it's own, or the most appropriate class.

    Basically the idea is not having to remember where you left each piece of code.

    This isn't so simple all the time. On more than one occasion we had to take apart a lot of old code, to re-do it in a more well-structured manner.

    I also try to keep scripts small, and although not always possible, I try to make it so one script = one feature.

    Also, Visual Studio helps. A lot. We were having serious trouble tracking bugs until I found the 'vew call hierarchy' feature in VS, which shows all incoming and outgoing function calls from any method in your project. That really helps.

    I also do unit-tests. If I'm writing a new, potentially complex feature, I do it in a separate scene (or even a separate project), where it can work independent of other components in the game. This keeps the new code isolated from the rest, which makes it possible to iron out bugs before the new system is added to the whole project. The idea of a unit test is to put the new code through it's paces, to make sure everything works as intended before it's integrated with other code.

    If all components are unit-tested as much as possible, you can pretty much plug-and-forget. There are bits of code in my project I haven't seen in over 8 months.

    Also, last but definitely not least: You see a NullReferenceError, you drop everything and hunt it down. Null references are the hardest thing to track, so if one crops up, you have the best chance of catching and fixing it when it's first spotted.

    Cheers
     
    Last edited: Oct 3, 2011
    deus0 and dogzerx2 like this.
  23. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Agreed VS + something like Resharper makes a day night difference in managing the code etc. Some good UMLs etc generated in Visual Paradigm on the general design saves you a lot of stress too when you need to change something that otherwise can lead to a nightmare due to the regression.

    All the contract work currently under my authority together sums up to beyond 140k lines of code and so far its no problem handling it.
     
  24. justinlloyd

    justinlloyd

    Joined:
    Aug 5, 2010
    Posts:
    1,680
    Yep, VS2010 + Devexpress with CodeRush and Refactor! Pro. Makes code navigation very easy. Unity has cut way down on the KLOCs for projects these days because I no longer have to wrangle engine code. :) The last big project I worked on would have been Shrek The Third with probably around a half million lines of Lua and C++ code. In its defense, it was being built on something like five separate and disparate platforms. :)

    With VS2010 to create my .NET command line tools and Unity3D to do the heavy lifting in the game engine, a full rebuild is now measured in tens of seconds instead of tens of minutes.

    Used to swear by Visual Assist but switched when they went through a period of greed and would stop you installing a legitimately paid for version of the software if it was "too out of date." Not sure if they still do that, but Whole Tomato lost me as a customer at that point.
     
  25. Kinos141

    Kinos141

    Joined:
    Jun 22, 2011
    Posts:
    969
    over 2300 lines, and my game is only 50% complete. UGH!!!
     
  26. handsomePATT

    handsomePATT

    Joined:
    Nov 30, 2010
    Posts:
    574
    I have about 10000 in 30 scripts. Just a small IOS game.
     
  27. GGames

    GGames

    Joined:
    Oct 20, 2012
    Posts:
    66
    The first Unity game for iOS I'm making was about 6800-6900 lines last I checked with Unitron. It is still not done though.
    Unrelated to Unity, but for a comparison: A Flash game I've finished about 80% is about 15k but including my framework which is almost 5000 lines, so only the game itself is about 10k. If I rewrote/translated the exact same game in Unity(The game is 2D by the way), my estimation of the number of lines would be about 20k with everything except third party libraries like TK2D...
     
  28. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    I think around 500 lines, this includes not much really just my AI only 121 of those are going to be in the end game... this doesn't include the character controller from standard assets and mesh combine.
     
  29. kingcharizard

    kingcharizard

    Joined:
    Jun 30, 2011
    Posts:
    1,137
    most lines i ever had in a project was 1300 it woulda probably been more but I stopped working on the project
     
  30. typane

    typane

    Joined:
    Nov 25, 2011
    Posts:
    297
    Measuring games in accordance to how many lines they are is stupid and inaccurate.
     
  31. khanstruct

    khanstruct

    Joined:
    Feb 11, 2011
    Posts:
    2,869
    That depends on what you're measuring. If you're measuring the number of lines of code (which was the point of the thread; "for fun") then its very accurate. No one said we were measuring quality.

    My interactive timeline is about 1750 lines (11 scripts) so far (and almost done). It also uses 6 external text files, but those are just for content.
     
    Last edited: Oct 21, 2012
  32. typane

    typane

    Joined:
    Nov 25, 2011
    Posts:
    297
    That being said then my last project was about 8000 lines prior to that it was 2000, current game will most likely be more.
     
  33. Westerbly

    Westerbly

    Joined:
    Aug 15, 2012
    Posts:
    60
    I like to see how long is my code. It's like seeing how your baby has grown :3

    Something around 600 lines right now, just beginning.
     
  34. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    Haha, just realized how old this thread is.
     
    deus0 likes this.
  35. UnknownProfile

    UnknownProfile

    Joined:
    Jan 17, 2009
    Posts:
    2,311
    I was wondering why it was necroed.
     
  36. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,816
    These are my stats for M.T.R - Extreme Offroad using DPak's solution statistics tool...

    C# files : 59
    Lines of code : 52431

    There is another solution I use for the services such as online player registration etc but these are in another solution and are fairly minimal.
     
  37. AqusSeven

    AqusSeven

    Joined:
    Aug 10, 2011
    Posts:
    119
    The c# lines/file ratio seems a bit high in this thread. Partial classes are your friends. C# lines of code don't really mean anything because c# is so abstracted. In the last 4 years I have written at-least 1.8 million lines of c++ :p
     
    Last edited: Oct 21, 2012
  38. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,816
    I'd be interested to hear how partial classes help you in Unity. I can understand in web/windows forms development, but how would you use them for Unity?
    Agreed, C++ is a lot of work :D

    Thanks
     
  39. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    The less lines of code you have could indicate that you are actually reusing class instances in different places throughout an app. This is a very good thing to do and something people should strive for.

    And my new game Falcon XDX (check signature for link) is ~2600 lines of code across ~145 script files (disregarding prime31).

    I honestly don't know how people can manage script files that are 500-1000+ lines. Unless that script has some ultra specific focus and requires this many lines, this would just be a big blotch of fog in my mind. For me so far, everything under 100 lines seems just fine.
     
    Last edited: Oct 21, 2012
  40. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    I'm at a few thousand lines here. My biggest project every was about 25,000 lines of assembler code .. but due to the nature of assembler it tended to take a lot of instructions to get stuff done. So far in Unity I haven't gone past a few thousand so have tended to stick with a single (or only few) script file, but I think I'm going to have to consider breaking some stuff up into chunks somehow.
     
  41. DexRobinson

    DexRobinson

    Joined:
    Jul 26, 2011
    Posts:
    594
    I take pride in keeping my code clean and able to reuse a script for more than 1 thing. That being said I have 22 scripts with 5500+ lines of code for ACME Planetary Defense for IOS/Android.
     
  42. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Blew through that completely :( another monolithic huge bloated mess, courtesy of your favourite aquatic fatty.

    To clarify I think "less is more" - if I'm doing too much code, or too many lines - it's harder to debug, harder to maintain, harder to port... well you get the message!

    The problem is that to get speed you need tonnes more code. For example a sendmessage would clear up my project MASSIVELY - however sendmessage is the kiss of death for mobile.

    Is there any chance of unity offering a way to sendmessage that is a lot, lot faster yet as simple? it would be nice if the component stuff and the sendmessage stuff was optimised a lot more than it is right now. That would dramatically cut down on garbage code, bugs, development times, if we could use it freely.

    Currently I have to cache the target script I want to send the message to, then add tonnes of "repeat" code for each different type of thing I want to send the message to since I'm calling a function directly on a cached refrerence of the target script. This is very fast but leads to bloated repetitive code patterns since I need to account for every kind of object that's different. If unity were able to add internal hashtables or such to very quickly look stuff up for sending messages, it would mean we could use the power of unity. Currently I can't really use the power of unity because its freaking slow :p

    Or do people have tips on how we can get a faster sendmessage? Or perhaps a design proposal for getting stuff communicating very fast across the project.

    The problem with sendmessage only arises when you comply with unity's design principles, for example unity wants you to make components and stack them, and unity would prefer if you just use an update per script. This design allows for proper use of the unity editor and workflows, tight integration with monobehaviour and even animation. It all ties together beautifully in a team environment as they can add prefabs built with scripts. But this kind of design means a heavy reliance on sendmessage for ai, for cross talk and so on.

    But if I want to do that (not much choice) I need a faster sendmessage or my code gets bloated working around it.
     
    Last edited: Oct 22, 2012
  43. marcoantap

    marcoantap

    Joined:
    Sep 23, 2012
    Posts:
    215
    My project went down from 5000+ lines to 3800... optimizations :)
     
    deus0 likes this.
  44. HarvesteR

    HarvesteR

    Joined:
    May 22, 2009
    Posts:
    531
    my last reply was about a year ago... Here's the latest count for KSP:

    About 200,000 total lines (including third party plugins and editor code)

    About 70,000 lines for the main game assembly (which is mostly our code).

    Both counts are ignoring whitespace and comments.

    It's large, certainly, but as of the last few months, things have actually been getting simpler (from organization overhauls and better planning practices we picked up over time), even though the line count has been ever growing.

    Cheers
     
    AdamFoster and djweinbaum like this.
  45. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    Content creation requires SO much UI ==> lots of code. UI code bloats itself due to protections and safety and hundreds of details. I thought about releasing my real-time authoring system for Unity several times, but... would require too much investment in UI cleanup. What works for me is not sufficient for public release.

    Gigi
     
  46. Geta-Ve

    Geta-Ve

    Joined:
    Jul 17, 2012
    Posts:
    12
    Seeing as how I am absolutely new to programming, I don't have much right now. I think mine is about 200 lines of code, that could, probably, be condensed immensely. It's hilarious watching my artist brain try and program. :D
     
  47. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Geta-Ve - that is a good thing. Less code is ALWAYS less bugs that can be potentially introduced. Keeping it clean and modular in separate scripts with simple commands like SendMessage is an artistic and creative way to make code. However, the downside is - its not all that fast - especially if like me you have a lot of little things requiring communication with lots of completely different things, in an open sort of way.
     
  48. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    Hippo,

    We built our own messaging system. It was pretty simple, especially compared to the Game Manager infrastructure we built for Delta3D years ago. Here's a good Unity starting point: http://www.unifycommunity.com/wiki/index.php?title=CSharpMessenger_Extended.

    Basically, we have several message types (templated to allow for extension) and a global Notifier class. Components that WANT messages register as a listener. The listeners are registered by type and can be turned on/off based on their internal state. It uses delegates, and it's fast and clean. The entire system is under 300 lines of code, including comments.

    Gigi.
     
  49. Geta-Ve

    Geta-Ve

    Joined:
    Jul 17, 2012
    Posts:
    12
    Ya, I find myself constantly scratching my head as to why certain things have to be done certain ways. The thing is, I kind of abhor programming, but necessity dictates that there is no one else to do it, so learn I must. lol.

    Although, to be fair, cracking a hard piece of code, and seeing it work after hours, nay, days! of frustration is actually kind of a magnificent feeling. ^_^
     
  50. Essential

    Essential

    Joined:
    Sep 8, 2011
    Posts:
    265
    How did you guys count your code?
     
    CarterG81 likes this.