Tau Station--A Narrative MMORPG Written in Perl

We've released our first trailer:


Play Tau Station for free and share the video far and wide!

And please don't forget to "like" that video and subscribe to the channel!

My New Homepage

I've not been writing here much because I've been busy building Tau Station--a narrative sci-fi MMORPG. I'm also doing a lot of client work and that keeps me from sharing much here since I tend to take a bit more time when I write entries on this blog.

However, I've taken the time to set up a new homepage for myself. It uses Github pages because it was ridiculously easy to get started. I'm consolidating many of my more popular articles there, and many of the pages have a comments section powered by Disqus.

If you are interested in hiring me or my colleagues at All Around The World, you check out that site or share it with your boss.

The Future of Perl 5

No, I'm not speculating about where Perl 5 is going, but I was imagining a few minor (hah!) features that would make life much simpler.

In fact, I was imagining a minimalist OO system with optional typing.

The following is a simple LRU cache in Moose:

package Cache::LRU {
    use Moose;
    use Hash::Ordered;
    use MooseX::Types::Common::Numeric qw/PositiveOrZeroInt/;
    use namespace::autoclean;

    has '_cache' => (
        is      => 'ro',
        isa     => 'Hash::Ordered',
        default => sub { Hash::Ordered->new },
    );
    has 'max_size' => (
        is      => 'ro',
        isa     => PositiveOrZeroInt,
        default => 20,
    );

    sub set {
        my ( $self, $key, $value ) = @_;
        if ( $self->_cache->exists($key) ) {
            # delete the key and set it later to ensure it's the
            # most recently used
            $self->_cache->delete($key);
        }
        elsif ( $self->_cache->keys >= $self->max_size ) {
            # key doesn't exists, so make room for it
            $self->_cache->shift;
        }
        $self->_cache->set( $key, $value );
    }

    sub get {
       my ( $self, $key ) = @_;
       $self->_cache->get($key)
    }

    __PACKAGE__->meta->make_immutable;
}

And to use it:

my $cache = Cache::LRU->new( max_size => 100 );
$cache->set($key,$value);
$cache->get($key);

The set($key,$value) method removes the oldest value if the cache size is greater than the max size. Then we delete our key and set it again (puts it at the top of the stack). Setting the max_size to zero disables the cache.

Here's the same code in my imagined future of Perl 5, with a class keyword. It also has method, has, and self (unshown) keywords, but only in the class body. It also has private and public attributes, and optional typing.

class Cache::LRU {
    use Hash::Ordered;
    my       $x        = Hash::Ordered->new; # private
    has UInt $max_size = 20;                 # default

    method set ( $key, $value ) {
        if ( $x->exists($key) ) {
            $x->delete($key);
        }
        elsif ( $x->keys > $max_size ) {
            $x->shift;
        }
        $x->set( $key, $value );
    }
    method get ($key) { $x->get($key) }
}

The devil, of course, exists in the details, but it's so much simpler and easier to read. The bigger the class, the easier it is to read. Whether that could ever be implemented is a different story, particularly having lexically scoped keywords (e.g., keywords that only exist in a scope they'd be useful in).

What would you like to see in the future of Perl 5? And what mistakes did I make in the above?

Tau Station is now live!

It's been a few years in the making, but Tau Station is now live!

It's a free-to-play post-apocalyptic interstellar MMORPG that runs in a browser, tablet, or mobile. The backend is written in Perl.

Join Tau Station and let's show the world the awesome things you can do with Perl! (And hey, spend money if you can; I need to keep the lights on) :)

We follow WCAG 2.0 AA standards for accessibility (blind and mobility impaired people can play).

Tau Station is now live

Building a Software Consulting Firm

Hey, I'm not dead! I just haven't posted in a while because I've been so busy on Tau Station (which, if all goes well, will be open for everyone real soon™).

In the meantime, I've written a bit about building a software consulting firm. You might find it interesting.

If you need to outsource software development with a firm you can trust, contact us.

About Ovid

user-pic Freelance Perl/Testing/Agile consultant and trainer. See http://www.allaroundtheworld.fr/ for our services. If you have a problem with Perl, we will solve it for you. And don't forget to buy my book! http://www.amazon.com/Beginning-Perl-Curtis-Poe/dp/1118013840/