Saturday, December 29, 2007

From dev to politics: I am taking part of Fox News boycott

I am officially boycotting Fox News and their supporters for there not allowing Ron Paul to participate in the Jan 2008 debate.

Cool links, cool projects

I have always like the lucene/nutch project. This looks like yet another cool tool.

Project Euler, enough said.


Why botlist sucks but doesnt suck as bad?

By and large, I have tried to live a life of purpose. When I mean purpose, I mean that I try to use my time for doing useful things. I try to create useful things. Sometimes it becomes difficult because time is limited and creating useful things in the year 2007, 2008 never straight-forward. I am working on the botlist application as a means of gathering useful information on the web, and filtering useful information on the web, allowing users to filter useful information on the web. Botlist may not get to the point where I want it to, but at least I made an effort to create a useful application. The data is open, the code is open. I will do my best to provide users with other useful tools.

I look at other web 2.0 applications and shake my head in amazement at the uselessness of the various public tools. Twitter is a good example. It will probably receive a lot of funding and the twitter team will come up with a snazzy implementation, but the original concept is pretty useless. Some have called twitter a micro-blog. A blog is worthless (yes, including this one), a micro-blog is worthless times two. Why is it worthless? Isn't it obvious; who cares what you had for breakfast, or that you just got back from the mall. It is kind of funny how PC magazine editors spin twitter into gold because some silicon-valley investor told them to. "twitter!!! it is gold, baby, roll with it"

I don't have any ill will against twitter; twitter is just my reference example of the misguided web2.0 world. I feel the same way about facebook,, myspace, and clones.

Good Web 2.0 Apps/or other projects

Google-* (maps, docs, etc)
Reddit (digg, you are skating on thin ice)

Suspect Web 2.0 Apps


Thank god no-one reads my blog?

Friday, December 28, 2007

Thursday, December 27, 2007

Short Post, an working example for a meta language with Antlr 3.0+

There aren't too many FULL examples of a Antlr based grammar for the 3.0+ versions. If you actually research the grammar file, it isn't too difficult to go from vers 2 to 3, but when you are starting out it may throw some people off.

In any case, I was working on a grammar for my botlist remote definition file and threw together a grammar. The full source is available and it will parse an example grammar and print out critical tokens and values.

Saturday, December 22, 2007

Berlin from Dallas, going after text analysis

Hello, I am coming to you from Dallas Texas (close to it, anyway). I am going to take a break from the Octane operating system and looking at text analysis. If you look at the botlist application, it is more than just a URL aggregation service; there are internal services that don't get a lot of attention. The content analysis is one part of that.

So over time, I hope to look at text analysis utilities including some simple natural language parsing; noun/verb parsing. From there, who knows.

Recent Resources

Anagram Trees

Friday, December 21, 2007

New site,

If anyone on the planet was following the botprojects, I have moved them to a new host. Basically, same development articles and projects:

Moved to the new host botnode (be warned, some of the project did not mirror correctly).

Tuesday, November 27, 2007

Web requests with the Haskell HTTP library


Web development work can exist at the server level but it can also exist at the client level. You may need to build a simple HTTP load test framework or test if a particular web application or page is available. It is also possible that you need to upload files. I have built a couple of simple HTTP frameworks in Java and Python but this be a first attempt at Haskell based framework. Actually, in this small example; there isn't much of a framework but just an example on how to use the most recent HTTP library update.

Install the HTTP library

It seems that GHC Haskell release 6.8 encourages that libraries exist outside of the base Haskell build. For example, the parsec parser library requires that you download parsec from or other location or extract the source from darcs. Basically, development will continue on haskell libraries outside of the typical GHC development. With that being said, the same holds true for the HTTP library. You can pull the source from darcs or at the time of this blog entry, the latest HTTP library is HTTP-3001.0.2. I downloaded and did a Setup.hs configure/build/install against GHC version 6.8.

If you attempted to compile haskell source with out installing this library, you will get a package not found error.

ghc --make -package HTTP ManClient.hs

What does and do and how

The goal of this simple application is to post data or actually could be used to post to any website. Also, if you simply replace the POST string type in the code to GET, you can use this code to read content from a website and print the web page to the console.
Get Function

get :: URI -> IO String
get uri =
eresp <- simpleHTTPProxy (manRequest uri)
resp <- handleErr (err . show) eresp
case rspCode resp of
(2,0,0) -> return (rspBody resp)
_ -> err (httpError resp)
showRspCode (a,b,c) = map intToDigit [a,b,c]
httpError resp =
showRspCode (rspCode resp) ++ " " ++ rspReason resp

Build the Request Type

manRequest :: URI -> Request
manRequest uri = Request { rqURI = uri,
rqMethod = POST,
rqHeaders = [
Header HdrContentLength
(show (length forumRequestBody)),
Header HdrUserAgent userAgentMimicIE
rqBody = forumRequestBody }

Download Source

Sunday, November 25, 2007

Blog Spam: Cat programming language

This is my first blog spam post but I hope to post more in the future. Basically, blog spam is a post that does not have any real content and is generally used to promote the blog. In my case, I am not promoting my blog but I just thought this post on the Cat programming language is interesting and I didn't really feel like trying to come up with some witty entry so instead I will just copy the project description and resource links:

"Cat is a functional stack-based programming language inspired by the Joy programming language. The primary differences is that Cat provides a static type system with type inferencing (like ML or Haskell), and a term rewriting macro language extension language called MetaCat."

What I also thought was interesting was that Cat is embeddable.

I hope to make OctaneLang embeddable as well.

Wednesday, November 21, 2007

Science behind botlist

I haven't done a lot of work on botlist recently. I have been captivated by other projects. But I have a couple of doable features that I want to implement.

First I need to develop the push-pull system a little bit further. This allows for botlist to be updated remotely. Right now, it is working fine but I want to ensure data integrity for when the client is communicating with the server. Basically, when the client sends data uploads to the server, I want to ensure that the server has all the right data. It will probably be a simple MD5 scheme to validate a binary upload or something similar. As of right now, the push pull system just ignores invalid records when they are encountered.

Recommendation System

Botlist is a really simple system, right now. New links are submmitted by users or by the remote bots and added to the table. I am currently working on a system for the main page to be filled with popular links and actual content. Recently I picked up a USA today newspaper and amazed at the layout. Who decides and under what conditions articles should be placed at the front. How much text is too much, too little, what is captivating to the reader. It would be nice mimic such functionality. If you have visited the Drudge Report, it would be similar to how that works (minus Drudge manually updating his popular links).

Sunday, November 18, 2007

Additional Resources (link blog entry: haskell and parsing links)

My old take on a blog was to write useful entries. That didn't go so well, I mean I didn't really get that many readers. So this time around, I am just going to post whatever I feel like posting. A free for all of sorts. In this entry, here are some useful haskell and other functional programming resources and blogs. Blogs and articles that I have been reading over the last couple of days:


Wednesday, November 14, 2007

More practical Scala, searchable help document system

I go into more detail on the google code site, but here is a tool for creating searchable help documents:

"This is a small utility for indexing developer help documents with Lucene. And because some botlist documents have already been indexed, you can use it to search some of those example docs."

Tuesday, November 13, 2007

Practical Scala; Walking a tree directory

One of my requirements for botlist is to have a searchable help system. E.g. instead of man pages or Java API. I want to be able to add files to a directory. Index the files in the directory and then have the data as searchable. All of this through a command line interface. I started some initial code and used the following Scala idioms:

First Version, use of File Class:

class DocWalkFile(file: File) {
def children = new Iterable[File] {
def elements =
if (file.isDirectory) file.listFiles.elements else Iterator.empty;
def andTree : Iterable[File] = (
Seq.single(file) ++ children.flatMap(child => new DocWalkFile(child).andTree))
def listDocuments(dir: File): List[File] =
(new DocWalkFile(dir)).andTree.toList filter (f => (f.getName.endsWith(".java") || f.getName.endsWith(".txt")))

Second Version:


object DocWalkFile {
def andTree(dir: File): List[File] = {
val fileList = dir.listFiles.toList
(fileList filter(f => f.isFile && f.getName.endsWith(".txt"))) :::
(fileList filter(f => f.isDirectory) flatMap (f => andTree(f) ))
def main(args: Array[String]): Unit = {
if (args length == 0)
println("usage: DocWalkFile [dir]")
else {
println("using dir " + args.apply(0));
File(args.apply(0))).foreach(f => println(">> " + f))


Sunday, November 11, 2007

Short primer, importing a SVN repository into a GIT one

I wanted to convert parts of the Botlist project to GIT. Basically, I did just that. I saved the history from the Subversion repository and was able to import that into a new GIT repository. My entry will discuss the steps that I took to make that happen, also I work with several different remote machines so I hacked together a startup script for git-daemon.

Get GIT and install

I am working with an Ubuntu Dapper machine (yes, it is an older distro) and I didn't want to go through the hassle of using a very out of date version of git, so we are going to download the most recent git from

tar -xvf git-

Pre configure and Installation

Actually, before running configure on the git source; you may need to get two

On Ubuntu, I did the following:
  • sudo apt-cache search libsvn-core-perl
  • sudo apt-get install libsvn-core-perl
  • sudo apt-get install libcurl3-dev
In order for the git-svn to work, you will need the libsvn perl libraries. For working with http operations, you will need libcurl.

Run ./configure

At this point, you can start to build the git source; type ./configure at the command prompt and the subsequent make/install commands. Basically, standard steps for compiling and installing a typical linux source package.
  • ./configure
  • make
  • sudo make install
Git is installed, now get the subversion project (history)

Assuming git was built properly, you should be able to import a subversion
project. I suggest creating a directory and then have git create the .git repository information in that particular folder.

  • sudo mkdir -p /usr/local/var/gitscm/botlist.git
  • cd /usr/local/var/gitscm/botlist.git
  • sudo git-svn clone
At this point, you will see verbose output of git creating the botlist repository.
That is all that is needed to create a repository from subversion, notice that the svn (.svn) working directory folder is not included in your git project.

Running the git-daemon at machine startup

Unlike other linux daemons, setting up git-daemon is pretty simple. At least for running the git daemon server under the git protocol. Basically, git-daemon is a server for hosting git repositories and this particular server defaults to running on port 9418. GIT also supports hosting repositories through HTTP.

Run whereis git-daemon to find out where the executable is located. It is up to you how to pass the git-daemon arguments, I used a simple wrapper bash script and launched git from there.

/usr/local/bin/git-daemon --reuseaddr --verbose --base-path=${BASE_PATH} --export-all -- ${BASE_PATH}

[End of Script]
Change the base-path path according to where you want to store your git repositories. In the script above, gitscm is just a regular directory. The subdirectories (for example, botlist) are actual git repositories (that contain the .git directory). Create a symbolic link in your init.d directory, something along the lines of this:

ln -s /usr/local/bin/git-daemon2 git-daemon2

With ubuntu, you can run update-rc.d to ensure that the git-daemon2 script gets launched at startup:

  • sudo update-rc.d git-daemon2 defaults

Run and Test

Now, you can start the git-daemon2 script
  • git-daemon2 &
  • git ls-remote git://
  • To get the project, cd to some directory
  • git clone git://

Tuesday, November 6, 2007

Now Playing: Brandenburg Concerto

In my effort to find the perfect development music, I stumbled upon these concertos by Bach, in particular "Brandenburg Concerto No. 2 in F - 1 Allegro"

They are widely regarded as among the finest musical compositions of the Baroque era.

Friday, November 2, 2007

13949712720901ForOSX Vote! I am actually helping Java

I am not really a big Mac user, but I use it every once in a while. And I still develop in Java, so I am helping the Java cause by posting this vote to get Java6 OSX.

Personally, I feel that Apple has a right to leave out whatever software they choose. Plus, they already have Java5 working with their operating system so it is not like they are totally ignoring the Java community. But, if enough momentum is created for adding the new Java; would it hurt for them to listen to some of their users.

So, I am doing as the blog instructed and here is my vote:

Thursday, November 1, 2007

Google, we are watiing?? on opensocial

Google, what is the deal? Where is opensocial. I am actually kind of excited about this technology. I heard reports that library was supposed to be released on Thurs. It is 6:42PM (PST) , you have a couple more hours left. Don't be evil by lying to us.

I have a new perspective, Firefox and Flash bugs

After a little bit of research I eventually ended up on at the site. It seems like there are various issues with flash and FF. So hopefully, I will do some work in trying to resolve my problems as opposed to just ranting.

Wednesday, October 31, 2007

Factor screencast, take 2, basic Factor usage with the tty listener

(Image of the Factor UI, edited by Elie)

(Images taken from Elie's blog at he created them, I didn't)

The following screen cast was developed to show basic factor usage including analysis of the data stack, how one would go about looking up help on words, etc.

Also, working with the stack takes a little getting used to, that is why I went it over in the screencast. Elie has some great images that I want to show here of some basic operations. I go over a couple of them in the screencast.

"Let's take our rot example from above and practice it with the help of the illustration. Write 1 2 3 4 in your input area and hit Enter (the Return key) on your keyboard. You should see the start stack displayed in your stack area. Notice the position of the top and bottom of the stack in your stack display area. Now write "rot" (without the quotation marks) in your input area and hit Enter. You should see the rot stack displayed as above because the "rot" word caused the 3rd stack item to be moved to the top while the 1st and 2nd stack item were pushed down." -- quote from Elie's blog on stack manipulation

In the second video (part two), I demonstrate the new vocabulary modules for structuring your factor application and a short demo on what your code would look like in emacs.

Screencast (1)



This screen cast was created gtk-recordMyDesktop. And then encoded with mencoder (ffmpeg could also be used).

  • bbrown@houston:~/tmp/capture$ mencoder factorcaptureA.ogg.3 -o f4_part2.avi -ovc lavc -ss 09:58
  • bbrown@houston:~/tmp/capture$ ffmpeg -i factorcaptureA.ogg.3 -t 00:09:58 factorscreenlin1.avi

Monday, October 29, 2007

How to post to blogger through gdata API (example in Scala Language)

In some earlier posts, I was ranting about the inadequacies of the blogger wysiwyg interface.
Actually, I have ranted a lot about this system in the last couple of days.
So, the next logical step was to create a simple blog client that could connect with the blogger/gdata API.
It actually wasn't that complex. Envision an API for posting a blog entry to blogger, and
the operations shall include: Authenticating to the service, provide a post URL to connect to,
provide the actual content and title to post. That is basically all that is required to use
the API. The documentation does a much better job of explaining the overall functionality
available through the service. And it is freely available and fairly easy to use. I created
the source below in a couple of hours. When using the API, just make sure to secure
your google username and password as it is probably use to access all of the google services.

Most of the scala source can be found below.

class ContentReader(filename: String) {
def readFile(): (String, String) = {
val file = Source.fromFile(filename)
var counted = file.getLines.counted
val fileData = new StringBuilder()
var title = ""
counted.foreach { (line: String) =>
if (counted.count == 0) {
title = line.substring(6).trim()
} else {
(title, fileData.toString())
} // End of Class //

def createPost(service: GoogleService, blogid: String, title: String, content: String,
authorName: String, userName: String): Unit = {

// Create the entry to insert
val myEntry = new Entry()
myEntry.setTitle(new PlainTextConstruct(title))
myEntry.setContent(new PlainTextConstruct(content))
val author = new Person(authorName, null, userName)
// Ask the service to insert the new entry
val postUrl = new URL("" + blogid + "/posts/default")
val res = service.insert(postUrl, myEntry)
Console.println("INFO: create post");
def publishEntry(googleUsername: String, googlePwd: String): GoogleService = {
val myService = new GoogleService("blogger", applicationClientId)
myService.setUserCredentials(googleUsername, googlePwd)
return myService

Sunday, October 28, 2007

Firefox (2 and possibly 3) are unusable on Linux

This will be a short entry but Firefox on Linux is not doing the Linux community any favors. Firefox is really buggy software. At first I thought maybe I was doing something wrong like visiting websites (you know, typical web browsing tasks) but after yet another memory upgrade and yet another Ubuntu release, I am convinced there is something seriously wrong with the Firefox/Mozilla engine on the linux platform. Maybe the FF community grew too fast and the FF group were unable to adequately handle the demands of the modern web user.

There are a couple of problems that plaque my internet use. Slow startup (at least with FF2). Heavy javascript oriented pages wreak havoc on FF and the operating system.

Don't you find it a little odd that Ubuntu just recently upgraded to Firefox only 2 weeks (or so) after the Gutsy (Ubuntu 7.10) release. I bet it was yet another Firefox memory fix or something along those lines. The worst part, as far as I can tell it works fine on the win32 platforms. Never have a problem with it. But once I start using FF on a Linux platform, I start praying to the gods I can do basic tasks like check my email or visit one of the three sites I frequently visit. It is really tragic.

My Solutions

I am trying my best to move away from FF, at least FF2. I am currently writing this blog entry under Firefox Granparadiso (FF3). But it is kind of difficult when you have been using some variation of Firefox for so long. Firefox on windows. Firefox on Redhat. Also, FF shares so many properties with Internet Explorer. I use the latest Opera on occassion and so far it seems to be very stable.

Plugins: Some articles on the web mention that Firefox doesn't work well with various plugins. I only really use Firebug and the non-commercial Flash plugin.

Tuesday, October 23, 2007

Project Diary Update: JVM Notebook

I have made the initial import of jvm language notebook source. Basically just a collection of source related to programming languages that run on the jvm. People are always curious about how one should get started working with for example Jython. Hopefully these notebook projects will show one how to do so. Here is a blurb from the project:

"The Java Virtual Machine ( Sun's JVM is called HotSpot? ) is a java bytecode intepreter which is fast, portable and secure. Jython, JRuby, Scala, ABCL (Common Lisp) are popular language implementations that run on the JVM that allow for the syntatic sugar of their particular languages. This project contains multiple subprojects and code demos related to those jvm language implementations. "

Monday, October 22, 2007

Random Ramblings: Haskell OpenGL on Win32 doesn't work at all?

Random Ramblings

I can't tell if it is a failure on the part of the Haskell OpenGL testing team (open source developer volunteers) or on my part for not doing enough research? Whatever the case may be, there seem to be a lot of issues with writing Haskell OpenGL code on the Win32 platform. If you read the mailing list, you will get 100 steps on how to either compile with FreeGLUT or get the opengl haskell source from darcs or both. With that being said, my issue is that I will compile some code and then attempt to launch the application and you can tell that the window launches but no 3D graphics and the window does not stay open.

Typically in a win32 environment. The runtime OpenGL DLL is resident on the system and the developer will only have to compile against a particular set of libraries. The Glut DLL is normally not installed but hardware vendors typically are supporting it now. I don't know if Haskell uses a FFI interface to connect to those DLLs or is it compiled against FreeGLUT. If your code is compiled against FreeGLUT that is normally more difficult to address because those libraries are needed at compile time.

Hopefully, in the near future I will write a wiki entry on how to really get OpenGL working on the win32 platform.

Friday, October 19, 2007

Why contractual oriented programming is the only way to program in java

Java, by and large is a mess. The applications and the need for java systems is not a mess. At least for the time being there is still going to be a need for java applications and developers. With that being said, there are a couple of steps that can be taken to ensure a robust system with a limited number of bugs if you abide by a couple of rules and don't get caught in some java development traps. I don't go over the most obvious ones but I have gotten interested (again) into Contract oriented programming. Contract oriented programming, design by contract; ensures a true object oriented model, allows for better testing. Here is a quote from an Eiffel document, "In human affairs, contracts are written between two parties when one of them (the supplier) performs some task for the other (the client). Each party expects some benefits from the contract, and accepts some obligations in return". Basically, with design by contract, you limit the number of side-effects that can occurr when an operation is invoked. When call a method, passing a message, you want that result to return the value you would expect. If the method returns a String, you want it to return a string. Not a generic Object or Numeric. If you have a List of elements, and there are 5 elements in that list and you expect 5 elements returned. You want a list with 5 elements.

Tony Morris, a former(?) Java developer is very fluent in the ways of Design by Contract; he created the ContractualJ framework and had this to say:

"ContractualJ is an open source project that is aimed at providing a robust API specification for the Java programming language. The ContractualJ API Specification is independent of any given context, except that it either replaces an existing core J2SE API Specification that is poorly designed, or adds a feature that does not exist in the core API. ContractualJ serves as an example of writing software using Contractual Oriented Programming, while also highlighting the flaws of the dependent tools (e.g. Java) and exemplifying the optimal workaround to the existence of these flaws. "

Here are some more quotes from Tony and as of now I don't have much to say on the subject.

"1) Interfaces define a contract for *how a class may be accessed*, but don't provide ANY information about what the class does, or how it does it.

2) Abstract classes allow (among other things) *commonly implemented processes to be encapsulated"

* All classes are declared final. Concrete behaviour inheritance is not permitted.

* All local variables and fields are declared final, unless otherwise required not to be by the context. A local variable or field that is assigned once must be declared final.


Tuesday, October 16, 2007

Happiest day of my life, playing FFT on Linux

When several magazines call it the best game ever, there must be something to that. I knew it was the best game 10 minutes after playing it. Also, people always ask me why my screen name on freenode is ramza; where there you go. Ramza is the main character in FFT.

Anyway, I am playing through the psx emulator. Awesome. Thanks linux.

Tuesday, October 9, 2007

Last Java Reader Writer Utility you will need (especially for Log Analysis)

It is actually kind of funny, it is amazingly hard to write Java classes/utilities that you can really use over and over again. The requirements of a particular project may change to where code changes to your base library are always required. Your initial library may be too slow or to cumbersome to work with. Whatever the case may be, code-reuse in the Java world is hit or miss in my opinion. Sure it happens, libraries like the Jakarta commons provide useful libraries for common tasks. But, I see way more reuse in functional programming libraries; for example, there are some common data structure libraries that have been in use for a decade. With that being said, I found this first cut at a simple read writer utility reusable.

The goal is simple; given a input file, read the file and then rewrite the output based on that file. I am using this particular code for log file analysis.

Python pseudo code:
f = open(filename)
fw = open(filename, 'w')
data =
for line in data:

The java version is just that, but I wanted to do the iteration around reading a line through callbacks (anonymous inner subclasses). I designed the following loadFile routine to use an implementation of some ReaderWriter class because you certainly want to control how you iterate through each line of the document and only to focus on that particular task as opposed to the inner details of how the file gets opened or closed. For example:

FileUtil.loadFile(filename, (new HtmlFileUtilReaderWriter()
public void read(BufferedReader bufInput, List resultList) :

while ((feed = bufInput.readLine()) != null

That is basically it, I know it is simple but it is pretty useful idiom. You can download the full source from my googlecode repository. In the future, I hope to create a similar set of libraries in Haskell and compare and contrast between the two languages.


Sunday, October 7, 2007

Imperative Haskell OpenGL development and demo

I have finally created the camera component for the Octane Mech game. It is pretty basic, but is a basis for the camera movement. The camera, as you would expect, is a n important aspect of a 3D game.

You can read more about the source and download the demo by going to the project wiki. I would have posted it on but the code formatting here is terrible so I will only post to the wiki now and in the future.

Monday, October 1, 2007

Haskell Cookbook(Notebook) Released on Google Code

It is always difficult to save a repository of code snippets that you consider useful. Sure, you could keep them in a blog or post them on some random wiki. These both work, but in my case, I will be hosting a Haskell cookbook including useful Haskell full source and snippets. It may include the "wrong" way to do things in Haskell and the "right" way but I will let you decide. And all examples will compile with a modern Haskell (GHC is the target system).

Monday, September 24, 2007

Octane Mech, OpenGL Haskell based mech game; early code and some haskell notes

I am in the initial design and some development of OctaneMech; as the title implies is a OpenGL Haskell based Mech (bot, tank mobile) game.

An early goal is to recreate/port glAnts (mech game) to haskell

On Haskell

Haskell is a pure functional programming language where your primary view of your software is through the use of functions. In java or other objected oriented/imperative languages, you are looking at the lowest level components; in Haskell, you are able to concentrate on the operation a particular function is used for without focusing on the low-level details (step-by-step sequences) of the function.

I won't now or probably in the future detail the power you are given with Haskell and I leave that up to you the reader. I will focus on how I am using Haskell to build my project. And this first entry will contain some simple Haskell snippets.


Like other applications, a Haskell application begins with entry point definition main function. For example, the following snippet below is all that is included in my Main module (included in a text file called OctaneMech.hs)

module Main where

import MechGLScreen
main = do
putStrLn "running OctaneMech"

It almost resembles a Hello World application. We import the needed library "MechGLScreen" and then write our main definition. putStrLn was used to print the startup message. mechLaunchGLWindow, is going to get a little bit more complicated. It includes the OpenGL initializations and sets the display callback.

Launch OpenGL

This function also may resemble more the sequential, call by call nature of an imperative program. If you are used to OpenGL development, most of the calls are window and GL initialization. It may get a little bit more interesting with the "SimplePlayer" data type which is composed of a x and y position.

= do
initialDisplayMode $= [DoubleBuffered]
initialWindowSize $= Size mechScreenWidth mechScreenHeight
createWindow mechWindowTitle

curMech <- newIORef (SimplePlayer {
shape = MechBoxShape,
posX = 0,
posY = terrainYSize-ssize,
angle = 0})
-- Get the current and rotation matrices
curMatrix <- get ((matrix $ Just $ Modelview 0)::StateVar(GLmatrix GLdouble))
rotationMatrix <- newIORef curMatrix
-- Keep track of camera movement
cameraRotPosition <- newIORef (0::GLint, 0)

-- Set the OpenGL callbacks
displayCallback $= displayGameLoop curMech rotationMatrix

-- Set the keyboard callback for handling actions
keyboardMouseCallback $= Just (mechKeyboardHandler curMech)

idleCallback $= Just idle

This particular function initializes the GL window and other game initializations. Now, open the MechDisplay.hs source. This function contains operations for swapping the GL double buffer and rendering the plain (Quad) object and player character (a simple cube).

displayGameLoop mechObjRef rotationMatrix = do
clear [ColorBuffer]
curMech <- get mechObjRef
prevMatrix <- get rotationMatrix
multMatrix prevMatrix
curMatrix <- get ((matrix $ Just $ Modelview 0)::StateVar(GLmatrix GLdouble))
scale 0.06 0.06 (0.06::GLfloat)
multMatrix curMatrix
-- Render the terrain, including the flat plain
-- Render the Mechs
renderBasicMech curMech
-- OpenGL, swap buffers

And I know it is short entry but I will actually continue in my next couple of posts on this topic. See all of the source code for this simple example below. Once you have it compiled, you should only see a 640 by 480 window open up and then you are able to use the keyboard (arrow keys) to move the "box" character around.

Source for Example

Download Haskell Example

Follow the Project at Googlecode:

Note: google code is horrible about the code formatting, so you will have to browse the included source to view the correct indentation

Tuesday, September 18, 2007

Botlist released on

Botlist has been released on There really isn't much to say. The web application has been released in its raw form. There are some issues I mentioned on the wiki page with the SQL database create scripts and some "url" path issues. But I will fix these real soon. Stay tuned for updates. Also, I hope to send over the opml feeds so that you can import into your RSS readers.

Here is the blurb from the googlecode page.

Botlist is a social bookmarking web application that contains a news aggregating/news/article submission site. There is also an ads listing section so that users can post personal/ad profiles. The application itself is created with the following libraries; JRuby and J2EE's Spring framework as a middleware piece, Hibernate for object relational mapping (ORM). It is designed to run with Tomcat but should work with other J2EE servers. Search functionality uses the Lucene API.

Other Features

News aggregation (some links will be included); over hundred and fifty thousands links thus far.

You can reply to comments, up or down vote the news articles, post new article links similar to other social bookmarking sites.

- Comma delimited output for easy, text based access (for developers)

- Numerous documentation on architecture

- Discussion Forums section

- User profiles

- Ad/Profile listing section, listed by city

- Sort search by relevancy, submit date

- Can also operate as a simple bug tracking system

Visit Botlist Home

View the Source

Thursday, September 13, 2007

Why Java still sucks but there are some things done right for web development (to me anyway), in 10 minutes


Writing this will get me banned from the development community for life. Actually, I don't know if I really belong to any development community so I guess I can sleep soundly at night. Basically, unless you are living under a rock, the development world has made great strides in terms of language development. There are at least a dozen popular/mainstream programming languages that are used to perform various computing tasks. Some are open sourced, some are closed. Some are geared towards a specific niche in computing. Some are more general purpose languages. Java, C, C++, C#, Haskell, Common Lisp, Python, Ruby, Erlang Assembly/Machine Language (x86 for example) are probably some you have heard of.

Lets get to the point (this is really about Java); Java and some other imperative languages that are defined by a sequence of steps to define a particular task (which can be cumbersome) are not as productive as declarative programming styles where the step-by-step inner workings are hidden and you only are to focus on the particular goal of the operation based on the given inputs. For example, Haskell is a purely functional programming language that adheres to the declarative programming paradigm. There are probably various studies and analysis comparing lines of code, number of bugs, productivity and other metrics comparing different programming paradigms; the java/imperative/object-oriented, procedual approach seems to lose out. With that being said, Sun (creators of java) have created a complete system that may not include the best language but does include a set of libraries and components that can aid in a variety of different computing tasks. And this may not be the most important statistic, but millions of developers and thousands of companies probably rely on the java platform and it is too costly to which to something else. Me, I work with and write web software for a Financial Services company (sort of online banking); security is important, completing a task on time is important, accuracy, stability, reliability are important. Does a Java/J2EE based system gurantee that? Not 100% of the time? But, it does provide for those things a majority of the time. Would a system based on Rails, Django, Haskell Server Pages, ErlyWeb work? Maybe. My purpose in writing this is to say that there are some things that Sun and Java, J2EE have done right. In the future, there are some things that an emerging language may hijack from the Java platform to sway those developers. From the language developers I have read about and great hackers out there, they don't really care about how many users are using their particular tool. It is really more for the other developers (eg, java developers) who are fed up with things like NullPointerExceptions, Out of Memory Errors, 40 lines to open/read/write a file; these developers are dying to move away from the java platform, but a lack of a SSL library or lack of a database connectivity api held them back from switching to something else.

So, what has Java/J2EE done right?

There are a couple of things surrounding Java that I just find "productive", I have certainly missed a few and you certainly may disagree but by and large I find these things useful. And I know that some of these libraries don't begin and end with Java and are common in other development environments.

Jar files, War files

This is really a small thing. But I guess because of the nature of loading byte code compiled java classes, Sun wanted to create something similar to an executable. They came up with the jar (java archive) file which is basically just an zipped archive of java classes. If you want to get more creative, you can "Secure" your jar files and/or provide meta information like the target jvm and what-not. Personally, I think this is useful just like an binary executable is useful. All of the libraries are typically in one place and normally "read-only". Applications based on interpreted languages like Ruby, which are script driven run of a library of separate scripts as opposed to one archived file. This may or may not be a good thing. Sure, python has "egg", but I think the python developers chose the expanded directories. It is great to be able to edit a script or patch an application just by updating one single file but it has been my experience that "users" tinker with their applications (edit the script files) too often for my comfort, jeopardizing the integrity of the application. Having one file, plug and play library or set of libraries like the jar and war file limits what the developer has to worry about. In the case of the war file, you also can update your entire application remotely by uploading it through an application server web interfaces.

The servlet api

The core servlet api, especially the HttpServlet class is pretty simple and does what you would expect. Given a GET/POST/HEAD request, process the incoming request parameters and then modify the response. Pretty basic.

For example, a doGet handler might look like the following (python pseudo code)

doGet(request, response):
session = request.getSession();
parm = request.getParameter("action");
session.setAttribute("prev.action", parm);
out = response.getWriter();
cookie = new Cookie();
cookie.setAttribute("", "true");


A corrollary, along the lines of the Servlet class is the Java Server Page (JSP), the J2EE HTML/XML view technology. Think of JSPs as a HTML templating system that parses your java model classes and displays the values to the user surrounded by the rendered HTML or XML. JSP idioms can get ugly, especially when you want to iterate over a collection of beans in a List and then print the values out or perform other "if/choose" operations.

[c:forEach items="${command.mediaList}" var="curmedia" varStatus="status"]
[c:cout value="${curmedia}"]

The default JSP (eg JSP 2.0) system has all but been replaced by taglib driven MVC frameworks like JSF and Struts. The advantage of these newer technologies is that the difficult web tasks like form validation, model driven development, error message handling are handled by the framework.


Filters are pretty useful especially in a high security application. Basically, you can apply a filter in front of a Servlet request and do post processing before the response goes out to the user. For example, you may want to filter all newline characters (protects against HTTP poisoning attacks) from a request.

doFilter(request, response, chain):
// process incoming input from request and modify output.

I kind of threw a bunch of common api calls in there because those are pretty common. Handling cookies, sessions, the request parameters are easy to get at. You still are limited by the procedural style of Java development, call by call but at least the api is pretty apparent.

Web Archive Layout

The web layout for a Java web application is not entirely intuitive or behaviour driven like the MVC framework Rails, but it is consistent and it does make some sense in a java context.

[top level of the web application, called MY_WEB_APP]
[includes view oriented files, jsps, html, etc]
[application oriented, byte code classes, libraries]
[web configurations, like web.xml]
[java byte code classes, packages]
[java library files, jars, etc]

Consistent Database Connectivity API.

Java does have a general purpose connectivity library that provides an interface to database specific drivers. Some features go unused and some have security holes, but it is easy to connect to your database with a couple of calls. On the other side, some language implementations provide driver specific libraries, ODBC oriented libraries. These are ok and they normally provide interfaces for returning rows, meta information, but with JDBC, it is nice to be able to connect an Oracle or MySQL with the same code and only changing the url connect strings. I am kind of oversimplifying what is involved in database development in java; ignoring object relation mapping, connection pooling but you do have jdbc as a base to start with.

XML Libraries


My knowledge of the java security framework is limited, but I know it is there and it works. I do know that other languages don't have or their security intefaces aren't reliable. What do I want from a security library? Well, the ability to do ssl/https socket connectivity is a start. APIs for the popular encryption algorithms are another plus.

Ant's Build.xml (and maybe Maven)

Ant and their build.xml in the java world is akin to the gnu make utility. It is XML based and may not be the best descriptive language for builds but it does the job of compiling java classes. It does allow for full builds of your application in one call at the command-line. Also can be used for daily builds (see cruise-control) without an over-complicated make/bash script. Outside of java build it provides an inteface for pretty much anything you could think of. FTP, SFTP, JUNIT calls, Copy, Mkdir (Maven, the other java build tool is supposed to be a better "ant", that is what I heard anyway)


Tomcat is a third party web servlet container developed by the Apache software group. It is simple, reliable and does its job; serving up jsp/servlet based applications. It may or may not be what you want in a production environment and will probably require some performance tuning outside of the default configuration.

The others, the other libraries and Applications

Java has certainly matured over the last 10-12 years. With that maturity comes a proliferation of a numebr of libraries for common tasks. Popular librares include:

SpringMVC/Struts (Middleware and MVC framework), Hibernate/iBatis (Object Relational Mapping), Lucene (Full Text Search), Log4j (logging framework), GWT (Google Webtoolkit for Ajax Development), Ant (build tool) JUnit (unit testing), iText (PDFs), dom4j/jdom (XML Processing) Jboss, WebLogic, etc, etc.

JVM Languages

Earlier, I didn't mention an overwhelming fondness for the Java language. Jython, JRuby, Scala, ABCL (Common Lisp) implementations allow the syntatic sugar of their according languages on top of the Java virtual machine. In most cases, you have access to any of the Java API's that are available.

Eclipse IDE (with WTP)

this resource hog wild java/web development environment has a little bit of everything; project management, java/package explorers, profiling tools, java debugging tools, ant tools, junit unit testing interface, custom views/perspectives, plugin support (for example interfaces to SVN, GIT, etc). Some developers despise it and chose something lighter like JEdit, Vim, or even IntelliJ. It does take some getting used to.

6. Paul Graham on Great Hackers.

Wednesday, September 12, 2007

Hello Welcome

Hello, my name is Berlin Brown. I am a software developer that doesn't really have one particular niche or favorite programming language. I like them all and hate them a little bit at the same time.

I love:

But, you may also see me on:

I like creating various projects that frankly, users may not like. But, I love creating them anyway. My most recent project is (botlist, social bookmarking site):

My next project is a web server/application server/database server in haskell. And with that, various snippets of haskell development.