Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

How many lines is your project?

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

  1. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    Had a tool back then to do it. Current latest project is still 40k I think. I guess 20-40 is pretty normal overall (this one is C#).
     
  2. Divinux

    Divinux

    Joined:
    Jul 5, 2011
    Posts:
    205
    According to that .exe on page 1 I got 1500 lines of .cs code, none of which is mine. I write in Java and have about triple the amount of .cs code. I thought I have maybe 1500 lines in total. Crazy.

    On a slightly related note, said program from the first page, that's not Unity code, is it? If I were to change it to also count .js files, how would I compile it? I'd ask the original creator but I'm not sure he's active.
     
    Last edited: Jan 17, 2014
  3. superroxfan

    superroxfan

    Joined:
    Aug 23, 2013
    Posts:
    83
    That feeling is one of the many reasons I love programming. I detest having to make my own art; I really stink at it. I've turned to freelancing so I can get that feeling, get paid for it, and not have to make the art for the game :D But to each their own I suppose.

    I tend to write single scripts for small, single purposes. The most recent venture (my Trajectory asset on the asset store) that I recall the line count is about 500 lines . That's two classes, around 250 each. The second class is mostly a duplicate of the other, but modified to work in 3 dimensions. That number includes comments and whitespace (I tend to double-space my code, so that's quite a bit of whitespace).
     
  4. dxcam1

    dxcam1

    Joined:
    Feb 6, 2012
    Posts:
    477
    1.7k, 800 on pathfinding, 200 on custom shaders, about 500 for gameplay and 200 for AI state machine.
     
  5. Deleted User

    Deleted User

    Guest

    How in the multi-verse are people managing 40 - 200K worth of code?. I have around 50 classes and 5K worth of code in an engine sure it's not finished but I don't expect more than 20K for the completed product, are you guys rebuilding Unity from scratch?

    I suppose if I included the whole OpenGL API, it would be pretty large.
     
    Last edited by a moderator: Jan 18, 2014
  6. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,204
    Double spacing, wide margins and a large font size.
     
    Deon-Cadme likes this.
  7. HonorableDaniel

    HonorableDaniel

    Joined:
    Feb 28, 2007
    Posts:
    2,970
    Hahaha, don't forget comments!

    No but in all seriousness, I find that as long as I keep my total lines under 2,000 I'm fine. Once you pass 2000 and start getting into 3000, 4000, etc. things start getting difficult. I don't believe that one person can actively manage 200,000 lines, simply ridiculous...
     
  8. Deleted User

    Deleted User

    Guest

    HAHA, good one ;).
     
  9. ivan2532

    ivan2532

    Joined:
    Nov 19, 2012
    Posts:
    10
    I agree... My biggest project had about 8k lines of code, when i was working alone....
     
  10. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,615
    My Game, approx 10k. I did a count on it once, I recall it being about there.

    software I work on at work. 5million+

    lol. bug finding takes days-weeks.
     
  11. Sajalsh25

    Sajalsh25

    Joined:
    Jul 14, 2016
    Posts:
    2
    more than 2500 lines, im guessing. first unity project
     
  12. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    321
    over 10 000 lines , 1000 lines just in AI code not all code is in use , in use id say about 9000 or so.
    my voxel engine is 3000 lines of code alone.
     
  13. UltronTM

    UltronTM

    Joined:
    Dec 26, 2014
    Posts:
    78
    I can't help but to wonder, how much shorter the code could have been, if written in F# instead of C#.

    I see people saying that their line counts don't include white space and comments. What about curled braces? I looked at my own code, and I saw things like properties spamming with curled braces and keywords instead being "actual" code.
     
    MV10 likes this.
  14. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,442
    I used to pay a lot of attention to the number of lines of code I wrote but eventually had written so many it seemed pointless to bother with it any more. I was eager to reach 1 million. Lost interest in tracking at 2 million. Many different projects. It was more about gaining a certain amount of experience than anything else because I was continually striving to improve my code and learn new patterns and so forth during this time.

    The metric I pay most attention to now is dev time in hours. Current project has taken 24 hours so far. Goal is to complete it in 40 hours which means I am targeting 36 hours.
     
    Last edited: Aug 25, 2016
  15. Quingu

    Quingu

    Joined:
    Jan 30, 2013
    Posts:
    648
    VS tells me I have 4k lines. I made development console and rotating cube for camera testing. Making progress. XD
     
  16. HolBol

    HolBol

    Joined:
    Feb 9, 2010
    Posts:
    2,884
    My most recent? About 800 lines.
     
  17. EETechnology

    EETechnology

    Joined:
    Aug 15, 2015
    Posts:
    185
    10000 Lines!
     
  18. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,865
    Obviously pretty meaningless but a bit of fun. My raw lines (including whitepsace, you could probably halve this):

    Johns-MBP-2:~ javery$ cd $PLATFORMER_PRO/Assets/2DPlatformerPro/Scripts
    Johns-MBP-2:Scripts javery$ find . -name '*.cs' | xargs wc -l
    ...
    80695 total
     
  19. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    525
    247 scripts and 23,350 lines of code. I use same line curly braces.

    I use the attached script. I modified the directory to only search my own scripts. Don't know where I got this script initially.
     

    Attached Files:

  20. MV10

    MV10

    Joined:
    Nov 6, 2015
    Posts:
    1,889
    Heck, recently the VStudio team blogged about solution-loading performance on a single SLN that involved around a million files spanning several tens of thousand of projects. Apparently just opening the solution file on a modern high-performance machine took more than an hour (and VS2015 got that down to a couple minutes, which is why VStudio still has a pricetag and junk like Eclipse is free).

    I'm guessing it must have been Lockheed or some equally gigantic entity.

    On my own stuff I've seen millions of lines of code, but such metrics ceased to be relevant decades ago.
     
    GarBenjamin likes this.
  21. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,479
    really who cares about lines counts, its a pretty meaningless number, especially when you consider stuff like code style can make drastic changes on it, like do you put attributes on same line as fields and do you put brackets on new lines or same line as a condition.

    Just structure your projects in a logical way, don't make huge monolithic classes, and use a non rubbish IDE that offers good navigation and refactoring features.
     
    Deon-Cadme likes this.
  22. MV10

    MV10

    Joined:
    Nov 6, 2015
    Posts:
    1,889
    Although I certainly agree it's meaningless, line-counting software usually reformats to a specified style. People used to sometimes be paid by lines of code produced. That was mostly before my time, but I've known at least one guy who had such a job and they absolutely gamed that system!
     
  23. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,479
    yeah that sounds pretty stupid as well, since that can easily be gamed, and that more code almost never means better code.
     
  24. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    525
    I still find it an interesting statistic to hear about. Its not super important, but also not meaningless. Nobody here is going for high score or anything.
     
  25. MV10

    MV10

    Joined:
    Nov 6, 2015
    Posts:
    1,889
    We're talking 70s programmers here. You generally couldn't write that much more code because there wasn't that much memory just laying around to fill up. And companies were trying to find useful metrics for an entirely new kind of employee. It's easy to see how LOC was probably an obvious thing to analyze. IBM was famous for it back in the day.

    Speak for yourself! :D
     
    GarBenjamin likes this.
  26. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    kissUI.dll: about 58,850 lines and growing still. :]
    kissUIEditor.dll: about 70,070 lines and growing still. :]
     
    Last edited: Aug 25, 2016
  27. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,562
    Not Unity project, and no idea how many lines, but the application I'm working on right now in Visual Studio has 34 individual projects in it, including Unity tests, and not including all of the external services it touches. :)
     
  28. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,442
    ... or are you writing in Assembly or some other low level language. Agreed it makes a big difference. When I was tracking loc it was across several different languages starting with Assembly (and probably began as an extension of counting clock cycles although I have no idea now) although the latter chunk of tracking was primarily C.
     
  29. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,703
    How many lines is my project? As few as possible to make stuff do stuff.
     
    MV10 and passerbycmc like this.
  30. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,180
    I remember personal work projects exceeding 10s of 1000s of lines...my current project though has less than 100. It will grow but shouldn't ever reach 10s of 1000s. It would be larger if you count configuration type data, which most people don't, but is important to the game.

    Just search the net for code line counting utilities.
     
  31. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,562
    Did a quick powershell count, excluding blank lines of lines in *.cs, *.html, *.js and *.ts files (we're using Typescript and including HTML because it's an Angular app with lots of HTML views).
    1,171,500 lines
    codelines.PNG
     
  32. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,865
    Its just a bit of fun guys. No one is saying LOC means anything more than exactly what it is.
     
  33. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,773
    I've still got quite a ways to go, but so far:

    Lines: 120,305
    Files: 1,024

    Using this method
     
  34. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,442
    Visual Studio has an Analyze Menu with a Calculate Code Metrics option that will count the lines for you. Are you using Mono?
     
  35. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    6,659
    IIRC I think Deftly is like 2 or 3000, not including editor code. There is plenty of room for condensing that down, not sure I would be comfortable growing it significantly before refactoring the existing code.

    I could see large projects excluding 3rd party stuff getting to 20k and more complicated low level stuff adding double. I'd imagine 40k being a nightmare to do anything really productive with.
     
  36. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,773
    Thanks. I just did that, and it is only 34% of that.
    Lines: 41,122

    --------------------------

    Unfortunately, most of my time isn't spent creating much code, but in two never-ending features: Multiplayer & GUI.
    Multiplayer is a never-ending headache- features are never done even when they're done, because they have to be networked & bug free. All synchronized with authoritative server to prevent obvious exploits (one of the biggest headaches.)
    GUI is mostly just the user manipulating the interface, some linkage to gameplay included. Things like Inventory, Crafting, Containers, etc.

    Usually not such a big deal, but in a crafting game that heavily emphasizes constantly consuming items? A lot bigger of a deal than normal.

    Anything else, like AI or WorldGen, is so easy & fun I don't even notice doing the work.

    I have 642 hours in my project.
    (Equivalent: 4 months)

    (of a 40 hr work week)​

    Category Work.png

    Some notes:

    Management - includes not just managing others working on the project, but the time it takes to "manage" myself, coming back to code from long vacations.
    Input - Most systems for the PlayerObject & User input, while Gameplay is anything that is in addition to those systems. (Input/Gameplay are very similar).
    GUI - Anything dealing with the user interface (Backpack inventory, moving around items, Crafting GUI, animating the GUI, writing scripts to link it together with Input/Gameplay/Content), and maybe include some network code?
    Design - Includes all research, excludes a lot of "personal time" used for game design. This includes a lot of generic technical or google research, like looking up shortcuts & useful tidbits about Visual Studio. Includes "researching" the asset store for future features, like when thinking about adding a weather system.
    Content - Creating prefabs, dealing with Textures, Audio, etc. (Very similar to Gameplay)
    AI - Early prototyping & full AI for a single animal & Generic Scripts created for AI in Behavior Designer ; anything dealing with NPC's (any moving entity that isn't the player, is NPC)
    World - Any systems that deal with WorldGen Game Time, Save/Load System, etc. Also systems for Static Objects (Game Items, Trees, Foliage, Harvestable Plants). Basically any system that doesn't involve the Player (Input) or NPC's (AI) or Content (creating the actual prefabs that are placed in the world).
    Waste of Time - Pointless work that shouldn't have ever been done.
    Unity - Everything from working with Order In Layer of sprites & custom scripts, to rendering issues, core setup, etc
    Organizing - Includes cleaning up code, refactoring, rename & sorting folders/files, etc.
    Multiplayer Waste of Time - All the time I spent on UNET, before ditching it for Forge Networking.
    Multiplayer - All Forged Networking work.

    Also a lot of work, such as in GUI, is reworking systems or refactoring code to link it together with Multiplayer. So while Multiplayer shows to have taken 23.68% of the total time so far, it's likely far greater. It probably leeches quite a bit into Input, GUI, Design, AI, World, Organizing and Unity categories.


    According to VS, my biggest files are either GUI, Player Input, & Multiplayer related. Of course, that makes up the majority of the game, lol. Stuff like AI scripts are very small (tons of scripts, very few lines) and I've barely done much there besides create some generic commands & a full Bee A.I.
    The number of lines also shows some of the complexity (what I have the most difficulty with.) The GUI is by far the most complex. Before I refactored, it was a total mess hacking everything together. Multiplayer is quite simple & each function small, but SO MUCH has to be networked, it becomes one of the larger ones. Same for the Player script(s).

    Now, I have just as much time spent in "World" category, but the scripts are much smaller. AI are tiny tiny, and for how much little work I've done, it took a good chunk of time. Input has only 45h (1/2 of GUI) and felt about half as painful (but still painful), and it has some of the bigger files. So there may be a correlation between the number of lines in a script, and how enjoyable it is to write it, even when they took the same amount of time. Maybe not, but it's interesting at least.

    My multiplayer scripts are very few. I keep nearly every multiplayer command (RPC) in one class. There's a bit in the player script, but that's pretty much it. So that has very simple functions, very few lines in total, but consumes the most time.

    Possible hypothesis: The more lines, the more headache. The fewer lines, the less headache. Either that, or Behavior Designer just makes AI really easy, and WorldGen is just a freak occurrence being a complex blast of fun fun fun! And multiplayer is alot more about engineering than it is about programming.
     
    Last edited: Aug 26, 2016
  37. MV10

    MV10

    Joined:
    Nov 6, 2015
    Posts:
    1,889
    As far as I can tell, Angular was specifically designed to increase your lines-of-code count. :p
     
  38. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,562
    Lol that's very possible. There is an absolute load of boilerplate included in there, although we've lessened that by moving to Typescript. And I've found that the JS generated by the Typescript compiler is smaller and fewer lines than what we were writing by hand.
     
  39. MV10

    MV10

    Joined:
    Nov 6, 2015
    Posts:
    1,889
    I'm generally not a fan of Angular, although I'm about to start an Angular2 project (it pays the bills) and I do appreciate a lot of the house-cleaning they've done for ng2. The other day I was noticing Typescript is surprisingly similar to F# syntax (often identical), but yeah, MS did a good job with their compiler. I'm nervous about the upcoming angular-cli compiler (or ngc or whatever they're calling it) -- not sure I entirely trust those guys to take over Typescript compilation, and very sure I don't actually want them to...

    Or rather, I'm not a fan of Angular for giant enterprise projects which are destined to become 2025's legacy system. But the people signing the checks want it, so they'll get it.
     
    tatoforever likes this.
  40. dogzerx2

    dogzerx2

    Joined:
    Dec 27, 2009
    Posts:
    3,873
    How do you guys count the lines of code?

    I searched *.js in my scripts folder and I get 415 files. I estimate 15k lines of code.
     
  41. derf

    derf

    Joined:
    Aug 14, 2011
    Posts:
    349
    The only truly impressive thing about LOC is if you can get a very low count and yet have a complete game.

    Usually the large the game in either game play or features the more lines of code there are, but if you can reduce that number significantly, take a bow my friend.

    I once wrote out the character creation system from Microprose Darklands in XNA in ~2009 and it took over 80,000 lines. It worked complete with graphics, audio and simple play testing. I refactored it after learning more skills and tricks that following year and was able to reduce it to only about 8,000 lines. If I was to use Unity nowI would probably get it to a tight 5,000 lines super easy.
     
  42. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,562
    We're using Angular 1.x. We're also not relying on npm or any of the other gobs of package managers. Too much maintenance overhead right now since we're not planning on upgrading any time soon. I agree with you on the angular-cli. The whole reason for their own compiler is that it supports decorators and such that are currently experimental. I'm not sold on Angular2 yet... there's a lot I don't care for and I built my own component system for Angular 1.x so we have modular components that are built just like normal views / controllers and they support two way binding, not to mention the ability to reuse controllers with different views or swap controllers for a specific view. Very nice.

    As for TS, I'm using the 2.x beta bits from MyGet. A few steps and a powershell script to get it initially installed so I can use the most recent tooling, but now I can keep it updated and it works slick.
     
  43. roojerry

    roojerry

    Joined:
    Mar 18, 2013
    Posts:
    68

    Command line tool for counting lines of code (CLOC)

    https://github.com/AlDanial/cloc


    EDIT: And my current count...
     
    Last edited: Aug 26, 2016
    GarBenjamin and dogzerx2 like this.
  44. dogzerx2

    dogzerx2

    Joined:
    Dec 27, 2009
    Posts:
    3,873
  45. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    16,148
    GarBenjamin and dogzerx2 like this.
  46. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,562
    Ryiah likes this.
  47. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,626
    Well I'll get in on this, about my current project "Pixel Destruction":

    EDITOR SCRIPTS: 1129 + 135 + 32 + 58 = 1354 Lines
    GAMEPLAY SCRIPTS: 899 + 87 + 107 + 12 + 275 + 605 + 60 + 24 + 619 + 229 + 37 + 245 + 78 + 172 + 194 + 24 + 810 + 495 + 82 + 91 + 23 + 146 + 56 + 123 + 9 + 102 + 40 + 28 + 58 + 31 = 5761 Lines
    TOTAL C# SCRIPT LINES: 7115 Lines

    Wow, that is not even counting 3rd party assets or tools, so yeah... its grown and shrunk a few times in its development over the last few years, but I figure by release it'll be over 10k easily (keep in mind this is a mobile game!).

    Guess it is worth noting I do a lot of one liners as short as I can, and avoid making stuff multi-line if I don't have to for the sake of keeping it shorter and easier to edit later.

    Forgive me if I typed my math wrong :D
     
    Last edited: Aug 26, 2016
  48. Olander

    Olander

    Joined:
    Sep 13, 2014
    Posts:
    400
    May as well have some fun. My Genesis Framework is 437 C# scripts and 831,567 total lines of code. I estimate that about 5% more is comments. Close enough for fun. Getting closer to completion so probably will be ~600 C# scripts in the end and 1,500,000 lines-ish

    I agree with some others more lines does not make better code. My code however....is super clean. :cool::p

    Good fun all! Some really good numbers going here!
     
  49. Arcana96

    Arcana96

    Joined:
    Jun 28, 2015
    Posts:
    27
    F***ing hell @Olander that's a lot of code! My current game only has about 10,000 at the moment.
     
  50. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    I just managed to remove a huge amount of code and reduce the complexity (I consider less is more) so that's a great cause for celebration! Basically, whenever you have less code, it's a great thing. It's very tiring but I removed around 15,000 lines of redundant code with refactors, cleanups etc...
     
    Dustin-Horne and eskovas like this.
unityunity