Wednesday 29 September 2010

In which I Go

I think I mentioned that I've decided to teach myself Go, Google's new programming language. I've been doing just that, reading tutorials, style guides, tips and package documentation. It's good stuff, I'm very impressed by the design of this language.

I particularly like its clear support for concurrency, as well as the typing system. I feel that I'm learning fast, although interactions on the golang-nuts mailing list help me see that there are still some concepts that I need to learn or brush up on. I think this comes of spending the last few years coding mostly in PHP.

Now the thing about Go is that it lends itself naturally to use on servers, having some nice libraries for common server operations. That being the case I foresee using it in that context, so I set out in search of a database library.

That's one area where the core libraries seem oddly lacking so far, although that may change. However, a Go community member has developed a package called GoMySQL, which I believe will suit me quite well. I've forked the project on GitHub so that I can make any changes I need as they come up, as well as additions.

I'm an Object Oriented programmer, by education. I studied C++ mainly where I became fond of creating classes to represent concepts in my code. Go doesn't have classes, but it is object oriented. It's a departure and an interesting one, in which structs are used where we need data types, but where we need types that offer a clearly defined interface that is exactly what we write, an interface.

It serves to separate the two aspects of a class, its members and methods. Both exist in Go, but they're not so tightly bound. The same methods may apply to structs with different sets of members. A single struct type, with a single set of members, may implement multiple interfaces' methods.

In practical terms this frees design from the tyranny of type hierarchy. A type may be defined that is equally a Reader and a Writer, these being predefined interfaces. It's not a Writer derived from a Reader, or vice versa. It doesn't have both Reader and Writer as parent types. No, it simply is both, as much one as it is the other. It's smooth.

There's a lot more to it, with slices and channels and goroutines. It's all pretty cool stuff, but those are the bits that I felt like mentioning. There may be more as I continue to learn.

I have to say, as well, that I think I probably will work on that game I mentioned. It'll be slow, occasional effort, but Go looks well suited to the server portion of the system, so that's something I intend to do.

Monday 20 September 2010

Still want to create a game...

Like a lot of people who've studied programming of one kind or another, I've idly created simple games from time to time. An important part of my learning was the creation of a Solitaire game (the kind with pegs or marbles, not cards). But over the years I've had a few ideas for rather larger, more intricate games.

I've never found the time to pursue any of them yet, but there's one nagging at my mind. Actually there are two, but one is far too wide and deep to consider without having a fairly sizable team. The one that's really holding my interest right now would be comparatively small, but by no means the work of a weekend.

It's a fairly well formed idea at this point. A multi-player, on-line, real-time-strategy game with a sci-fi setting. The idea would concentrate on cooperative strategy.

It'd have to be divided into a few software components. Most obviously a server and a client, but the server itself I think should be built as a set of small, concurrent servers handling various tasks such as connections and coordination. I believe this would be an excellent application for Go, Google's language, as it has an impressive native approach to multi-threading and inter-process communication.

I see the client having an OpenGL GUI, though I'm curious about using Blender to create models/meshes. Its back-end would probably be best written in C++ or C.

The idea so fires my imagination that I have, in my mind, some reasonably well formed data flow models. I've also drawn a little game art.

Will this get off the ground? Probably not. But it's something that's probably going to hang around, attracting bits of time and effort. I'd need others to join in though, for both development and testing. The trouble there is that while I do have a friend who has just taken up game design as a field of serious study, I could hardly prevail on him to assist. Meanwhile, my pool of coder friends, with free time or otherwise, is relatively small.

And I don't even know OpenGL or Blender.

Sunday 5 September 2010

The real potential of 3D TV

Via slashdot I found an article, one of many, panning 3D TV. Of course I can understand the widespread disdain for the technology, as I've previously alluded it is used today as a gimmick. In many ways its current implementation, no matter how advanced the underlying technology (such as IMAX and realD), is no better than the use of the red-and-green '3D' of old.

But I've had a taste of what it can really do. I refer, as I have before, to watching an IMAX film in the science museum that took us to space. One of the aspects that has stuck with me ever since was the reality of the faces on that screen.

I don't care about seeing launch debris race toward me. I am aware that placing my hand in the astronaut's glove was essentially a gimmick. But those faces were important.

When I look at the face of someone standing in front of me I can see the prominence of their nose, the rise of their cheekbones, their brow ridge and socketed eyes. When I looked at the face of an astronaut in that film I could see all of those details.

These are not the shadow plays of old or the paper dolls seen in poorly made modern 3D. These are not dioramic layers or retro magic eye pictures. These are true, deep, rich stereoscopic images.

Enough evangelism, what matters is what this can be used for. I believe that properly produced 3D content could be important for both education and art, two of the most important measures of any culture.

Education begins as soon as we are born, if not sooner. Early in life, once vision has sharpened enough, visual information can be as important as aural and tactile tuition. I recall when my first nephew was younger, watching television programmes and videos made for infants.

Many of these used puppets; these were often brightly coloured with clear, bold shapes and set against a black background. If I remember rightly, from my sisters explanation of her research, this was because young children respond better to visibly real objects (puppets) and greater clarity (contrast, brightness). This was all, of course, on a 2D screen, but consider the advantages offered by 3D.

Those puppets would then appear to really be there, to be tangible objects with real geometry, helping a child's brain to process deeper visual input. They need not use the gimmickry of projecting toward the infant's head, rather they would be better rendered as though on the far side of the screen to complete the illusion. I feel sure that this would have benefit.

Then consider the continued education of growing children. I recall when I was young, being fascinated by images of a kingfisher with its colourful plumage and undeniable grace. How much richer would such an experience and memory be, had I been able to see that bird in its full, three-dimensional form?

By presenting to our children images of such detail we could help them to learn about nature, its structures and wonder. It could have potential for the teaching of geometry, of chemical structures, architecture and more. We could show them great sculptures from around the world.

This leads me to my other point, that of art. If we wish to introduce our children, or ourselves, to great sculpture we must travel for hours to view them. Of course, viewing such works in person will always be the best way, but many people have not the time nor other resources to take these trips. We could at least better see them in our home than today.

But television today relatively seldom shows us paintings. Rather, the medium lends itself to a different sort of art, a modernisation of the traditional theatre play. Players strut and fret their hour upon the stage behind that screen, the camera able to show us nuances of performance that had never been visible to a theatre audience. How much richer might that become, should they appear to stand before us?

Of course the medium would take some time to come to terms with its new aspect. Film makers would have to learn that such depth of view should be as natural an aspect of their work as colour and sound are today. But once this state is reached, what art may be produced!

I must admit that today's detractors rightly point out the primitive implementation of 3D displays today — the need for glasses, the poor image quality, such issues as these — but in time these limitations will be overcome. Once they are, how rich might the medium become.