Sunday, August 09, 2009
Social Networking
My Partner, has expressed similer annoyance with Facebook, where she has several groups of frends from different periods of her life. Very often something she wants to post is particularly relevant to one group and not the others. However having one networking sites all will see it, leaving some to scratch their heads and wonder what she is going on about.
Recently I have joined site dedicated to a particular subject of interest. What I found inside was an entire social networking site (blog included). I've been thinking about this for a while and I think it makes sense. The Facebook Idea of one network site to rule them all is a bad one. Why, because we all have segments to our lives. Places where we don't want to expose to everyone we know for one reason or another.
Interestingly this is one place where I don't even want interoperability. And their are certainly things I have posted in special interest sites that I don't want on my Facebook Page at the present moment.
But why not just use the entire internet as your social networking site? well that comes down to the problem of finding other people with similar interests. Take this blog. Its on a general blogging site, and all things considered I don't know that anyone actually reads it. Often I feel its I get more of an audience by posting my thoughts to Facebook, then to recording them here. Ditto for special interest sites where my posts are guaranteed to be on topic and delivered to an audience who will be interested in some of what I have to say on the matter at hand.
So it is natural that their will be an array of special interest social networking sites. Each with a target demographic of sorts, and many fostering particular special interests, whatever they may be.
Thursday, April 23, 2009
An RPG in JavaScript
I've spent my train time for the last two weeks working on an wrting an JavaScript RPG (Thats Role Playing Game) system. The end result is intended to be a cross between the system used by Kingdom of Loathing and a traditional text adventure.
So far I've been boged down with a lot of low level mechanics, and ensuring that all my objects can round trip between JavaScript and XML. E4X makes this far less painful then it would otherwise be. The plan is to have a JavaScript game engine that executes XML based adventure files. Why XML? because JavaScript can allready parse it and it will be less cryptic then JSON. I'm musing that an adventure creator would also be nice, and would give me an excuse to play with XUL.
E4X means that at the moment my engine will only run in Firefox. But then this is a hobby project and I have better things to do then deal with the Pandora's Box of cross browser issues. Especially as Firefox 3 already implements so many goodies from HTML5 and ECMAScript 5th Edition.
Though I can't wait for the next beta of Firefox 3.5 and the @font-face CSS property. That and border images Should really come in handy when I get around to putting an interface page together.
Monday, March 09, 2009
JSEXT
For one thing it provides an incredible amount of auto loading magic, which sees it find not only functions in other javascript files but also in C header files. Any C library will effectively be usable form javascript. That got me thinking Cairo is a C library
Getting the helloworld example from the Cairo FAQ going was reletivly simple. But JSEXT provides something better, an OO wrapper for the Cairo library. Granted I did have to check the source out from SVN and compile it to get them, and then sort out a couple of minor bugs in the wrapper.
Anyway the following code is a slight modification of the basic example. This script is intended to be accessed from a web browser as title.jsx?"Insert your text here" and yes it works perfectly fine if you set the src attribute of an img tag.
function(str){
this.responseHeaders.contentType = "image/png";
var surf = new JSEXT1.Cairo.Surface.image("ARGB32", 800, 80);
var cr = surf.context();
with(cr){
selectFontFace("serif", "normal", "bold");
fontSize = 32;
source = [0, 0, 1];
moveTo(10, 50);
showText(str);
}
surf.writeToPNG(stdout);
}
Yes this is a file containing one anonymous function. This is one of the more curious features of JSEXT. You can give it a directory tree and it will walk it and build a set of Javascript objects based on what it finds. This does requie one method per file, which is somewhat unusual. But seems to work alright in practice. It is also uses lazy loading so only the methods you actually use get loaded into the runtime.
Thursday, February 26, 2009
Javascript Solution
The little JavaScript solution was suprisingly more enjoyable. Now I don't do much fornt end work so I had to look up essentially everything, and had one approach not work, for no obvious reason that I could see. But on the whole it was more enjoyable. I suspect that the immediate visible feedback provided by making a change, reloading the page and seeing what would happen, had a lot to do with it.
I'm think I can see more web design work in my near future. And more javascript. wxJavascript or GLUEScript as it is to be know from the next version onwards is worth a look. Especially as I like the wxWidget toolkit. Don't know if I'll be sufficently motivated to build it myself though.
Tuesday, February 10, 2009
Divine Retribution
Honestly their should be an ethical exam before anyone is allowed into a position of religious authority. This is the 21st century people. The lunacy of it is, as always, that the people hurt the most by the bushfire played no direct part in writing the laws Mr Nalliah is critical of.
Mr Nalliah, I put it to you that if you dream of fire and brimstone it might be a premonition of your own fate. I trust, and hope, that your congregation does not hold with your absurd statements and will seek to remove you from office as expediently as possible. And let me finish by saying shut up you self deluded religious zealot.
It turns out that Mr Nalliah is no stranger to controversy. And has previously been found guilty of religious vilification. He also published a brochures that listed the religious buildings of other religions (along with Casinos and Brothels) as Satan's strongholds.
This reinforces my decision at the last few elections to always list the Family First Party last. I see them as far more sinister then some overtly Christian political parties as they make some attempt to conceal their affiliation with fundamentalist Christian groups.
Wednesday, January 21, 2009
Read First. Then work out what to do
Most recently I've taken to playing the Alto recorder, this is slightly larger and lower pitched then the more common soprano records that tend to be used by school music programs. Knowing for past experience that it is quite easy to play out of tune even on woodwind I got myself a cromatic tuner, so as to give me some of the feedback that my ear doesn't quite provide.
Their are two reasons I've shifted from Saxaphone to recorder:
* I live in a unit and an Alto recorder is much softer then an Alto Saxaphone.
* getting a recorder setup at the beginning of practice, and cleaned at the end takes much less time. It's smaller and their is no reed to mess about with.
Reading part of the way through a book on Musical Scales and Temprement has really blown that theory out of the water. THe point is that my cormatic tuner is giving me methamatically precise Just Temperament. Which is essentially a set of compromises need to get keyboard instuments tuned into something usable.
Now a Record does not have fixed intonation, if it did I would never have gone down the path of getting a tuner in the first place. WHat this means is that I should be aiming to play the real intervals, not the tempered intervals (especially when playing solo).
Now the chromatic tuner wasn't a total loss, but it means how I use it will have to change. Rather than trying to get the tone exactly on the note the correct thing to do is to sharpen or flatten it based on the melodic progression.
This will however require me to get my head around what the real intervals actually are. So far I know their names but don't quite follow how they relate to the notes of the scale. How sharps and flats actually work is particularly confusing me at the moment. Though I do know that they don't really coinside so that A sharp is slightly flatter then B flat, etc.
This will take quite a lot of thinking an experimenting. I was planning to write myself some ear training programs relying on midi playback. However I may have to rethink my strategy here as I suspect MIDI uses Just Temperament. So it will be a case of learning how to control the sound hardware to generate particular pitches including overtones. And then generating the correct intervals from their.
Tuesday, December 02, 2008
64bit assembly
If you look on forums the best answer you will get is learn x86_32 assembly then look here to see how 64 bit is different. This is fine if I allready knew 32 bit assembly but I don't I'm starting from scratch. So why should I waste time learning how to do things on on 8086, or even the 80386 when I want to write programs that run in 64 bit mode.
Now I realise that there is an awful lot of common ground here but there are also important differences. There is an lot of legacy 32 bit and 16 bit ways of doing things which I don't strictly need to know when working in 64 bit mode.
so Instead of following the evolution of the chips I want to start with today's chips and learn how to adapt that to yesterdays chips if or when I need it. For anyone reading this who knows x86_64 assembly, you should write a book, or at least a good tutorial.
Monday, October 20, 2008
The tribulations of Setting up a Goldfish Tank
Chances are the staff haven't a clue, and management couldn't care less, even if they are cheaper. Before I knew this I went down to the local generic store to buy the basic materials, a tank, a filter etc. I fooled myself into thinking I'd pay less by buying basic glass tank, and compeltly failed to factor in the price of a filter and a light. Even on this score It's hard to tell if I came out ahead or behind.
At every jucture I asked if item x was suitable for a cold freshwater aquarium. Turns out the gravel I brought wasn't, it buffered the water and drove up the Ph, so much so that I couldn't make it budge from a reading of 7.5 no matter how much ph down I put in.
So I spent half a day replacing the gravel, with the stuff I got from an aquarium shop. Unlike the generic pet store these guys will not sell you a fish without testing a water sample first. When I complained about the buffering the first thing the Guy said to me was, you have white gravel don't you? And yes I did.
So I went back to the pet store and asked for a refund on the gravel, No can't do that, Not responsible. The manager says in a I've got your money and I couldn't care less tone. Half way through the conversation after telling me how all his gravel comes from the same place he admits that the ph problems occurs, but stress that its not his responsibility, as its prepackaged. He says the black gravel can be even worse. Still after all this the only thing he offers is to replace it with another bag from the same place. Then turns his back on me to go and get money out of another customer.
Needles to say I was ticked off (yes self censorship is going on here). Still I have new gravel and the ph is dropping towards where it's supposed to be, and I have learnt a lesson. Now all I have to do is find an alternate place to buy replacement pads for my filter, as I don't plan to give that particular shop any more of my money.
I have half a mind to make a complaint to fair trading, would I be wasting their time on an item which cost $16.00 though?
PS while fantails at the Pet shop were $1.50 cheaper even I could see the difference in quality. The fish I got from the Aquarium shop are shiny, with bright orange and gold scales. The ones at the Pet shop meanwhile don't look shiny at all, and have pale dull colours. If the fish weren't a different quality to begin with, clearly the petshop is doing something wrong to them.
Thursday, October 16, 2008
PicoLisp in a chroot
Unfortunately I'm on a 64 system, and pico dosn't at the moment compile under 64 bit. Now I'm told that if I install the right things and tweak the right options I can get 32 bit binaries to compile anyway. But that involves modifying the upstream source and I don't like doing that, unless I plan to submit a patch.
In this case It seemed somewhat pointless. So I though I'd try setting pico up in a chrooted environment. I came accross the following post on the matter: Installing apps in a 32-bit chroot in AMD64 Debian systems.
I followed most of step 1, with the following exceptions:
- I skipped step 1.3 (decided not to mess with my main gcc instalation.
- Installed gcc, and build-essentials into the chroot. (also locals and less which didn't get installed by default.
- Installed dchroot into my real system ( I think this is soemthing the tutorial does later).
- Compiled picolisp in the chroot enviroment and installed it to /usr/local/
- Added some scripts to my real path which would execute picolisp and psh in the chroot.
All in all it was a surprisingly easy process and at the end of it I have a fully functional picoLisp. which is accessible form anywhere. even the scripting is easy.
!#/bin/bash
dchroot --preserve-environment <> "$@"
This lets me run pico the same way weather I'm in the chroot or in the main system. And there are no gremlins. I started a picolisp server in the chroot, started firefox (I mean Iceweasel) in the main system, and everything worked, even the ondemand compilation of c from inside pico.
Partially I did this because I wanted to learn how to do it, and now that I have a 32 bit chroot I'll probably move my IceWeasel into it and install flash.
Hmm, I wonder which I'll see first, 64 bit PicoLisp or 64bit Flash? I have it on good authority that they are both in development.
Monday, October 13, 2008
Programming is not that different.
just anther form of composition.
Applying Strunk and White to programming - absolutely inspired (I wish I'd through of it first).
I have seen a few places aregue that Design Patterns, as they are commonly used, are a complete missinterpreatation of A Pattern Language by Christopher Alexander.
Just two examples of how Programming is not that different from everything else. And why Extreme Programming is a step too far.
Sunday, October 12, 2008
PIcolisp Cookbook
All of the built in functions are documented, what is missing at the moment however is the various idioms for using them in practice. Thankfully you can usually get a prompt answer on the mailing List.
I came acrose one such are the other day. I was trying to break a circular list, built by fifo, into a plain list. In Common Lisp I'd do this with set. so I tried it to no avail. In Pico (set (cdr A) NIL) actually sets the 2nd element of the lsit A to nil.
It turns out that to set the cdr portion of a cell I want a function called con. My first reaction to that was ... well that's annoying. But then I got to thinking that its not actually a bad thing. Essentially we have to setting functions which are subtly different.
set: is used for setting values, and con is used for manipulating structure. Yes things get a little confusing if you use cells to build a tree structure where both the car and cdr contain pointers to other cells. That aside I when reading code I can assume that calls to set will change values but not alter the underlyign datastructures, while calls to con will alter structure.
The more I think about it the more I like this distinction. It adds something usful to the code. In the end the only thing which tripped me up was documentation. The Picolisp docs are good as far as they go, but missing a few bits.
Alex, the maintainer of PicoLisp, seems somewhat reluctant to make the official documentation more verbose. Well we may have to agree to disagree on that one. But there has been talk of building a picoLisp wiki (powered by picoLisp). And this may go some way to adding the Cookbook style reference that appears to be needed.
Monday, July 07, 2008
Inform - first lesson learned
As a programming language inform is an excelent tool for writing fiction. Take the built in 'What not to wear' example. On the one hand it shows how far the language can be pushed. On the other I haven't seen code this contorted since reading a book about Visual Basic 6.
Examples like this really show how much Inform is not natural language.
To be honest I still can't understand how the damn thing works. Getting it requires a much deeper understanding of Inform Grammer then I currently possess. Here Lies the nub. Inform makes simple things simple, and allows you to write interactive fiction. But like most special purpose tools it makes hard things harder.
From a language point of view we have conditionals, looping constructs and an object hierarchy. We can also construct data tables and lists. All in all we have a language which is not only Turing complete, but as feature rich as general purpose languages like Java. The problem, form a programming perspective, is that we have a syntax which can be more cryptic then Perl!
The short answer; If Clothing is not a central focus of your game; ie your character is not a catwalk model, then don't implement a generic clothing system. Changing a characters description when they put on a Jacket, or a Has mat suit is so much easier, and for most games is all that is required.
The other problem with overloading your games with generic systems is that most will be published as Z-code files, and this places some major limitations of executable size. Recent posts I've seen on rec.arts.int-fiction suggest that even the z8 standard has trouble reaching novel length (about 50,000 words) and that is without including bucket loads of extra real world simulation rules.
Sunday, July 06, 2008
Interactive Fiction
I've been toying with the idea of writing a text adventure for a few months. Granted I didn't do anything more than think about it untill a Random post on slashdot, or ReadIt (I forget which) linked me to Inform7.
Suddenly I discover that there is a thriving home brew community writing and playing Interactive Fiction. And Inform is a rather interesting approach to writing it.
Interestingly while story files are free they are not open source, as most games are shipped in binary form only.
Inform 7 is both very enticing and frustrating at the same time. Its goal to allow Interactive Fiction to be written in plain english is admirable and works quite well for simple cases. However in the end it is not english but a language which overlaps with it. The upside is it looks cool, and the fact that you are porgramming is generally hidden from few. The downside is that when you do need to do some programming you end up with a very verbose syntax, which often does not make sense as an english sentence.
For example: 'the list of things carried by the noun'. In English this is nonsense as nouns can't carry things, however it does make perfect sense to inform. As a comparison I had a cursory glance at Inform6 and TADS3, and there really is no contest in the given domain.
With inform I feel Like I'm writing a story, while with the others I'm very clearly programming. The challange now is to write somthing worth playing. Now I have a plot in mind, and I'm learning the tricks on how to extend inform to do new things. This leaves one stumbling block: I've forgotten how to think about Interactive fiction puzzles, solving them is hard enough, actually writing them, well I'm yet to come up with an interesting puzzle. Guess I need to play more Interactive Fiction first.
Thursday, June 05, 2008
Anonymous Recursive Function
I thought I'd give the 99 Lisp Problems a spin as a way of exploring Pico Lisp. One of my first outings came up with the discovery that if you call a function without enough arguments the remaining arguments get set to NIL this can be used to do default arguments as follows:
(de fun (X Y)
(let (Y (or Y 5))
(+ x Y)))
(fun 1 2) -> 2
(fun 1) -> 6
I did this to simulate an accumulator argument in a recursive function. But then i got to thinking, I'm executing the let on each recursive call, which seems kind of a waste as it is only needed on the first call. Well Pico has an answer for this recur and recurse which allows you to define an anonymous recursive function. Now this is something you don't find in your garden variety common lisp!
(de my-rev (lst)
(let (res ())
(recur (lst res)
(if (pair lst)
(recurse (cdr lst) (cons (car lst) res))
res))))
That is one neat way to make do without auxiliary functions.
Wednesday, June 04, 2008
Lisp is addictive
A week or so of Pico Lisp and I'm addicted again. Now the label was right, this is no common Lisp. Part of this means that a lot of built in functions have different names but then lets be honest, 'filter' is a much better name then 'remove-if-not'. I also found that there is no 'reduce' function but it was trivial to implement.
I have to say that having having one name space for functions and variables works, and using quote as lambda is growing on me. Pico lisp is proving to be a very succinct lisp to program in, which is a good thing.
Time permitting I'll be doing a lot more pico lisp hacking in the near future, port a few scripts I've done in python as practice and then on to some more interesting stuff. I've got some pointers on how to mix pico lisp and c code, which will is bound to prove useful
Sunday, June 01, 2008
Been away from Lisp too long.
Another omission, from the point of view of convenience, is the lack of a well developed string formatting function. Granted the built in symbol manipulation primitives are more general then a format function but in simple cases they lead to more verbose code. Note Pico Lisp does have a function called format but it is restricted to formating a single number as a fixed precision decimal.
Still I'm working slowly in adapting some examples from a Common Lisp book into Pico Lisp, and if nothing else its an enjoyable exercise.
It looks like I am on the Pico lisp mailing list, though I never got notified that my subscription request was accepted. Still I got to ask my question now, which is good.
Thursday, May 29, 2008
The Demise of the Desktop ... Not
Frankly I don't see this happening for a number of reasons.
- My Laptop is offline most of the time. I mostly use it on the train and don't have wireless broadband. In any case I doubt it would work too reliably sitting in aluminum clad train under high voltage cables.
- At home my download limit per month is about 300MB and is about right for my usage. frankly I couldn't afford to access online apps all the time.
- I don't trust the benevolent administrators of huge online file servers to keep my files confidential if it ever comes to the crunch. If large chunks of the worlds data are in one place then it becomes easy for governments to mandate the removal of 'harmful' material.
And in a corporate environment there is another host of problems with thin client, issues of Privacy regulations and Commercial secrets. An interesting fact comes up in this artilce on The Daily WTF. Switching a corporate environment to thin client increases infrastructure costs. Suddenly your junior desktop support staff who know how to run Norton Utilities just don't cut it any more, instead they need more servers and more system administrators.
Personally I like my Desktop applications and I use them all the time. My laptop is set up how I want it and not how Google wants it. Even when I do use my firfox it is usually to read pages I've saved for off line viewing using the scrapbook plug in. And importantly the files that detail how I'll achieve world domination are tucked away in a computer that can't be hacked without physical access (one of these days I must encrypt them).
White space
This means that I have probably spent weeks of accumulated time going back and adding semicolons to statements because I forgot to terminate them the first time round.
As for using python on larger projects. Well the answer is internal standards. If you try to contribute to C projects like GTK they come out and say things about standards right up front.
If you submit a patch and it doesn't meet the coding standards then we are going to reject it out of hand. Its quite a reasonable position to take.
Moreover a good editor will support a whitespace delimited language. My examples are from vim, though I assume that Emacs can do similar things as well (no need for another editor flame war).
- Auto indentation sticks consistent indents on my lines.
- Editor can highlight lines that mix tabs and spaces in their indents.
- Files can carry a special comment which defines indentation rules.
- If all else fails you can switch to a mode where whitespace characters are rendered so they are visible.
I had to write some java a while back, only a small simple problem, and after python I found it unbelivably hard. I realise this is largely personal preference, but iit felt like the syntax was fighting against me rather than helping me.
At the end of the day a good syntax is one which you don't notice. Foe me being a visual person seeing well indented code gives me a quick graps of what the code is supposed to do. One of my egocentricities in this regard is that I prefer:
to:
if foo:
return
else:
# do something else
if foo:Python will behave the same way in both cases, however for me the first option is more explicit. as I can see that we have an else branch without having to reach the code. If the body of the if is long enough it could be easy to miss that pesky return statement.
return
# do something else
Wednesday, May 28, 2008
Pico Lisp
- Fully interpreted and yet faster then compiled lisp in some usecases
- Persistent storage (essentially an object database)
- built in Prolog.
- built in web server and support for online applications.
- No floating point numbers ?
Using floating point in financial circles is in general a big no-no, people get a lttle tucky when your working with money and make rounding errors. Also its a little hard to do anything with a fraction of a cent.
Graphics. Well yes and no. Fixed precision might be quite good enough. Heck there's a 3d flight simulator application to prove it even. The Documentation claims it can be easily extended with C, including writing C functions inline, unfortunately exactly how this is done, or what the limitations are, is not explained. Once I get onto the mailing list I plan to ask.
First impressions are that this is a very small, neat and yet still useful language. Time will tell if I can do something interesting with it though.
Tuesday, May 27, 2008
Bad Karma
Sharon Stone's Karma comment has to be the dumbest thing any celebrity has said this year.
Karma is supposed to return to whom ever generated, and I fail to see how school children in Sichuan have oppressed Tibet. Its clear to anyone that this is a natural disaster which has affected perfectly ordinary innocent people. They have nothing to do with setting government policy in Tibet.
Seeing images of collapsed schools with a childs hand sticking out of them brings tears to my eyes. I can't imagine what it must be like to shift through ruble looking for your child. For some starlet to suggest that its Karma ... I'm lost for words really ...
Even the Democrat Presidential hopefuls haven't managed a gaff this bad.
I'd call for a boycot of Stone's movies myself, but in all honest I've never been a fan so I probably wouldn't have rushed out to see them in any case.