Archive for November, 2006

Tilda 0.9.4

Tilda 0.9.4 hit the shelves yesterday. Get yours before they are all gone.

Check out the ChangeLog to see what is new.


Read Full Post »

I’m sure most of you have heard of the absurd claim Microsoft has made regrading the Linux kernel. Same old story that SCO was giving. I don’t have time to rant on how insane this is or how mad I am at Novell, but I have a suggestion. Everyone collect some Monopoly money and send it to Microsoft, or Ballmer if someone finds his address with this note inside:

“Mr. Ballmer, Since you live in a fantasy world, thought we’d pay some fantasy money for your fantasy claim.”

The address is:

Microsoft Corporation
One Microsoft Way
Redmond, WA 98052-7329

Please, let me know if someone finds Ballmer’s address.

If you agree with this please post about it everywhere. Maybe we can create a day out of it. I don’t reach a very large crowd with my posts so any help would be great.

Read Full Post »

I never thought people really would get a dozen credit cards and then spend like crazy with a mind set of it being “free money”. Well I was wrong, this dumb girl did it, and I assume a whole lot more.

I used to blame kids who became brats and excess consumers on their parents. Which it partially is due to, no matter how much money I have my kids Christmas will be small. But when I see one of these rich kids blame it on parents I start to think, “Maybe they are just being brats again.” I mean of course it is not their responsibility to remember elementary arithmetic or anything… It is always someone elses fault. But I guess if you want to be sure your kids don’t grow up with the ability to do simple arithmetic, teach them the value of a dollar, or punch them in the nose with every stupid purchase.

The world is a scary place.

Read Full Post »

I thought it was bad enough when Digg readers were confused about 0.0…1 not being a number (couldn’t find the link again). I guess they are all 5 year olds who still say “I’m infinity plus one better than you!”. Only explanation I can come up with. But wow, they also are confused about Kerry’s joke about Bush. COME ON! It wasn’t that complicated. Slashdot has better commenters, and that is sad. I may just have to drop digg altogether and only use Reddit.

Read Full Post »

Why Vote?

Election day is tomorrow, Nov 7th, and I, like many of you, am hoping for a change. I know a lot of you are very anti-Democrat, saying they are the exact same as the Republicans. I wouldn’t call myself a Democrat (though I know many of you would call me that), but I thought I’d lay out some reasons to choose Democrats. Some of these won’t be able to be completed till they also take back the White House; however, some could be started now.

Major increase of pressure on administration regarding Iraq (both regarding troops and the insane amount of money being stolen by the corps getting the no bid contracts)
Stem Cells
Gay Marriage
Get rid of the damn abstinence only teaching in schools, Africa, etc
New Kyoto Treaty
No militarization of space
Public health care
Equal public schools
Try to stop that fucking wall — damn Mongolians
Higher Taxes! — someone has to pay the debt…. I think Republicans need to go back to elementary arithmetic

I know the first one will happen. They are running their campaign on change in Iraq and holding people in the administration accountable for what is happening. If they do not follow through on this it is game over. They have 2 years to make a major change in Iraq and find out what has really been going on. Will there be an impeachment? If the evidence is there I sure hope so. But if they don’t go in swinging in January they have no chance for ’08.

I am not saying don’t vote independent. Live in Texas? Vote Kinky! But I know the above are issues a lot of people are for but they are not going to go out and vote tomorrow because they think all politicians are scum. Well you are right. But I’d rather scum that keeps us out of another cold war (militarizing space) than scum that is going to continue ruining the environment, increase spending on military, push fear, push absitence, push for privitization, build a damn Great Wall and so on and so on.

Read Full Post »

OOP in Erlang

Erlang, a functional language built for concurrency, has no object oriented specific syntax, but is very open to object oriented design. I for one am not a huge fan of “pure” object oriented programming, but enjoy showing how to implement it in languages not considered OO. Erlang can do a lot of things in much less code than languages like Java, C/C++ and so on, but it does take awhile to see how to harness the power of Erlang. So, this OOP code may be useful and may be a complete waste of time, all depends on the problem I suppose. I doubt I will ever use anythng like this in a real project; however, I will use “OO” style code, just not as complete as what I came up with for this. That is one of my favorite things about languages like Erlang’s OOD, you build it to suit your needs.

This is a good bit of code and blogger lacks formatting, so please grab account.erl and test.erl to better see what is happening in the code.

The first thing we’ll need for our “class” is a module and some exported functions:


Now we have a module “account” with two exported functions, new and balanceLoop(must be exported since its spawned). The function new is called when we wanted to create a new object, obviously, and the balanceLoop is called from inside new:

new(Balance) ->
BPid = spawn(account, balanceLoop, [Balance]),
loop([{balance, BPid}]).

The second line above spawns a new process running function balanceLoop and stores its PID in BPid which is placed a tuple corresponding to the atom balance. This tuple is in a list which is sent as an argument to the function loop. Might sound complicated… Sorry. This is needed since Erlang like many other functional languages does not allow changing variables values. In order to create objects that can “change” the value of a “variable” we rely on processes (don’t worry processes are extremely cheap in Erlang).

balanceLoop(Current) ->
{get, From} -> From ! {balance_return, Current}, N = Current;
{set, NewBalance} -> N = NewBalance

The balanceLoop function, above, recurively calls itself waiting for a message of either {get, From} or {set, NewBalance}. This creates our get/set methods for the variable Balance. Now we need the loop function that is called in new:

loop(Variables) ->
{From, Method, Args} ->
case method(Method, Args, Variables) of
{result, R} ->
From ! {result, R};
no_method ->
_ -> no_method

loop will loop over itself passing a list of the internal/private “variables” (actually a list of tuples). When a message is received it should be of the form {From, Method, Args}, otherwise nothing is done, _. It calls the function method(…) with the arguments and the variable list and waits for a result or a no_method return telling us that method does not exist. This is basically the dispatch function that is hidden in other languages.

method(withdraw, Amount, V) ->
BPid = getPid(V, balance),
BPid ! {get, self()},
{balance_return, B} ->
BPid ! {set, B - Amount},
{result, success}

method(getBalance, _, V) ->
getPid(V, balance) ! {get, self()},
{balance_return, B} ->
{result, B}

method(_, _, _) ->

The method function is overridden 2 times for the methods getBalance and withdraw. withdraw uses getPid:

getPid (V, Atom) ->
case lists:keysearch(Atom, 1, V) of
false -> nil;
{value, {_, PID}} -> PID

to find out the PID for balance so that it can send a message to call get. It waits for the return result, in the form of a message. Then, it can subtract the argument Amount from the returned result and use that to set the new Balance. getBalance simply sends a message to balanceLoop, receives the result via a message and returns it.

Now to actually use the code above:

-export([test_account/0, new/2]).

new(Class, Args) ->
spawn(Class, new, [Args]).

test_account() ->
A1 = new(account, 10),
A1 ! {self(), withdraw, 4},
{result, success} -> success;
no_method -> no_method
A1 ! {self(), getBalance, []},
{result, R} ->
io:format("New Balance ~w~n: ", [R]);
no_method ->

The above code creates a new account object named A1 with the starting value of Balance at 10. It then withdraws 4, gets the new value and returns that new Balance.

Seems to me this is the way to do objects with changing state in Erlang, adding inheritance would be a simlpe modification to loop(). Hopefully, I got it mostly correct. I wouldn’t suggest using this in all Erlang projects, if any at all :). But it is there. Erlang has much better and more elagent ways to solve most problems, without “changing” state.

This does have a few advantages over other langauges. For one these really are messages being passed. Lots of books for OOP langauges use the wording “message passing”, but in reality they are not. Message passing, along with the fact that each object is its own process, gives us true concurrent objects.

Note: I left out the code for process garabage collection. Since the object and its memebers are proccesses, they must be killed when we no longer need the object. This can be seen in the code you can download above, a clean_up “method” in the loop takes care of it.

Read Full Post »