# Hash Keys in WEBrick config.rb

**URL:** <https://www.ruby-forum.com/t/hash-keys-in-webrick-config-rb/50825>\
**Category:** Ruby\
**Created:** [December 21, 2005, 4:25pm UTC](https://www.ruby-forum.com/t/hash-keys-in-webrick-config-rb/50825 "2005-12-21T16:25:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Explosiv0SX](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce73a5/32.png) [@Explosiv0SX](https://www.ruby-forum.com/u/Explosiv0SX)\
**Post date:** [December 21, 2005, 4:25pm UTC](https://www.ruby-forum.com/t/hash-keys-in-webrick-config-rb/50825/1 "2005-12-21T16:25:34Z")

</div>

Hi – long time lurker, first time poster.

While searching for Ruby app configuration best practices, I came  
across the config.rb file for WEBrick. In this file, a few hashes are  
created as follows:

```
 General = {
   :ServerName => Utils::getservername,
   :BindAddress => nil, # "0.0.0.0" or "::" or nil
   :Port => nil, # users MUST specifiy this!!
   :MaxClients => 100, # maximum number of the concurrent

```

connections  
:ServerType =\> nil, # default: WEBrick::SimpleServer  
:Logger =\> nil, # default: WEBrick::Log.new  
:ServerSoftware =\> "WEBrick/#{WEBrick::VERSION} " +  
“(Ruby/#{RUBY\_VERSION}/#{RUBY\_RELEASE\_DATE})”,  
:TempDir =\> ENV[‘TMPDIR’]||ENV[‘TMP’]||ENV[‘TEMP’]||’/  
tmp’,  
:DoNotListen =\> false,  
:StartCallback =\> nil,  
:StopCallback =\> nil,  
:AcceptCallback =\> nil,  
}

I’m curious as to why the author used symbols here as the hash keys.  
Is it for performance reasons? My first inclination was to use  
strings in the same way, but after seeing this, I started to wonder  
how these symbols are represented internally compared to strings.

Can anyone shed any light on why symbols are used here?

Rick

---

<div class="post-metadata">

**Author:** ![Explosiv0SX](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ce73a5/32.png) [@Explosiv0SX](https://www.ruby-forum.com/u/Explosiv0SX)\
**Post date:** [December 21, 2005, 4:46pm UTC](https://www.ruby-forum.com/t/hash-keys-in-webrick-config-rb/50825/2 "2005-12-21T16:46:54Z")

</div>

On 12/21/05, Explosiv0SX [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> :MaxClients => 100, # maximum number of the concurrent
> :AcceptCallback => nil,
> 
> ```

Largely a matter of style - plus you have to type one less letter 🙂

Symbols will be slightly more efficent and use a little less memory,  
as every reference to an existing symbol will become a reference to  
the existing symbol in the symbol table. Of course the flip side is  
there is no garbage collection of symbols, so they are there to stay,  
where string objects can be collected and discarded when they are no  
longer needed. This is only a real issue in long running processes  
that might create many dynamic symbols.

pth
