Jump to content
  • Advertisement
Sign in to follow this  
VanillaSnake21

DLL Advantage

This topic is 4163 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Are there any advantages in runnign functions from dlls, rather than from a compiled code, besides modularity. More specifically are there any speed advantages? And a short question off the topic, a .lib file basically contains what? I know its a library :), of function lists?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
There is no speed advantage. With a DLL, you're either using

1) a dynamically linked function which has a level of indirection that you don't usually get when linking to a lib.

2) virtual functions in a class - in which case you have the virtual call overhead (no inlining, etc.)

3) function pointers (again, a level of indirection).

FWIW, I'm not dissing DLLs - I use them extensively.



Share this post


Link to post
Share on other sites
DLL's can be used as libraries across languages. I remember reading up on a tutorial on how to write a program in C++, export the code into a DLL, and load the DLL into C#. It was pretty cool, though I didn't actually finish it.

Share this post


Link to post
Share on other sites
Libraries are pretty much for modularity, but you may not have considered some of the advantages of this. DLLs will allow your programs to use the same library, which takes up less space and the OS might only load the DLL once saving memory and some processing time (which could be said to improve performance). You can also swap the DLL without having to swap other files like the executable, this allows games to keep patches as small as possible and maybe even patch without the user even noticing. As have already been said other languages will also be able to call your DLLs without caring about how it's implemented.

Of course there are also lots of disadvantages. For instance you're likely to incur a little overhead everytime you call a function. Some runtime systems like the .Net Framework or the Java VM could optimize this away and probably do (likely only for frequently called functions, which they find through profile-guided optimization), but I doubt Windows do the same thing for DLLs written in native C++. Also DLLs doesn't have native support for normal classes.

Share this post


Link to post
Share on other sites
Quote:
Original post by Drunken_Monkey
DLL's can be used as libraries across languages. I remember reading up on a tutorial on how to write a program in C++, export the code into a DLL, and load the DLL into C#. It was pretty cool, though I didn't actually finish it.


Actually thats one of the few things that I do know about about using dlls :), since im taking Java in school, theres a reserved word "native" which could load a dll that was written in c++. But thanks for the reply.

Share this post


Link to post
Share on other sites
Quote:
Original post by CTar
Libraries are pretty much for modularity, but you may not have considered some of the advantages of this. DLLs will allow your programs to use the same library, which takes up less space and the OS might only load the DLL once saving memory and some processing time (which could be said to improve performance). You can also swap the DLL without having to swap other files like the executable, this allows games to keep patches as small as possible and maybe even patch without the user even noticing. As have already been said other languages will also be able to call your DLLs without caring about how it's implemented.

Of course there are also lots of disadvantages. For instance you're likely to incur a little overhead everytime you call a function. Some runtime systems like the .Net Framework or the Java VM could optimize this away and probably do (likely only for frequently called functions, which they find through profile-guided optimization), but I doubt Windows do the same thing for DLLs written in native C++. Also DLLs doesn't have native support for normal classes.


Thanks, you pretty much answered my question, right now the game is not even close to being finished, so thinking about how im going to patch a game that maybe only two or three people are going to play, would really be a waste of time, Its just that I figured since DirecX's files are in dlls and libs that those guys put them there to speed up the API. Thanks for the replies.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!