A BYONDscape Classic! This one comes from Deadron, and it's all about why you should be using libraries in your games right now. It's as true today as it was in 2002.

Why people don't use libraries

"Other people's code sucks! Screw libraries -- I can do it myself!"

For nigh on 20 years this has been the rallying cry of the gaming community. Using a library was a sign of mental meant you thought the library creator was better than you, and that just couldn't be. I know of a guy whose first effort every time he moved to a new company was to write his own memory manager and word processor, because he couldn't trust those things in the hands of anyone else.

Of course the result was he had a buggy memory manager and low-quality word processor, since they'd been stress-tested by a total of one person. But hey, at least he wrote it himself!

I don't know what the code is doing

People get sucked into this concern because with a BYOND library they can look at the code, so suddenly they want to know how it works. Nothing wrong with wanting to know how it works, but the real question is "Does it work?"

If it works, and the API is clear enough that you know how to call the functions, what more do you need? You probably don't avoid doing things on your computer because you don't know how the code works for what you are doing. For example, do you know what code Windows executes when you double-click a file, or what code BYOND uses when you send text to a player, or exactly which relays are triggered when you press the gas pedal in your car? I'm guessing that you don't avoid double-clicking files or sending text to players or driving your car just because you don't know exactly what happens under the hood.

Think of a library as just extending the built-in BYOND functionality. Pretend you can't see the library code. Now, is the library useful to you? If the library works and does what you need, then use it.

I don't like having to read other people's code

This is similar to the first concern...if the library is properly done, you don't need to read the code! You should be able to use it by reading the documentation (just like you do for BYOND, right?) or the demo and calling the functions as specified. Just because the code is there doesn't mean you need to read it.

If the library has no documentation or tells you to "just read the code" to understand it, then it's a bad library. Don't use it.

I want to learn to do it myself.

Libraries are definitely good places to learn coding techniques, especially if they are well-commented. Using them as a source of sample code is a fine approach -- but beyond playing with a copy of the code to see how things fit together, why reinvent the wheel? If you need a calendar object and someone has already written a calendar object that works, has been fully debugged, and does what you need, why spend time doing the code again? If you need to learn, why not learn doing something new? Why not spend time doing code no one has done before?

It's too trivial a task to use a library for

Trivial stuff is perfect for libraries! Why should you have rewrite or go find and copy the say verb for the 50th time? Why not just be pulling it from a library, whether written by someone else or by yourself? You'll save yourself a lot of hassle, and get a debugged version of the trivial task.

I'll just have to change the library anyway

A good library is designed so that you can make changes to it by overriding its functions or seting variables. Just like you'd override Move() in BYOND or set a mob's name. If the library doesn't let you do what you want, make a copy of the library code, change it as necessary, and send your changes to the library creator so they can improve the library for everyone.

Why you should use libraries

Because you are smart. Because you don't want to waste your time. Because you don't want to add new bugs to your game.

Far from being a weakness, using and creating libraries show that you understand the importance of modularized code and not reinventing the wheel. Even if you don't use libraries created by other people, putting your own frequently-used code in a library for yourself improves your code in the ways described below.

Creating a library doesn't mean you have to let others use it, by the way. If I find myself using any function in more than one game, it goes into a library. Most of the libraries I use are private libraries for myself or my team that never get publically released.

Here are some of the benefits you get from libraries, whether you create them yourself or use those written by others:

Libraries encourage proper encapsulation of code

Any functionality that can be used by multiple games should be. If it's a general problem, it should be solved once and the solution used wherever needed.

Write once, use everywhere.

Libraries take care of the drudge work, so you can focus on the cool stuff

Putting general functionality into libraries, even if you never distribute them publically, improves your games and cuts down your own development time. You or someone else as already spent the time doing the drudge work -- why not reuse that and just do the cool stuff for your new game?

Libraries encourage general well-tested solutions instead of one-time buggy hacks

Popular libraries, such as s_admin or CharacterHandling, have been in development for years, with hundreds of people using them and filing bugs and enhancement requests. That means that by using one of those libraries, you get the benefit of everyone else's time and efforts. The libraries are fully debugged with lots of functionality. Anything you write yourself is almost guaranteed to have more bugs and less functionality than the stuff that has been well-used.

Libraries let you game more games done better and faster

This is simple: If someone else wrote the code for you, or if you are using code you already wrote for another game, then you have more time for new functionality on the game you are working on now. And since you have to write less code for your new game to get it done, you'll create fewer bugs.

What it comes down to is this: If a library exists that does what you want and you aren't using it, why are you wasting your time? Don't you have a game to finish?

i use libs, i find them more effective, since there already working, and general do what u want to have don,e it makes more sence to use a lib than to do it yourself and mess it up..

i use
deadron.test(somtimes to makesure everythings running right)
dearon.texthandeling ( for some of my chat stuff )

these libs are smashing, and worth having especial when u wanna do certen things
When I grow up, I want to be a library!
Hey, I like my one-time buggy hacks! ;-P

Deadron has many sexy libraries.
I don't really like htmllib, I rather use topic() since I have more control over it.
I have a problem with simply jumping to a library: if you don't know how it works inside, then if it is ever buggy, you want new functionality, or just if you need to utilize the library in the best, most efficient way, you won't be able to unless you had re-invented the wheel and learned all the internal mumbo jumbo in the past.

You also shouldn't be too dependant on them. You're going to have to do some very complicated tasks yourself at some point and a library isn't always going to be there to help you, so it's good to learn it yourself.

I completely agree with using higher quality libraries vs. your own choppy hacks, though.
I'm personally all for libraries, the more the merrier. That said, I hardly ever find libraries that cater to my need.
I rarely use libraries, but can be useful for improved functionality. C/C++ more likely requires you to use libraries though. :|

I mainly built the ByMail Support Library because some people want to implement mail receiving capabilities (ByMail wise that is) into their games.
The biggest problem is that there's really only a handful of people around BYOND who know how to write proper libraries, while there's a whole lot of people who really don't know what they're doing and they're also writing libraries. So when you download a library, unless its from someone who has a reputation for making solid libraries, you don't know if its reliable or not.

That said, I find math, sorting and pathfinding libraries are especially useful, as well as stuff like DMPmakers/loaders, SwapMaps - anything that does a big job that probably isn't going to change much between programs.
Good points, Lummox. I used to be like that, unwilling to use others' code. (Thank god I got over that.)

I agree with LoL though. While htmllib is a very well-made and flexible library, it is a little too high-end for me. I find it much easier and efficient to handle those things myself. This isn't the case with most libraries, but that's my opinion on one.

It was nice you recommended a couple libraries. Perhaps you should have a post every so often with other libraries, their functions, and advantages.
ooh yes, totally agree. The terrible spin against use of libraries drives me crazy. There are exceptions, i dont think you should ever use a libraries demo icons. Thats very tacky, they arent meant to be used in your game! so you have a clickable onscreen hud, we have seen it before and its not attractive! make your own, they are only a placeholder! Otherwise, i fully agree, if a library is known to work, has good reviews and runs efficiently on a cpu profiling..why waste your time redoing it, i use libraries when applicable.. i try to not create the concepts of my game by looking through the libraries archive though, find out what you need to do, see if you can find the tools to do it, then do it. Scraping together working code to make a game that doesnt play fun.. thats what you need to be worried of.
It's certainly okay to use libraries, but some tasks for which a library is present on the BYOND website should not be in a library.

And I do think that sometimes it's important to understand what's going on inside the library. Sure, you don't need to know how the innards of your car work - but if you do, it can help you avoid a few common pitfalls, and you can do your own maintenance if things go wrong.

Or in other words, knowing what a library is doing helps you with debugging and allows you to use it better.