126k lines of code...in one file



  • Just ran into this on the Silverlight forums and had to share.

    http://forums.silverlight.net/t/240580.aspx/1?126+000+lines+of+code+System+OutOfMemoryException

    Quote for lazy people who don't follow links:

    Hi,

    I do have a question. In my MainPage.xaml.cs file, I am on the 126,000:th line now coding. Sometimes when I compile I get this below exception that tell about OutOfMemoryException.

    I wonder if this depends on the big amount of code. I have 3.5 GB of RAM and there is 1.5 GB Free RAM when I compile. My XAML contain of approx: 15,000 lines of code.

    Source file 'D:\Documents and Settings\A\My Documents\Visual Studio 2010\Projects\thisProj\thisProj\MainPage.xaml.cs' could not be opened ('Exception of type 'System.OutOfMemoryException' was thrown.')

    Basically his complaint is that Visual Studio sometimes crashes when it tries to compile a C# code file containing at least 126,000 lines of code. I really hope he's a first-year CS student who hasn't really had much exposure to OOP yet.(Now that I think about it, a first-year student would not be handling a project of this size, unless they don't understand functions either and manually "in-line" all the "functions" by copy-pasting snippets anywhere they're needed.)

        </div><p>&nbsp;</p>

  • Discourse touched me in a no-no place

    @mott555 said:

    Basically his complaint is that Visual Studio sometimes crashes when it tries to compile a C# code file containing at least 126,000 lines of code. I really hope he's a first-year CS student who hasn't really had much exposure to OOP yet.(Now that I think about it, a first-year student would not be handling a project of this size, unless they don't understand functions either and manually "in-line" all the "functions" by copy-pasting snippets anywhere they're needed.)

        </div></blockquote><p>When you don't know how to design, and don't understand what OO is about at all, you wind up doing this.&nbsp; I remember a freeware Windows CE game where the main form was 15K lines of C#, because the coder didn't understand how to refactor, or to design smaller functional units.</p>

  • Trolleybus Mechanic

     He should just autoformat it to remove the line breaks. Then everything will be on only 1 line, and that'll use only 1/126k of the memory.



  • It could be over the top OOD.  Maybe he has ~1000 related classes in the same file.



  • @frits said:

    It could be over the top OOD.  Maybe he has ~1000 related classes in the same file.

    Sadly no. He states in that thread that it's one class, and all of his code is contained inside of the main method.



  • @dohpaz42 said:

    @frits said:

    It could be over the top OOD.  Maybe he has ~1000 related classes in the same file.

    Sadly no. He states in that thread that it's one class, and all of his code is contained inside of the main method.
    Oh wow, those guys responding are much more patient than I would be...  I know that makes me sound like a dick, but you need to get a grasp of the basics first, no?

    Kind of like a noob trying to build a 75 storey sky-scraper without using a steel frame and asking other architects why it won't work and how he could make it work anyway, without him actually learning or reading anything about basic structural design, etc.  I hate the "just give me the answer" questions...

    /rant



  •  It's truly an impressive piece of work. Slivers (an extremely inappropriate username, but there you go) is obviously highly skilled and shows great dedication.

     Any ordinary human being writing something like that would have had to fix thousands of bugs in the process - either that or give up in frustration at the sheer number.

    Slivers, on the other hand, has written 126,000 lines and has either produced and dealt with a superhumanly low number of bugs, or has battled thousands of the things without quitting. Either way: Respect!


  • @Watson said:

    Slivers, on the other hand, has written 126,000 lines and has either produced and (...) has battled ignored thousands of the things without quitting realizing they are there.

    FTFEveryone



  •  Of course the real WTF is that modern IDE are not able to handle 126.000 lines.

     With Vi/Emacs you can edit it fine


  • BINNED

    We've got a 40k LOC file in our code base.

    Ok, that's just one third of this one, but it's C and not some bloated XAML stuff which (presumably) mostly consists of opening and closing tags, anyway. And believe me, it's horrendous.

    But at least the compiler doesn't barf on it.


  • ♿ (Parody)

    I think that what you guys fail to appreciate is that having all of your code in one file puts it all right there in front of you. Changes are easy to make, because you don't have to go looking through your files. Undoubtedly, he has some flowcharts to explain the logic. Also, you losers probably use SCM, when you could simply comment out the old and write the new stuff. BAM! It's all right there for your jamming pleasure!



  • @boomzilla said:

    It's all right there for your jamming pleasure!
    *stepping away from the keyboard*



  • @C-Octothorpe said:

    C-Octothorpe: Sounds like fun. Lets start with your mom.

    Filed under: perv, too easy

    How's that for "too easy"?



  • if( input == '1' ) then number = 1;

    if( input == '01' ) then number = 1;

    if( input == '001' ) then number = 1;

    if( input == '1' ) then number = 2;

    if( input == '02' ) then number = 2;

    ...

    BTW, just to be contrary, I'd suggest he use the "partial" keyword to split his one mega-class into multiple files.

    EDIT: Oh damn, I scrolled down and someone on that forum beat me to it.



  • @dohpaz42 said:

    @C-Octothorpe said:

    C-Octothorpe: Sounds like fun. Lets start with your mom.

    Filed under: perv, too easy

    How's that for "too easy"?
    Ouch...


  • @Watson said:

    It's truly an impressive piece of work. Slivers (an extremely inappropriate username, but there you go) is obviously highly skilled and shows great dedication.
    ...to trolling?

     



  •  Well, with a bit of luck the next guy to maintain his code will be a sociopath that knows where Silvers lives.



  • @cconroy said:

    @Watson said:
    It's truly an impressive piece of work. Slivers (an extremely inappropriate username, but there you go) is obviously highly skilled and shows great dedication.
    ...to trolling?

    He's no C-Octothorpe, that's for sure.

     



  • @Zylon said:

    @cconroy said:
    @Watson said:
    It's truly an impressive piece of work. Slivers (an extremely inappropriate username, but there you go) is obviously highly skilled and shows great dedication.
    ...to trolling?
    He's no C-Octothorpe, that's for sure.
    Good god man, go get laid and learn to smile.  You don't have to prove to everyone that you're as annoying as you are stupid ALL the time, ya know?



  • Here we have the man who [i]quotes a troll in his signature[/i] (thereby giving the troll exactly the attention it wants), pretending to be either a) not a troll himself, or b) not stupid. Either one is a rich vein of irony.



  • @bugmenot1 said:

     Of course the real WTF is that modern IDE are not able to handle 126.000 lines.

     With Vi/Emacs you can edit it fine

    Correct me if I'm wrong, but the above quote says that he runs into the OOM error only if he tries to compile the whole thing.



  • @Zylon said:

    Here we have the man who quotes a troll in his signature (thereby giving the troll exactly the attention it wants), pretending to be either a) not a troll himself, or b) not stupid. Either one is a rich vein of irony.

    We're all trolls, move on already.


  • ♿ (Parody)

    @Rhywden said:

    @bugmenot1 said:
    Of course the real WTF is that modern IDE are not able to handle 126.000 lines.

     With Vi/Emacs you can edit it fine


    Correct me if I'm wrong, but the above quote says that he runs into the OOM error only if he tries to compile the whole thing.

    But doesn't VS normally compile in the background? I suppose you could turn that off.



  • @mott555 said:

    Just ran into this on the Silverlight forums and had to share.

    http://forums.silverlight.net/t/240580.aspx/1?126+000+lines+of+code+System+OutOfMemoryException

    The forum itself is a bit WTF-y....

    What pages?

     

    Just how many integer-numbered pages did it omit between "2" and "3", anyway?

     



  • @blakeyrat said:

    @Zylon said:

    Here we have the man who quotes a troll in his signature (thereby giving the troll exactly the attention it wants), pretending to be either a) not a troll himself, or b) not stupid. Either one is a rich vein of irony.

    We're all trolls, move on already.

    Can I get a "Hell Yeah!"



  • @DaveK said:

    @mott555 said:

    Just ran into this on the Silverlight forums and had to share.

    http://forums.silverlight.net/t/240580.aspx/1?126+000+lines+of+code+System+OutOfMemoryException

    The forum itself is a bit WTF-y....


    Just how many integer-numbered pages did it omit between "2" and "3", anyway?

     

     

    ...do they not count one, two, oswald, narragansett, three where you come from? Where did you go to school?

     


  • Trolleybus Mechanic

    @Someone You Know said:

    ...do they not count one, two, oswald, narragansett, three where you come from? Where did you go to school?
     

    "What would you do if you had a million dollars?"
    "I'll tell you what I'd do, man: narragansett chicks at the same time, man."



  • @Lorne Kates said:

    @Someone You Know said:

    ...do they not count one, two, oswald, narragansett, three where you come from? Where did you go to school?
     

    "What would you do if you had a million dollars?"
    "I'll tell you what I'd do, man: narragansett chicks at the same time, man."

     

    "How many combat drops?"

    "Uh, narragansett. Including this one."

    "Shit."

     



  • I remeber decompiling a J2ME game once. It had only a one huge class ~30kb, and only about three other helper ones. But at that time, it made sense, because craming everything into one class made it siignificantly smaller and allowed you to bypass the 64Kb Jar limit. Must be a nightmare to code in an envirnonment where this kind of thing is "best practice".


  • Discourse touched me in a no-no place

    @msntfs said:

    I remeber decompiling a J2ME game once. It had only a one huge class ~30kb, and only about three other helper ones. But at that time, it made sense, because craming everything into one class made it siignificantly smaller and allowed you to bypass the 64Kb Jar limit. Must be a nightmare to code in an envirnonment where this kind of thing is "best practice".

    Welcome to embedded systems development! (Or, you know, 8-bit computers like Atari, Apple...)



  • OutOfMemoryException is basically the CLR's way of saying "you done fucked up son, don't do that again".



  •  "Perheps this is the way to go then instead of partial class. I have never worked with classes in that way where I create them myself so I am not sure of how to do this actually."

    THIS.

    and in the next post after that he talks about doing something asynchronously with BackgroundWorker.

     



  • @DaveK said:

    What pages?

    Windows 2000 still? Wow.



  • @bannedfromcoding said:

    @Watson said:
    Slivers, on the other hand, has written 126,000 lines and has either produced and (...) has battled ignored thousands of the things without quitting realizing they are there.
    FTFEveryone
     

    I wouldn't have thought that everyone needed that fixed.



  • @Daniel Beardsmore said:

    @DaveK said:
    [ ... image snipped ... ]

    Windows 2000 still? Wow.

    Yeah, I'm retro like that.

    Also, it still works and runs all the stuff I want to run in my day-to-day usage.  (Well, actually, just a couple of months ago I finally found something that it won't run that I want to run, so I guess I'll upgrade to XP sooner or later, but haven't felt the urgent need yet.)



  • I started hitting XP-only programs years ago. XP took a lot of getting used to, but I think the universal 32-bit graphics sealed it for me. Windows 2000's ghastly 16-colour tray icons were difficult to bear, and the giveaway in your screenshot was the 24-bit window icon.

    What's sad is that this means that, one day, I'll actually look back on XP with the same distaste as I do now with 2000. For the time being, Windows 7 is just a senseless headache.


Log in to reply