Jump to content
The Dark Mod Forums

Learn to program


pakmannen

Recommended Posts

  • Replies 63
  • Created
  • Last Reply

Top Posters In This Topic

I'm not a real programmer

Says one of TDM's main programmers. Sheesh. :laugh:

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

1. Do Ishtvan's bidding

2. ???

3. Profit!

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

Writing your own garbage collection is good practice anyway.

 

Not really :unsure: . Re-inventing a square wheel when there are tried, tested and robust round wheels already in existence is very bad practice indeed.

Link to comment
Share on other sites

If you rewrite it because you want to know how it works, that's ok. If you rewrite it, because you need one, and you haven't even looked at all the other solutions, that's indeed bad practice.

 

Good point -- I took Domarius' use of the phrase "good practice" to refer to best practices in design, when in fact this could equally be referring to "practising" certain programming techniques for learning purposes.

Link to comment
Share on other sites

Yeah I meant practicing.

 

I might be showing my lack of experience, but asides from Java's automatic garbage collection, what else is there at the moment? I know you do it manually in C++, because you want to be in control, and say you complete one level in a game and move onto the next, you want to ensure the previous level is all flushed before the loading screen, making room for the next one, and not randomly occouring during the next level causing frame rate stutters and taking up memory.

Link to comment
Share on other sites

I know you do it manually in C++, because you want to be in control, and say you complete one level in a game and move onto the next, you want to ensure the previous level is all flushed before the loading screen, making room for the next one, and not randomly occouring during the next level causing frame rate stutters and taking up memory.

That's not actually such a problem as long as you manage the garbage collector responsibility (which almost nobody does). Most garbage collector implementations will have a way for you to tell them "do a full sweep now and don't return until you're finished", so you'd just call that to flush the previous level after dropping all references to that level's data (though explicitly freeing things is a responsible thing to do, even when you do have a GC on hand). And as long as you explicitly destroy objects that are being created on a regular basis mid-level, the garbage collector shouldn't be invoked mid-level much at all, making it practical for action-oriented games; obviously you can get away with being a bit lazier if the game is more slow-paced. And there are implementations where you can cap the amount of time spent in the GC, so the CPU time cost gets amortised over a longer period.

 

Basically the idea is that you can (and sometimes should) still manage your own memory - the GC is just there for when you're lazy, and to save you from yourself when you screw up.

 

Lots of newer languages besides Java use garbage collection these days; C#, D, Python, Ruby, the list goes on and on.

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
Share on other sites

You don't have to use unpredictable garbage collection either; implementations like boost::shared_ptr use simple reference counting so that a resources is destroyed as soon as the last reference to it disappears, rather than some unspecified time later in a separate thread. GTK does this as well with its GtkWidget elements.

Link to comment
Share on other sites

Generally, garbage collection involves implicit, lazy deallocation of memory, whereas shared pointers involve implicit but strict deallocation (you know it will happen when the last reference is deallocated). With shared pointers, you're explicitly deallocating the references, and you know that when you get rid of the last pointer it will deallocate then, not the next time the garbage collect algorithm decides to run.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recent Status Updates

    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 4 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
    • nbohr1more

      Looks like the "Reverse April Fools" releases were too well hidden. Darkfate still hasn't acknowledge all the new releases. Did you play any of the new April Fools missions?
      · 5 replies
×
×
  • Create New...